I am quite new to LaTeX and as I was reading the LaTeX Wikibook I came upon the following general definition for a command in LaTeX here:


However, later on in the Wikibook the syntax for creating a new command is given as:


Now given the general definition for a command in LaTeX I would have instead expected the following syntax for creating a new command:


A bit later on in the same section on creating macros in the LaTeX wikibook the syntax for creating a new environment is given as:


Again, given the general definition I would have expected this instead:


I would appreciate it greatly if somebody could clarify this inconsistency for me.

  • 2
    Welcome to TeX.SX! The nice thing about TeX is that it has almost no syntax of itself. The syntax is defined by you (or in this case, by LaTeX). Commands defined with \newcommand will invariably have the syntax \cmd{<arg1>}{<arg2>}... or \cmd[<opt>]{<arg1>}{<arg2>}.... Commands defined with xparse have much more flexibility, and you can also define the commands by hand to have virtually any syntax you want. Commented Oct 19, 2019 at 14:59
  • 7
    Welcome to TeX.SX! I don't find the LaTeX Wikibook a very reliable guide. Some commands accept comma separated options, but the vast majority doesn't. And a command can have multiple optional arguments, one case is indeed [math]\newcommand[/math].
    – egreg
    Commented Oct 19, 2019 at 15:00
  • 3
    The only somewhat consistent convention is to use [] for optional arguments and {} for mandatory ones. Third type is () for coordinates, but those are pretty rare in the LaTeX format itself (picture-mode). There are some classes and packages however that break this general rule and add optional braced arguments, so not even those are safe. And the concept of key=value optional arguments is relatively young, so the older the macro the less likely they are used.
    – Skillmon
    Commented Oct 19, 2019 at 15:05
  • Also, while it is possible in theory to use optional arguments in fully expandable macros, a key=value syntax will most likely never be fully expandable, so there might be macros which take normal and possibly multiple optional arguments in the distant future, when key=value has otherwise fully took over.
    – Skillmon
    Commented Oct 19, 2019 at 15:10
  • Could you explain what key=value means? Commented Oct 19, 2019 at 15:11


You must log in to answer this question.

Browse other questions tagged .