File: FAQ-oarglikesect.html

package info (click to toggle)
texlive-doc 2005.dfsg.2-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 125,100 kB
  • ctags: 12,558
  • sloc: xml: 24,267; perl: 14,394; makefile: 727; sh: 324; lisp: 276; java: 159; sed: 4
file content (16 lines) | stat: -rw-r--r-- 850 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<head>
<title>UK TeX FAQ -- question label oarglikesect</title>
</head><body>
<h3>Optional arguments like <code>\</code><code>section</code></h3>
<p>Optional arguments, in macros defined using <code>\</code><code>newcommand</code>, don't
quite work like the optional argument to <code>\</code><code>section</code>.  The default
value of <code>\</code><code>section</code>'s optional argument is the value of the
mandatory argument, but <code>\</code><code>newcommand</code> requires that you 'know' the
value of the default beforehand.
<p>The requisite trick is to use a macro in the optional argument:
<pre>
\newcommand\thing[2][\DefaultOpt]{\def\DefaultOpt{#2} ...}
</pre>

<p><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=oarglikesect">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=oarglikesect</a>
</body>