What is this newcommand argument? [duplicate]












2
















This question already has an answer here:




  • newcommand argument confusion

    4 answers




newcommand*{name}[1][C]{%


I have come very familiar with newcommand however, I came across this line of code and i do not know what the [C] is for.










share|improve this question















marked as duplicate by Alan Munn, Stefan Pinnow, Kurt, Henri Menke, Andrew Swann Jan 21 at 8:18


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 2





    Welcome to TeX.SE! This means in this case that name has one optional argument whose default value is C.

    – marmot
    Jan 21 at 3:30











  • latexref.xyz/…

    – Henri Menke
    Jan 21 at 3:39











  • @HenriMenke Is there a more modern link in which things like it do not get advertized?

    – marmot
    Jan 21 at 3:54











  • @marmot Well, it etc. are commands provided by the standard LaTeX classes, so naturally they would be listed in a reference manual. However, you can contribute and remove them latexref.xyz/dev/writing.html

    – Henri Menke
    Jan 21 at 4:08











  • @HenriMenke Please don't get me wrong, this was not meant to criticize you. I have just seen so many cases in which users, especially new users, got interesting comments when they were using it and so on. Therefore I am really wondering if there are sources of the same information which a free of such relics.

    – marmot
    Jan 21 at 4:13
















2
















This question already has an answer here:




  • newcommand argument confusion

    4 answers




newcommand*{name}[1][C]{%


I have come very familiar with newcommand however, I came across this line of code and i do not know what the [C] is for.










share|improve this question















marked as duplicate by Alan Munn, Stefan Pinnow, Kurt, Henri Menke, Andrew Swann Jan 21 at 8:18


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 2





    Welcome to TeX.SE! This means in this case that name has one optional argument whose default value is C.

    – marmot
    Jan 21 at 3:30











  • latexref.xyz/…

    – Henri Menke
    Jan 21 at 3:39











  • @HenriMenke Is there a more modern link in which things like it do not get advertized?

    – marmot
    Jan 21 at 3:54











  • @marmot Well, it etc. are commands provided by the standard LaTeX classes, so naturally they would be listed in a reference manual. However, you can contribute and remove them latexref.xyz/dev/writing.html

    – Henri Menke
    Jan 21 at 4:08











  • @HenriMenke Please don't get me wrong, this was not meant to criticize you. I have just seen so many cases in which users, especially new users, got interesting comments when they were using it and so on. Therefore I am really wondering if there are sources of the same information which a free of such relics.

    – marmot
    Jan 21 at 4:13














2












2








2









This question already has an answer here:




  • newcommand argument confusion

    4 answers




newcommand*{name}[1][C]{%


I have come very familiar with newcommand however, I came across this line of code and i do not know what the [C] is for.










share|improve this question

















This question already has an answer here:




  • newcommand argument confusion

    4 answers




newcommand*{name}[1][C]{%


I have come very familiar with newcommand however, I came across this line of code and i do not know what the [C] is for.





This question already has an answer here:




  • newcommand argument confusion

    4 answers








macros arguments






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 21 at 6:21









Werner

441k679731668




441k679731668










asked Jan 21 at 3:30









Jesus EscarenoJesus Escareno

111




111




marked as duplicate by Alan Munn, Stefan Pinnow, Kurt, Henri Menke, Andrew Swann Jan 21 at 8:18


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Alan Munn, Stefan Pinnow, Kurt, Henri Menke, Andrew Swann Jan 21 at 8:18


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2





    Welcome to TeX.SE! This means in this case that name has one optional argument whose default value is C.

    – marmot
    Jan 21 at 3:30











  • latexref.xyz/…

    – Henri Menke
    Jan 21 at 3:39











  • @HenriMenke Is there a more modern link in which things like it do not get advertized?

    – marmot
    Jan 21 at 3:54











  • @marmot Well, it etc. are commands provided by the standard LaTeX classes, so naturally they would be listed in a reference manual. However, you can contribute and remove them latexref.xyz/dev/writing.html

    – Henri Menke
    Jan 21 at 4:08











  • @HenriMenke Please don't get me wrong, this was not meant to criticize you. I have just seen so many cases in which users, especially new users, got interesting comments when they were using it and so on. Therefore I am really wondering if there are sources of the same information which a free of such relics.

    – marmot
    Jan 21 at 4:13














  • 2





    Welcome to TeX.SE! This means in this case that name has one optional argument whose default value is C.

    – marmot
    Jan 21 at 3:30











  • latexref.xyz/…

    – Henri Menke
    Jan 21 at 3:39











  • @HenriMenke Is there a more modern link in which things like it do not get advertized?

    – marmot
    Jan 21 at 3:54











  • @marmot Well, it etc. are commands provided by the standard LaTeX classes, so naturally they would be listed in a reference manual. However, you can contribute and remove them latexref.xyz/dev/writing.html

    – Henri Menke
    Jan 21 at 4:08











  • @HenriMenke Please don't get me wrong, this was not meant to criticize you. I have just seen so many cases in which users, especially new users, got interesting comments when they were using it and so on. Therefore I am really wondering if there are sources of the same information which a free of such relics.

    – marmot
    Jan 21 at 4:13








2




2





Welcome to TeX.SE! This means in this case that name has one optional argument whose default value is C.

– marmot
Jan 21 at 3:30





Welcome to TeX.SE! This means in this case that name has one optional argument whose default value is C.

– marmot
Jan 21 at 3:30













latexref.xyz/…

– Henri Menke
Jan 21 at 3:39





latexref.xyz/…

– Henri Menke
Jan 21 at 3:39













@HenriMenke Is there a more modern link in which things like it do not get advertized?

– marmot
Jan 21 at 3:54





@HenriMenke Is there a more modern link in which things like it do not get advertized?

– marmot
Jan 21 at 3:54













@marmot Well, it etc. are commands provided by the standard LaTeX classes, so naturally they would be listed in a reference manual. However, you can contribute and remove them latexref.xyz/dev/writing.html

– Henri Menke
Jan 21 at 4:08





@marmot Well, it etc. are commands provided by the standard LaTeX classes, so naturally they would be listed in a reference manual. However, you can contribute and remove them latexref.xyz/dev/writing.html

– Henri Menke
Jan 21 at 4:08













@HenriMenke Please don't get me wrong, this was not meant to criticize you. I have just seen so many cases in which users, especially new users, got interesting comments when they were using it and so on. Therefore I am really wondering if there are sources of the same information which a free of such relics.

– marmot
Jan 21 at 4:13





@HenriMenke Please don't get me wrong, this was not meant to criticize you. I have just seen so many cases in which users, especially new users, got interesting comments when they were using it and so on. Therefore I am really wondering if there are sources of the same information which a free of such relics.

– marmot
Jan 21 at 4:13










1 Answer
1






active

oldest

votes


















4














LaTeX's newcommand has the following syntax:




newcommand *{<FOO>}[<i>]{<TEXT>}


User command to define FOO to be a macro with i arguments (i = 0 if missing)
having the definition <TEXT>. Produces an error if FOO already defined.
Normally the command is defined to be long (i.e. it may take multiple paragraphs in its argument). In the star-form, the command is not defined as long
and a blank line in any argument to the command would generate an error.




If you define a command with at least one argument (i > 0), you can specify an additional (optional) argument before the definition <TEXT>. This optional argument will be used as the "default" value for a first optional argument to FOO.



So, as an example, consider



newcommand{FOO}[2]{<TEXT>}


This command has two mandatory arguments and is therefore used as FOO{<one>}{<two>}. However,



newcommand{FOO}[2][X]{<TEXT>}


takes two (2) arguments, the first of which is optional and has a default of X (if not supplied). You can use it as FOO{<one>} (which is equivalent to FOO[X]{<one>}) or FOO[<one>]{<two>}. Similarly,



newcommand{FOO}[1][X]{<TEXT>}


takes a single (1) optional argument that has a default value of X (if not supplied) and can be used as FOO (which is equivalent to FOO[X]) or FOO[<one>].





In your particular case,



newcommand*{name}[1][C]{<TEXT>}


defines name to (be non-long; that is, <TEXT> cannot have blank lines and) take a single (1) optional argument that defaults to C if not supplied. You can use it as name (which is equivalent to name[C]) or name[<one>].



Reference:




  • LaTeX2e sources


  • What do newcommand, renewcommand, and providecommand do, and how do they differ?


  • What is the difference between def and newcommand?







share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    LaTeX's newcommand has the following syntax:




    newcommand *{<FOO>}[<i>]{<TEXT>}


    User command to define FOO to be a macro with i arguments (i = 0 if missing)
    having the definition <TEXT>. Produces an error if FOO already defined.
    Normally the command is defined to be long (i.e. it may take multiple paragraphs in its argument). In the star-form, the command is not defined as long
    and a blank line in any argument to the command would generate an error.




    If you define a command with at least one argument (i > 0), you can specify an additional (optional) argument before the definition <TEXT>. This optional argument will be used as the "default" value for a first optional argument to FOO.



    So, as an example, consider



    newcommand{FOO}[2]{<TEXT>}


    This command has two mandatory arguments and is therefore used as FOO{<one>}{<two>}. However,



    newcommand{FOO}[2][X]{<TEXT>}


    takes two (2) arguments, the first of which is optional and has a default of X (if not supplied). You can use it as FOO{<one>} (which is equivalent to FOO[X]{<one>}) or FOO[<one>]{<two>}. Similarly,



    newcommand{FOO}[1][X]{<TEXT>}


    takes a single (1) optional argument that has a default value of X (if not supplied) and can be used as FOO (which is equivalent to FOO[X]) or FOO[<one>].





    In your particular case,



    newcommand*{name}[1][C]{<TEXT>}


    defines name to (be non-long; that is, <TEXT> cannot have blank lines and) take a single (1) optional argument that defaults to C if not supplied. You can use it as name (which is equivalent to name[C]) or name[<one>].



    Reference:




    • LaTeX2e sources


    • What do newcommand, renewcommand, and providecommand do, and how do they differ?


    • What is the difference between def and newcommand?







    share|improve this answer




























      4














      LaTeX's newcommand has the following syntax:




      newcommand *{<FOO>}[<i>]{<TEXT>}


      User command to define FOO to be a macro with i arguments (i = 0 if missing)
      having the definition <TEXT>. Produces an error if FOO already defined.
      Normally the command is defined to be long (i.e. it may take multiple paragraphs in its argument). In the star-form, the command is not defined as long
      and a blank line in any argument to the command would generate an error.




      If you define a command with at least one argument (i > 0), you can specify an additional (optional) argument before the definition <TEXT>. This optional argument will be used as the "default" value for a first optional argument to FOO.



      So, as an example, consider



      newcommand{FOO}[2]{<TEXT>}


      This command has two mandatory arguments and is therefore used as FOO{<one>}{<two>}. However,



      newcommand{FOO}[2][X]{<TEXT>}


      takes two (2) arguments, the first of which is optional and has a default of X (if not supplied). You can use it as FOO{<one>} (which is equivalent to FOO[X]{<one>}) or FOO[<one>]{<two>}. Similarly,



      newcommand{FOO}[1][X]{<TEXT>}


      takes a single (1) optional argument that has a default value of X (if not supplied) and can be used as FOO (which is equivalent to FOO[X]) or FOO[<one>].





      In your particular case,



      newcommand*{name}[1][C]{<TEXT>}


      defines name to (be non-long; that is, <TEXT> cannot have blank lines and) take a single (1) optional argument that defaults to C if not supplied. You can use it as name (which is equivalent to name[C]) or name[<one>].



      Reference:




      • LaTeX2e sources


      • What do newcommand, renewcommand, and providecommand do, and how do they differ?


      • What is the difference between def and newcommand?







      share|improve this answer


























        4












        4








        4







        LaTeX's newcommand has the following syntax:




        newcommand *{<FOO>}[<i>]{<TEXT>}


        User command to define FOO to be a macro with i arguments (i = 0 if missing)
        having the definition <TEXT>. Produces an error if FOO already defined.
        Normally the command is defined to be long (i.e. it may take multiple paragraphs in its argument). In the star-form, the command is not defined as long
        and a blank line in any argument to the command would generate an error.




        If you define a command with at least one argument (i > 0), you can specify an additional (optional) argument before the definition <TEXT>. This optional argument will be used as the "default" value for a first optional argument to FOO.



        So, as an example, consider



        newcommand{FOO}[2]{<TEXT>}


        This command has two mandatory arguments and is therefore used as FOO{<one>}{<two>}. However,



        newcommand{FOO}[2][X]{<TEXT>}


        takes two (2) arguments, the first of which is optional and has a default of X (if not supplied). You can use it as FOO{<one>} (which is equivalent to FOO[X]{<one>}) or FOO[<one>]{<two>}. Similarly,



        newcommand{FOO}[1][X]{<TEXT>}


        takes a single (1) optional argument that has a default value of X (if not supplied) and can be used as FOO (which is equivalent to FOO[X]) or FOO[<one>].





        In your particular case,



        newcommand*{name}[1][C]{<TEXT>}


        defines name to (be non-long; that is, <TEXT> cannot have blank lines and) take a single (1) optional argument that defaults to C if not supplied. You can use it as name (which is equivalent to name[C]) or name[<one>].



        Reference:




        • LaTeX2e sources


        • What do newcommand, renewcommand, and providecommand do, and how do they differ?


        • What is the difference between def and newcommand?







        share|improve this answer













        LaTeX's newcommand has the following syntax:




        newcommand *{<FOO>}[<i>]{<TEXT>}


        User command to define FOO to be a macro with i arguments (i = 0 if missing)
        having the definition <TEXT>. Produces an error if FOO already defined.
        Normally the command is defined to be long (i.e. it may take multiple paragraphs in its argument). In the star-form, the command is not defined as long
        and a blank line in any argument to the command would generate an error.




        If you define a command with at least one argument (i > 0), you can specify an additional (optional) argument before the definition <TEXT>. This optional argument will be used as the "default" value for a first optional argument to FOO.



        So, as an example, consider



        newcommand{FOO}[2]{<TEXT>}


        This command has two mandatory arguments and is therefore used as FOO{<one>}{<two>}. However,



        newcommand{FOO}[2][X]{<TEXT>}


        takes two (2) arguments, the first of which is optional and has a default of X (if not supplied). You can use it as FOO{<one>} (which is equivalent to FOO[X]{<one>}) or FOO[<one>]{<two>}. Similarly,



        newcommand{FOO}[1][X]{<TEXT>}


        takes a single (1) optional argument that has a default value of X (if not supplied) and can be used as FOO (which is equivalent to FOO[X]) or FOO[<one>].





        In your particular case,



        newcommand*{name}[1][C]{<TEXT>}


        defines name to (be non-long; that is, <TEXT> cannot have blank lines and) take a single (1) optional argument that defaults to C if not supplied. You can use it as name (which is equivalent to name[C]) or name[<one>].



        Reference:




        • LaTeX2e sources


        • What do newcommand, renewcommand, and providecommand do, and how do they differ?


        • What is the difference between def and newcommand?








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 21 at 6:21









        WernerWerner

        441k679731668




        441k679731668















            Popular posts from this blog

            Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?