Definitions

In LaTeX, commands can have both mandatory and optional arguments, for example in: verbatim12 the 116 argument is optional, whereas the 117 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.

118 {<<#232#>cmd<#232#>>} [<<#233#>num<#233#>>] [<<#234#>default<#234#>>] {<<#235#>definition<#235#>>}
119 {<<#236#>cmd<#236#>>} [<<#237#>num<#237#>>] [<<#238#>default<#238#>>] {<<#239#>definition<#239#>>}

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: verbatim13 This defines 120 to be a command with two arguments, referred to as 121 and 122 in the {<<#241#>definition<#241#>>}---nothing new so far. But by adding a second optional argument to this 123 (the 124) the first argument (125) of the newly defined command 126 is made optional with its default value being 127. Thus the usage of 128 is either: verbatim14 which prints:

Mandatory arg: BBB; Optional arg: YYY.
or: verbatim15 which prints:
Mandatory arg: AAA; Optional arg: XXX.
The default value of the optional argument is <#246#>YYY<#246#>. This value is specified as the [<<#247#>default<#247#>>] argument of the 129 that created 130. As another more useful example, the definition: verbatim16 means that the input 131 produces the formula #tex2html_wrap_inline980#, whereas the input 132 produces the formula #tex2html_wrap_inline982#. In summary, the command:
133 {<<#253#>cmd<#253#>>} [<<#254#>num<#254#>>] [<<#255#>default<#255#>>] {<<#256#>definition<#256#>>}
defines <<#258#>cmd<#258#>> to be a command with <<#259#>num<#259#>> arguments, the first of which is optional and has default value <<#260#>default<#260#>>. Note that there can only be one optional argument but, as before, there can be up to nine arguments in total.

134 {<<#262#>cmd<#262#>>} [<<#263#>num<#263#>>] [<<#264#>default<#264#>>] {<<#265#>beg-def<#265#>>} {<<#266#>end-def<#266#>>}
135 {<<#267#>cmd<#267#>>} [<<#268#>num<#268#>>] [<<#269#>default<#269#>>] {<<#270#>beg-def<#270#>>} {<<#271#>end-def<#271#>>}

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 136.


137 {<<#274#>cmd<#274#>>} [<<#275#>num<#275#>>] [<<#276#>default<#276#>>] {<<#277#>definition<#277#>>}

This takes the same arguments as 138. If <<#279#>cmd<#279#>> is already defined then the existing definition is kept; but if it is currently undefined then the effect of 139 is to define <<#280#>cmd<#280#>> just as if 140 had been used. All the above five `defining commands' now have <#282#>*<#282#>-forms that are usually the better form to use when defining commands with arguments, unless any of these arguments is intended to contain whole paragraphs of text. Moreover, if you ever do find yourself needing to use the non-star form then you should ask whether that argument would not better be treated as the contents of a suitably defined environment. The commands produced by the above five `defining commands' are now robust.