summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-extrabrace.html
blob: 1f68cf4bd7411f59deaeb22ccd3bccac017b76ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<head>
<title>UK TeX FAQ -- question label extrabrace</title>
</head><body>
<h3>An extra &lsquo;<code>}</code>&rsquo;??</h3>
<!-- caption heading -->
<p/>You&rsquo;ve looked at your LaTeX source and there&rsquo;s no sign of a misplaced
<code>}</code> on the line in question.
<p/>Well, no: this is TeX&rsquo;s cryptic way of hinting that you&rsquo;ve put a
<a href="FAQ-protect.html">fragile command</a> in a moving argument.

<p/>For example, <code>\</code><code>footnote</code> is fragile, and if we put that in the
moving argument of a <code>\</code><code>section</code> command, as
<blockquote>

<pre>
\section{Mumble\footnote{I couldn't think of anything better}}
</pre>
</blockquote><p>
we get told
<blockquote>
<pre>
! Argument of \@sect has an extra }.
</pre>
</blockquote><p>
The same happens with captions (the following is a simplification of a
<i>comp.text.tex</i> post):
<blockquote>
<pre>
\caption{Energy: \[e=mc^2\]}
</pre>
</blockquote><p>
giving us the error message
<blockquote>
<pre>
! Argument of \@caption has an extra }.
</pre>
</blockquote><p>
The solution is usually to use a robust command in place of the one
you are using, or to force your command to be robust by prefixing it
with <code>\</code><code>protect</code>, which in the <code>\</code><code>section</code> case would show as
<blockquote>

<pre>
\section{Mumble\protect\footnote{I couldn't think of anything better}}
</pre>
</blockquote><p>
In both the <code>\</code><code>section</code> case and the <code>\</code><code>caption</code> case, you can
separate the moving argument, as in
<code>\</code><code>section[</code><em>moving</em><code>]{</code><em>static</em><code>}</code>; this gives us another standard
route &mdash; simply to omit (or otherwise sanitise) the fragile command
in the moving argument.  So, one might rewrite the <code>\</code><code>caption</code>
example as:
<blockquote>

<pre>
\caption[Energy:  $E=mc^2$]{Energy: \[E=mc^2\]}
</pre>
</blockquote><p>
for, after all, even if you want display maths in a caption, you
surely don&rsquo;t want it in the list of figures.
<p/>The case of footnotes is somewhat more complex;
&ldquo;<a href="FAQ-ftnsect.html">footnotes in LaTeX section headings</a>&rdquo;
deals specifically with that issue.
<p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=extrabrace">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=extrabrace</a>
</body>