Define macro as wrapper for parameters of a command












4















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























  • 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
    Dec 26 '18 at 22:33
















4















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























  • 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
    Dec 26 '18 at 22:33














4












4








4








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














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













share|improve this question











share|improve this question




share|improve this question










asked Dec 26 '18 at 22:27









José de Mattos NetoJosé de Mattos Neto

897




897













  • 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
    Dec 26 '18 at 22:33



















  • 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
    Dec 26 '18 at 22:33

















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
Dec 26 '18 at 22:33





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
Dec 26 '18 at 22:33










2 Answers
2






active

oldest

votes


















7














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































    5














    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
      });


      }
      });














      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









      7














      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




























        7














        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


























          7












          7








          7







          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 Dec 26 '18 at 22:42









          Wolfgang SchusterWolfgang Schuster

          5,6011711




          5,6011711























              5














              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




























                5














                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


























                  5












                  5








                  5







                  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 Dec 26 '18 at 22:35









                  Ulrike FischerUlrike Fischer

                  192k8302683




                  192k8302683






























                      draft saved

                      draft discarded




















































                      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.




                      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

                      Bressuire

                      Cabo Verde

                      Gyllenstierna