Define macro as wrapper for parameters of a command












3














I'm trying to define a macro that is a little wrapper to a common parameter of a command. The macro is expanded, but the parameter is not taken into account by the command.



The macro, sp is used inside an extreme table. Below are code and result: note that sp is expanded, but the parameter is not used. How can I define that macro to expand to an usable parameter?



% define macro sp
definesp{[bottomframe=off]}

% table setup
setupxtable[frame=off, bottomframe=on]

starttext

startxtable
startxtablehead
startxrow
startxcell Head 1 stopxcell
startxcell Head 2 stopxcell
stopxrow
stopxtablehead
startxtablebody
startxrow
startxcell A1 stopxcell
startxcell sp A2 stopxcell
stopxrow
startxrow
startxcell B1 stopxcell
startxcell stopxcell
stopxrow
stopxtablebody
stopxtable

stoptext


Result, with <code>sp</code> expanded but not used as parameter










share|improve this question







New contributor




José de Mattos Neto is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • As to explain why I reached at this: I'm writing documents in Markdown, and using Pandoc to generate PDF through a conversion to ConTeXt. Pandoc doesn't allow column or row spans on tables, so I'm figuring out how to fake that using borders. Turning bottom border off for a cell would make it seems as spanned. And using a macro for this is necessary in order to use default alignment of Pandoc tables.
    – José de Mattos Neto
    1 hour ago
















3














I'm trying to define a macro that is a little wrapper to a common parameter of a command. The macro is expanded, but the parameter is not taken into account by the command.



The macro, sp is used inside an extreme table. Below are code and result: note that sp is expanded, but the parameter is not used. How can I define that macro to expand to an usable parameter?



% define macro sp
definesp{[bottomframe=off]}

% table setup
setupxtable[frame=off, bottomframe=on]

starttext

startxtable
startxtablehead
startxrow
startxcell Head 1 stopxcell
startxcell Head 2 stopxcell
stopxrow
stopxtablehead
startxtablebody
startxrow
startxcell A1 stopxcell
startxcell sp A2 stopxcell
stopxrow
startxrow
startxcell B1 stopxcell
startxcell stopxcell
stopxrow
stopxtablebody
stopxtable

stoptext


Result, with <code>sp</code> expanded but not used as parameter










share|improve this question







New contributor




José de Mattos Neto is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • As to explain why I reached at this: I'm writing documents in Markdown, and using Pandoc to generate PDF through a conversion to ConTeXt. Pandoc doesn't allow column or row spans on tables, so I'm figuring out how to fake that using borders. Turning bottom border off for a cell would make it seems as spanned. And using a macro for this is necessary in order to use default alignment of Pandoc tables.
    – José de Mattos Neto
    1 hour ago














3












3








3







I'm trying to define a macro that is a little wrapper to a common parameter of a command. The macro is expanded, but the parameter is not taken into account by the command.



The macro, sp is used inside an extreme table. Below are code and result: note that sp is expanded, but the parameter is not used. How can I define that macro to expand to an usable parameter?



% define macro sp
definesp{[bottomframe=off]}

% table setup
setupxtable[frame=off, bottomframe=on]

starttext

startxtable
startxtablehead
startxrow
startxcell Head 1 stopxcell
startxcell Head 2 stopxcell
stopxrow
stopxtablehead
startxtablebody
startxrow
startxcell A1 stopxcell
startxcell sp A2 stopxcell
stopxrow
startxrow
startxcell B1 stopxcell
startxcell stopxcell
stopxrow
stopxtablebody
stopxtable

stoptext


Result, with <code>sp</code> expanded but not used as parameter










share|improve this question







New contributor




José de Mattos Neto is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm trying to define a macro that is a little wrapper to a common parameter of a command. The macro is expanded, but the parameter is not taken into account by the command.



The macro, sp is used inside an extreme table. Below are code and result: note that sp is expanded, but the parameter is not used. How can I define that macro to expand to an usable parameter?



% define macro sp
definesp{[bottomframe=off]}

% table setup
setupxtable[frame=off, bottomframe=on]

starttext

startxtable
startxtablehead
startxrow
startxcell Head 1 stopxcell
startxcell Head 2 stopxcell
stopxrow
stopxtablehead
startxtablebody
startxrow
startxcell A1 stopxcell
startxcell sp A2 stopxcell
stopxrow
startxrow
startxcell B1 stopxcell
startxcell stopxcell
stopxrow
stopxtablebody
stopxtable

stoptext


Result, with <code>sp</code> expanded but not used as parameter







macros context parameters definition






share|improve this question







New contributor




José de Mattos Neto is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




José de Mattos Neto is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




José de Mattos Neto is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 1 hour ago









José de Mattos Neto

555




555




New contributor




José de Mattos Neto is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





José de Mattos Neto is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






José de Mattos Neto is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • As to explain why I reached at this: I'm writing documents in Markdown, and using Pandoc to generate PDF through a conversion to ConTeXt. Pandoc doesn't allow column or row spans on tables, so I'm figuring out how to fake that using borders. Turning bottom border off for a cell would make it seems as spanned. And using a macro for this is necessary in order to use default alignment of Pandoc tables.
    – José de Mattos Neto
    1 hour ago


















  • As to explain why I reached at this: I'm writing documents in Markdown, and using Pandoc to generate PDF through a conversion to ConTeXt. Pandoc doesn't allow column or row spans on tables, so I'm figuring out how to fake that using borders. Turning bottom border off for a cell would make it seems as spanned. And using a macro for this is necessary in order to use default alignment of Pandoc tables.
    – José de Mattos Neto
    1 hour ago
















As to explain why I reached at this: I'm writing documents in Markdown, and using Pandoc to generate PDF through a conversion to ConTeXt. Pandoc doesn't allow column or row spans on tables, so I'm figuring out how to fake that using borders. Turning bottom border off for a cell would make it seems as spanned. And using a macro for this is necessary in order to use default alignment of Pandoc tables.
– José de Mattos Neto
1 hour ago




As to explain why I reached at this: I'm writing documents in Markdown, and using Pandoc to generate PDF through a conversion to ConTeXt. Pandoc doesn't allow column or row spans on tables, so I'm figuring out how to fake that using borders. Turning bottom border off for a cell would make it seems as spanned. And using a macro for this is necessary in order to use default alignment of Pandoc tables.
– José de Mattos Neto
1 hour ago










2 Answers
2






active

oldest

votes


















4














When a command takes a optional argument ConTeXt always checks if the next character after the command is [ which isn’t the case in your example.



To pass the argument which is hidden in the sp command to startxcell you have make the sp command expandable which can be done with defineexpandable. The next step is to expand the content of sp which can be done with expanded.



defineexpandablesp{[bottomframe=off]}

starttext

startxtable
startxrow
startxcell Cell 1 stopxcell
expanded{startxcell sp Cell 2 stopxcell}
stopxrow
stopxtable

stoptext


The better solution to pass the same arguments to a xtable multiple times is to create a named setup and pass the name as argument to the startxcell command.



setupxtable [sp] [bottomframe=off]

starttext

startxtable
startxrow
startxcell Cell 1 stopxcell
startxcell [sp] Cell 2 stopxcell
stopxrow
stopxtable

stoptext





share|improve this answer





























    3














    Imho there is no definition of sp that will do it. You would need a variant of startxcell that expands the following command once:



    definesp{[bottomframe=off]}
    definestartxcello{expandafter startxcell }

    % table setup
    setupxtable[frame=off, bottomframe=on]

    starttext

    startxtable
    startxtablehead
    startxrow
    startxcell Head 1 stopxcell
    startxcell Head 2 stopxcell
    stopxrow
    stopxtablehead
    startxtablebody
    startxrow
    startxcell A1 stopxcell
    startxcello sp A2 stopxcell
    stopxrow
    startxrow
    startxcell B1 stopxcell
    startxcell [bottomframe=off] B2 stopxcell
    stopxrow
    stopxtablebody
    stopxtable

    stoptext


    enter image description here






    share|improve this answer





















      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "85"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });






      José de Mattos Neto is a new contributor. Be nice, and check out our Code of Conduct.










      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467453%2fdefine-macro-as-wrapper-for-parameters-of-a-command%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      4














      When a command takes a optional argument ConTeXt always checks if the next character after the command is [ which isn’t the case in your example.



      To pass the argument which is hidden in the sp command to startxcell you have make the sp command expandable which can be done with defineexpandable. The next step is to expand the content of sp which can be done with expanded.



      defineexpandablesp{[bottomframe=off]}

      starttext

      startxtable
      startxrow
      startxcell Cell 1 stopxcell
      expanded{startxcell sp Cell 2 stopxcell}
      stopxrow
      stopxtable

      stoptext


      The better solution to pass the same arguments to a xtable multiple times is to create a named setup and pass the name as argument to the startxcell command.



      setupxtable [sp] [bottomframe=off]

      starttext

      startxtable
      startxrow
      startxcell Cell 1 stopxcell
      startxcell [sp] Cell 2 stopxcell
      stopxrow
      stopxtable

      stoptext





      share|improve this answer


























        4














        When a command takes a optional argument ConTeXt always checks if the next character after the command is [ which isn’t the case in your example.



        To pass the argument which is hidden in the sp command to startxcell you have make the sp command expandable which can be done with defineexpandable. The next step is to expand the content of sp which can be done with expanded.



        defineexpandablesp{[bottomframe=off]}

        starttext

        startxtable
        startxrow
        startxcell Cell 1 stopxcell
        expanded{startxcell sp Cell 2 stopxcell}
        stopxrow
        stopxtable

        stoptext


        The better solution to pass the same arguments to a xtable multiple times is to create a named setup and pass the name as argument to the startxcell command.



        setupxtable [sp] [bottomframe=off]

        starttext

        startxtable
        startxrow
        startxcell Cell 1 stopxcell
        startxcell [sp] Cell 2 stopxcell
        stopxrow
        stopxtable

        stoptext





        share|improve this answer
























          4












          4








          4






          When a command takes a optional argument ConTeXt always checks if the next character after the command is [ which isn’t the case in your example.



          To pass the argument which is hidden in the sp command to startxcell you have make the sp command expandable which can be done with defineexpandable. The next step is to expand the content of sp which can be done with expanded.



          defineexpandablesp{[bottomframe=off]}

          starttext

          startxtable
          startxrow
          startxcell Cell 1 stopxcell
          expanded{startxcell sp Cell 2 stopxcell}
          stopxrow
          stopxtable

          stoptext


          The better solution to pass the same arguments to a xtable multiple times is to create a named setup and pass the name as argument to the startxcell command.



          setupxtable [sp] [bottomframe=off]

          starttext

          startxtable
          startxrow
          startxcell Cell 1 stopxcell
          startxcell [sp] Cell 2 stopxcell
          stopxrow
          stopxtable

          stoptext





          share|improve this answer












          When a command takes a optional argument ConTeXt always checks if the next character after the command is [ which isn’t the case in your example.



          To pass the argument which is hidden in the sp command to startxcell you have make the sp command expandable which can be done with defineexpandable. The next step is to expand the content of sp which can be done with expanded.



          defineexpandablesp{[bottomframe=off]}

          starttext

          startxtable
          startxrow
          startxcell Cell 1 stopxcell
          expanded{startxcell sp Cell 2 stopxcell}
          stopxrow
          stopxtable

          stoptext


          The better solution to pass the same arguments to a xtable multiple times is to create a named setup and pass the name as argument to the startxcell command.



          setupxtable [sp] [bottomframe=off]

          starttext

          startxtable
          startxrow
          startxcell Cell 1 stopxcell
          startxcell [sp] Cell 2 stopxcell
          stopxrow
          stopxtable

          stoptext






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 1 hour ago









          Wolfgang Schuster

          4,9811711




          4,9811711























              3














              Imho there is no definition of sp that will do it. You would need a variant of startxcell that expands the following command once:



              definesp{[bottomframe=off]}
              definestartxcello{expandafter startxcell }

              % table setup
              setupxtable[frame=off, bottomframe=on]

              starttext

              startxtable
              startxtablehead
              startxrow
              startxcell Head 1 stopxcell
              startxcell Head 2 stopxcell
              stopxrow
              stopxtablehead
              startxtablebody
              startxrow
              startxcell A1 stopxcell
              startxcello sp A2 stopxcell
              stopxrow
              startxrow
              startxcell B1 stopxcell
              startxcell [bottomframe=off] B2 stopxcell
              stopxrow
              stopxtablebody
              stopxtable

              stoptext


              enter image description here






              share|improve this answer


























                3














                Imho there is no definition of sp that will do it. You would need a variant of startxcell that expands the following command once:



                definesp{[bottomframe=off]}
                definestartxcello{expandafter startxcell }

                % table setup
                setupxtable[frame=off, bottomframe=on]

                starttext

                startxtable
                startxtablehead
                startxrow
                startxcell Head 1 stopxcell
                startxcell Head 2 stopxcell
                stopxrow
                stopxtablehead
                startxtablebody
                startxrow
                startxcell A1 stopxcell
                startxcello sp A2 stopxcell
                stopxrow
                startxrow
                startxcell B1 stopxcell
                startxcell [bottomframe=off] B2 stopxcell
                stopxrow
                stopxtablebody
                stopxtable

                stoptext


                enter image description here






                share|improve this answer
























                  3












                  3








                  3






                  Imho there is no definition of sp that will do it. You would need a variant of startxcell that expands the following command once:



                  definesp{[bottomframe=off]}
                  definestartxcello{expandafter startxcell }

                  % table setup
                  setupxtable[frame=off, bottomframe=on]

                  starttext

                  startxtable
                  startxtablehead
                  startxrow
                  startxcell Head 1 stopxcell
                  startxcell Head 2 stopxcell
                  stopxrow
                  stopxtablehead
                  startxtablebody
                  startxrow
                  startxcell A1 stopxcell
                  startxcello sp A2 stopxcell
                  stopxrow
                  startxrow
                  startxcell B1 stopxcell
                  startxcell [bottomframe=off] B2 stopxcell
                  stopxrow
                  stopxtablebody
                  stopxtable

                  stoptext


                  enter image description here






                  share|improve this answer












                  Imho there is no definition of sp that will do it. You would need a variant of startxcell that expands the following command once:



                  definesp{[bottomframe=off]}
                  definestartxcello{expandafter startxcell }

                  % table setup
                  setupxtable[frame=off, bottomframe=on]

                  starttext

                  startxtable
                  startxtablehead
                  startxrow
                  startxcell Head 1 stopxcell
                  startxcell Head 2 stopxcell
                  stopxrow
                  stopxtablehead
                  startxtablebody
                  startxrow
                  startxcell A1 stopxcell
                  startxcello sp A2 stopxcell
                  stopxrow
                  startxrow
                  startxcell B1 stopxcell
                  startxcell [bottomframe=off] B2 stopxcell
                  stopxrow
                  stopxtablebody
                  stopxtable

                  stoptext


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 1 hour ago









                  Ulrike Fischer

                  185k7289667




                  185k7289667






















                      José de Mattos Neto is a new contributor. Be nice, and check out our Code of Conduct.










                      draft saved

                      draft discarded


















                      José de Mattos Neto is a new contributor. Be nice, and check out our Code of Conduct.













                      José de Mattos Neto is a new contributor. Be nice, and check out our Code of Conduct.












                      José de Mattos Neto is a new contributor. Be nice, and check out our Code of Conduct.
















                      Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467453%2fdefine-macro-as-wrapper-for-parameters-of-a-command%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      404 Error Contact Form 7 ajax form submitting

                      How to know if a Active Directory user can login interactively

                      TypeError: fit_transform() missing 1 required positional argument: 'X'