newcolumntype with optional argument

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












4















With the array package we can define a new column specifier that can be used in a tabular environment (e.g. newcolumntypeA[>centering arraybackslashm2cm).



It is even allowed to define a new column type with an argument like newcolumntypeB[1]>centering arraybackslashm#1.



Now I need to let the new colomn type argument have a default value like newcolumntypeC[1][2cm]>centering arraybackslashm#1 but this results in a compilation error.



So I am asking if it is possible to provide a default argument to the newcolumntype command?



MWE



documentclassarticle
usepackagearray
newcolumntypeA[1]>centering arraybackslashm#1

%newcolumntypeB[1]{3cm]>centering arraybackslashm#1

begindocument
begintabularhline
column width = 2 cm & column width= 4cm \hline
hello world hello world hello world & hello world hello world hello world\hline
endtabular
enddocument


enter image description here










share|improve this question


























    4















    With the array package we can define a new column specifier that can be used in a tabular environment (e.g. newcolumntypeA[>centering arraybackslashm2cm).



    It is even allowed to define a new column type with an argument like newcolumntypeB[1]>centering arraybackslashm#1.



    Now I need to let the new colomn type argument have a default value like newcolumntypeC[1][2cm]>centering arraybackslashm#1 but this results in a compilation error.



    So I am asking if it is possible to provide a default argument to the newcolumntype command?



    MWE



    documentclassarticle
    usepackagearray
    newcolumntypeA[1]>centering arraybackslashm#1

    %newcolumntypeB[1]{3cm]>centering arraybackslashm#1

    begindocument
    begintabularhline
    column width = 2 cm & column width= 4cm \hline
    hello world hello world hello world & hello world hello world hello world\hline
    endtabular
    enddocument


    enter image description here










    share|improve this question
























      4












      4








      4








      With the array package we can define a new column specifier that can be used in a tabular environment (e.g. newcolumntypeA[>centering arraybackslashm2cm).



      It is even allowed to define a new column type with an argument like newcolumntypeB[1]>centering arraybackslashm#1.



      Now I need to let the new colomn type argument have a default value like newcolumntypeC[1][2cm]>centering arraybackslashm#1 but this results in a compilation error.



      So I am asking if it is possible to provide a default argument to the newcolumntype command?



      MWE



      documentclassarticle
      usepackagearray
      newcolumntypeA[1]>centering arraybackslashm#1

      %newcolumntypeB[1]{3cm]>centering arraybackslashm#1

      begindocument
      begintabularhline
      column width = 2 cm & column width= 4cm \hline
      hello world hello world hello world & hello world hello world hello world\hline
      endtabular
      enddocument


      enter image description here










      share|improve this question














      With the array package we can define a new column specifier that can be used in a tabular environment (e.g. newcolumntypeA[>centering arraybackslashm2cm).



      It is even allowed to define a new column type with an argument like newcolumntypeB[1]>centering arraybackslashm#1.



      Now I need to let the new colomn type argument have a default value like newcolumntypeC[1][2cm]>centering arraybackslashm#1 but this results in a compilation error.



      So I am asking if it is possible to provide a default argument to the newcolumntype command?



      MWE



      documentclassarticle
      usepackagearray
      newcolumntypeA[1]>centering arraybackslashm#1

      %newcolumntypeB[1]{3cm]>centering arraybackslashm#1

      begindocument
      begintabularhline
      column width = 2 cm & column width= 4cm \hline
      hello world hello world hello world & hello world hello world hello world\hline
      endtabular
      enddocument


      enter image description here







      tables






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 9 at 12:17









      Hafid BoukhouldaHafid Boukhoulda

      2,3521517




      2,3521517




















          1 Answer
          1






          active

          oldest

          votes


















          6














          You can not do that without somewhat extensive changes to the array package, adding the declaration possibility would be simple but the mechanism used to replace defined columntypes does not have anything that would help detect optional parameters, so you would have to change that mechanism, and doing that without breaking packages that depend on it (colortbl, tabularx, tabulary, ....) might be tricky.



          If you accept an empty argument rather than an optional one it is easy, so the benefits of such a change compared to the risk of breaking existing code are rather discouraging adding such a feature.



          newcolumntypeA[1]>centering arraybackslashmif!#1!3cmelse#1fi


          would allow A to use a default width of 3cm






          share|improve this answer























          • Thank's for you reply! Unfortunately for me I have intensively used the column type A with no argument.

            – Hafid Boukhoulda
            Jan 9 at 12:57






          • 2





            @HafidBoukhoulda ok in that case, I think the answer is to use A for the default case and B for the case with an argument. It's what I'd do.

            – David Carlisle
            Jan 9 at 15:15










          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%2f469345%2fnewcolumntype-with-optional-argument%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          6














          You can not do that without somewhat extensive changes to the array package, adding the declaration possibility would be simple but the mechanism used to replace defined columntypes does not have anything that would help detect optional parameters, so you would have to change that mechanism, and doing that without breaking packages that depend on it (colortbl, tabularx, tabulary, ....) might be tricky.



          If you accept an empty argument rather than an optional one it is easy, so the benefits of such a change compared to the risk of breaking existing code are rather discouraging adding such a feature.



          newcolumntypeA[1]>centering arraybackslashmif!#1!3cmelse#1fi


          would allow A to use a default width of 3cm






          share|improve this answer























          • Thank's for you reply! Unfortunately for me I have intensively used the column type A with no argument.

            – Hafid Boukhoulda
            Jan 9 at 12:57






          • 2





            @HafidBoukhoulda ok in that case, I think the answer is to use A for the default case and B for the case with an argument. It's what I'd do.

            – David Carlisle
            Jan 9 at 15:15















          6














          You can not do that without somewhat extensive changes to the array package, adding the declaration possibility would be simple but the mechanism used to replace defined columntypes does not have anything that would help detect optional parameters, so you would have to change that mechanism, and doing that without breaking packages that depend on it (colortbl, tabularx, tabulary, ....) might be tricky.



          If you accept an empty argument rather than an optional one it is easy, so the benefits of such a change compared to the risk of breaking existing code are rather discouraging adding such a feature.



          newcolumntypeA[1]>centering arraybackslashmif!#1!3cmelse#1fi


          would allow A to use a default width of 3cm






          share|improve this answer























          • Thank's for you reply! Unfortunately for me I have intensively used the column type A with no argument.

            – Hafid Boukhoulda
            Jan 9 at 12:57






          • 2





            @HafidBoukhoulda ok in that case, I think the answer is to use A for the default case and B for the case with an argument. It's what I'd do.

            – David Carlisle
            Jan 9 at 15:15













          6












          6








          6







          You can not do that without somewhat extensive changes to the array package, adding the declaration possibility would be simple but the mechanism used to replace defined columntypes does not have anything that would help detect optional parameters, so you would have to change that mechanism, and doing that without breaking packages that depend on it (colortbl, tabularx, tabulary, ....) might be tricky.



          If you accept an empty argument rather than an optional one it is easy, so the benefits of such a change compared to the risk of breaking existing code are rather discouraging adding such a feature.



          newcolumntypeA[1]>centering arraybackslashmif!#1!3cmelse#1fi


          would allow A to use a default width of 3cm






          share|improve this answer













          You can not do that without somewhat extensive changes to the array package, adding the declaration possibility would be simple but the mechanism used to replace defined columntypes does not have anything that would help detect optional parameters, so you would have to change that mechanism, and doing that without breaking packages that depend on it (colortbl, tabularx, tabulary, ....) might be tricky.



          If you accept an empty argument rather than an optional one it is easy, so the benefits of such a change compared to the risk of breaking existing code are rather discouraging adding such a feature.



          newcolumntypeA[1]>centering arraybackslashmif!#1!3cmelse#1fi


          would allow A to use a default width of 3cm







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 9 at 12:29









          David CarlisleDavid Carlisle

          487k4111231868




          487k4111231868












          • Thank's for you reply! Unfortunately for me I have intensively used the column type A with no argument.

            – Hafid Boukhoulda
            Jan 9 at 12:57






          • 2





            @HafidBoukhoulda ok in that case, I think the answer is to use A for the default case and B for the case with an argument. It's what I'd do.

            – David Carlisle
            Jan 9 at 15:15

















          • Thank's for you reply! Unfortunately for me I have intensively used the column type A with no argument.

            – Hafid Boukhoulda
            Jan 9 at 12:57






          • 2





            @HafidBoukhoulda ok in that case, I think the answer is to use A for the default case and B for the case with an argument. It's what I'd do.

            – David Carlisle
            Jan 9 at 15:15
















          Thank's for you reply! Unfortunately for me I have intensively used the column type A with no argument.

          – Hafid Boukhoulda
          Jan 9 at 12:57





          Thank's for you reply! Unfortunately for me I have intensively used the column type A with no argument.

          – Hafid Boukhoulda
          Jan 9 at 12:57




          2




          2





          @HafidBoukhoulda ok in that case, I think the answer is to use A for the default case and B for the case with an argument. It's what I'd do.

          – David Carlisle
          Jan 9 at 15:15





          @HafidBoukhoulda ok in that case, I think the answer is to use A for the default case and B for the case with an argument. It's what I'd do.

          – David Carlisle
          Jan 9 at 15:15

















          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%2f469345%2fnewcolumntype-with-optional-argument%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

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?