summaryrefslogtreecommitdiff
path: root/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-protect.html
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-doc/doc/english/FAQ-en/html/FAQ-protect.html')
-rw-r--r--Master/texmf-doc/doc/english/FAQ-en/html/FAQ-protect.html62
1 files changed, 48 insertions, 14 deletions
diff --git a/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-protect.html b/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-protect.html
index 710c346f896..dd0389f9118 100644
--- a/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-protect.html
+++ b/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-protect.html
@@ -4,15 +4,13 @@
<h3>What&rsquo;s the reason for &lsquo;protection&rsquo;?</h3>
<p/>Sometimes LaTeX saves data it will reread later. These data are
often the argument of some command; they are the so-called moving
-arguments. (&lsquo;Moving&rsquo; because data are moved around.) Places to look for
+arguments. (&lsquo;Moving&rsquo; because data are moved around.) Candidates
are all arguments that may go into table of contents, list of figures,
<em>etc</em>.; namely, data that are written to an auxiliary file and
read in later. Other places are those data that might appear in head-
or footlines. Section headings and figure captions are the most
prominent examples; there&rsquo;s a complete list in Lamport&rsquo;s book
(see <a href="FAQ-books.html">TeX-related books</a>).
-<p/>
-
<p/>What&rsquo;s going on really, behind the scenes? The commands in moving
arguments are normally expanded to their internal structure during the
process of saving. Sometimes this expansion results in invalid TeX
@@ -26,26 +24,62 @@ illegal TeX code during the save process.
TeX code during the save process.
<p/>Lamport&rsquo;s book says in its description of every LaTeX command whether
it is &lsquo;robust&rsquo; or &lsquo;fragile&rsquo;; it also says that every command with an
-optional argument is fragile. These lists aren&rsquo;t as reliable as the
-list of moving arguments; the statements may have been true in
-early versions of LaTeX2e but are not any longer necessarily so:
+optional argument is fragile. The list isn&rsquo;t reliable, and neither
+is the assertion about optional arguments; the statements may have
+been true in early versions of LaTeX2e but are not any longer
+necessarily so:
<ul>
<li> Some fragile commands, such as <code>\</code><code>cite</code>, have been made robust
in later revisions of LaTeX.
-<li> Some robust commands are redefined by certain packages to be
- fragile (the <code>\</code><code>cite</code> command commonly suffers this treatment).
<li> Some commands, such as <code>\</code><code>end</code> and <code>\</code><code>nocite</code>, are fragile
even though they have no optional arguments.
<li> The &ldquo;user&rsquo;s way&rdquo; of creating a command with an optional
- argument (using <code>\</code><code>newcommand</code>) now always creates a robust
- command. There is no reason that a package author should not also
- make robust commands with optional arguments as part of the
- package.
+ argument (using <code>\</code><code>newcommand</code> or <code>\</code><code>newcommand*</code>) now always
+ creates a robust command (though macros without optional arguments
+ may still be fragile if they do things that are themselves fragile).
+<li> There is no reason that a package author should not also make
+ robust commands with optional arguments as part of the package.
+<li> Some robust commands are redefined by certain packages to be
+ fragile (the <code>\</code><code>cite</code> command commonly suffers this treatment).
</ul>
-In short, the situation is confusing. No-one believes this is
-satisfactory, and the LaTeX team have removed the need for
+Further, simply &ldquo;hiding&rdquo; a fragile command in another command, has
+no effect on fragility. So, if <code>\</code><code>fred</code> is fragile, and you write:
+<blockquote>
+<pre>
+\newcommand{\jim}{\fred}
+</pre>
+</blockquote><p>
+then <code>\</code><code>jim</code> is fragile too. There is, however, the
+<code>\</code><code>newcommand</code>-replacement <code>\</code><code>DeclareRobustCommand</code>, which
+<em>always</em> creates a robust command (whether or not it has optional
+arguments). The syntax of <code>\</code><code>DeclareRobustCommand</code> is substantially
+identical to that of <code>\</code><code>newcommand</code>, and if you do the wrapping
+trick above as:
+<blockquote>
+<pre>
+\DeclareRobustCommand{\jim}{\fred}
+</pre>
+</blockquote><p>
+then <code>\</code><code>jim</code> is robust.
+<p/>Finally, we have the <i>makerobust</i> package, which defines
+<code>\</code><code>MakeRobustCommand</code> to convert a command to be robust. With the
+package, the &ldquo;wrapping&rdquo; above can simply be replaced by:
+<blockquote>
+<pre>
+\MakeRobustCommand\fred
+</pre>
+</blockquote><p>
+Whereafter, <code>\</code><code>fred</code> is robust. Using the package may be reasonable
+if you have lots of fragile commands that you need to use in moving
+arguments.
+<p/>In short, the situation is confusing. No-one believes this is
+satisfactory; the LaTeX team have removed the need for
protection of some things, but the techniques available in
current LaTeX mean that this is an expensive exercise. It remains
a long-term aim of the team to remove all need for <code>\</code><code>protect</code>ion.
+<dl>
+<dt><tt><i>makerobust.sty</i></tt><dd>Distributed with Heiko Oberdiek&rsquo;s packages
+ <a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/oberdiek.zip">macros/latex/contrib/oberdiek</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/oberdiek.tar.gz">gzipped tar</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/oberdiek/">browse</a>)
+</dl>
<p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=protect">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=protect</a>
</body>