UK TeX FAQ -- question label oarglikesect

### Optional arguments like `\``section`

Optional arguments, in macros defined using `\``newcommand`, don't quite work like the optional argument to `\``section`. The default value of `\``section`'s optional argument is the value of the mandatory argument, but `\``newcommand` requires that you 'know' the value of the default beforehand.

The requisite trick is to use a macro in the optional argument:

    \newcommand\thing[2][\DefaultOpt]{\def\DefaultOpt{#2} ...}

This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=oarglikesect