Definitions

In LATEX, commands can have both mandatory and optional arguments, for example in:
verbatim45#
the |11pt| argument is optional, whereas the |article| class name is mandatory. In LATEX~2.09 users could define commands with arguments, but these had to be mandatory arguments. With LATEX2e, users can now define commands and environments which also have one optional argument.
#decl227#
These commands have a new, second, optional argument; this is used for defining commands which themselves take one optional argument. This new argument is best introduced by means of a simple (and hence not very practical) example:
verbatim46#
This defines || to be a command with two arguments, referred to as |#1| and |#2| in the <#239#>definition<#239#>---nothing new so far. But by adding a second optional argument to this | | (the |[YYY]|) the first argument (|#1|) of the newly defined command || is made optional with its default value being |YYY|. Thus the usage of || is either:
verbatim47#
which prints:
Mandatory arg: BBB; Optional arg: YYY.
or:
verbatim48#
which prints:
Mandatory arg: AAA; Optional arg: XXX.
The default value of the optional argument is YYY. This value is specified as the <#249#>default<#249#> argument of the | | that created ||. As another more useful example, the definition:
verbatim49#
means that the input |#tex2html_wrap_inline1767#a| produces the formula #math65#{a0,…, an}, whereas the input |#math66##tex2html_wrap_inline1770#[k]x| produces the formula #math67#{x0,…, xk}. In summary, the command:
| | <#259#>cmd<#259#> <#260#>num<#260#> <#261#>default<#261#> <#262#>definition<#262#>
defines <#264#>cmd<#264#> to be a command with <#265#>num<#265#> arguments, the first of which is optional and has default value <#266#>default<#266#>. Note that there can only be one optional argument but, as before, there can be up to nine arguments in total.
#decl267#
LATEX2e also supports the creation of environments that have one optional argument. Thus the syntax of these two commands has been extended in the same way as that of | |.
#decl279#
This takes the same arguments as | |. If <#285#>cmd<#285#> is already defined then the existing definition is kept; but if it is currently undefined then the effect of |is to define <#286#>cmd<#286#> just as if | | had been used.