[latexrefman-commits] r350 - in /trunk: ChangeLog latex2e.texi

jhefferon at domain.hid jhefferon at domain.hid
Wed Jun 3 03:00:53 CEST 2015


Author: jhefferon
Date: Wed Jun  3 03:00:52 2015
New Revision: 350

URL: http://svn.gna.org/viewcvs/latexrefman?rev=350&view=rev
Log:
expand on \protect

Modified:
    trunk/ChangeLog
    trunk/latex2e.texi

Modified: trunk/ChangeLog
URL: http://svn.gna.org/viewcvs/latexrefman/trunk/ChangeLog?rev=350&r1=349&r2=350&view=diff
==============================================================================
--- trunk/ChangeLog	(original)
+++ trunk/ChangeLog	Wed Jun  3 03:00:52 2015
@@ -1,7 +1,11 @@
+2015-06-02  Jim Hefferon  <jhefferon at domain.hid>
+
+	* latex2e.texi (\protect): Expand description, add examples.
+
 2015-05-30  Jim Hefferon  <jhefferon at domain.hid>
 
 	* latex2e.texi (\newlength): Add details, including that the name
-	nust begin with a backslash.
+	must begin with a backslash.
 
 2015-05-29  Jim Hefferon  <jhefferon at domain.hid>
 

Modified: trunk/latex2e.texi
URL: http://svn.gna.org/viewcvs/latexrefman/trunk/latex2e.texi?rev=350&r1=349&r2=350&view=diff
==============================================================================
--- trunk/latex2e.texi	(original)
+++ trunk/latex2e.texi	Wed Jun  3 03:00:52 2015
@@ -2,7 +2,7 @@
 @c $Id$
 @comment %**start of header (This is for running Texinfo on a region.)
 @setfilename latex2e.info
- at domain.hid UPDATED May 2015
+ at set UPDATED June 2015
 @settitle @LaTeX{}2e unofficial reference manual (@value{UPDATED})
 @comment %**end of header (This is for running Texinfo on a region.)
 
@@ -3699,15 +3699,15 @@
 @c xx everything in this chapter needs examples.
 
 @menu
-* \newcommand & \renewcommand::         (Re)define a new command.
-* \providecommand::                     Define a new command, if name not used.
-* \newcounter::                         Define a new counter.
-* \newlength::                          Define a new length.
-* \newsavebox::                         Define a new box.
-* \newenvironment & \renewenvironment:: Define a new environment.
-* \newtheorem::                         Define a new @code{theorem}-like environment.
-* \newfont::                            Define a new font name.
-* \protect::                            Using tricky commands.
+* \newcommand & \renewcommand::           (Re)define a new command.
+* \providecommand::                       Define a new command, if name not used.
+* \newcounter::                           Define a new counter.
+* \newlength::                            Define a new length.
+* \newsavebox::                           Define a new box.
+* \newenvironment & \renewenvironment::   Define a new environment.
+* \newtheorem::                           Define a new @code{theorem}-like environment.
+* \newfont::                              Define a new font name.
+* \protect::                              Using tricky commands.
 @end menu
 
 
@@ -4091,30 +4091,65 @@
 @findex \protect
 
 @cindex fragile commands
+ at cindex robust commands
 @cindex moving arguments
+
+All @LaTeX{} commands are either @dfn{fragile} or @dfn{robust}.
 Footnotes, line breaks, any command that has an optional argument, and
-many more are so-called @dfn{fragile} commands.  When a fragile
-command is used in certain contexts, called @dfn{moving arguments}, it
-must be preceded by @code{\protect}.  In addition, any fragile
-commands within the arguments must have their own @code{\protect}.
-
-Some examples of moving arguments are @code{\caption}
-(@pxref{figure}), @code{\thanks} (@pxref{\maketitle}), and
- at domain.hid in @code{tabular} and @code{array} environments
-(@pxref{tabular}).
-
- at domain.hid robust commands
-Commands which are not fragile are called @dfn{robust}.  They must not
-be preceded by @code{\protect}.
+many more, are fragile.  A fragile command can break when it is used in
+the argument to certain commands.  To prevent such commands from
+breaking they must be preceeded by the command @code{\protect}.
+
+For example, when @LaTeX{} runs the @code{\section at domain.hid
+name}@}} command it writes the @var{section name} text to the
+ at file{.dvi} auxillary file, moving it there for use elsewhere in the
+document such as in the table of contents.  Any argument that is
+internally expanded by @LaTeX{} without typesetting it directly is
+referred to as a @dfn{moving argument}.  A command is fragile if it can
+expand during this process into invalid @TeX{} code.  Some examples of
+moving arguments are those that appear in the @code{\caption@{..@}}
+command (@pxref{figure}), in the @code{\thanks@{..@}} command
+(@pxref{\maketitle}), and in @@-expressions in the @code{tabular} and
+ at code{array} environments (@pxref{tabular}).
+
+If you get strange errors from commands used in moving arguments, try
+proceding it with @code{\protect}.  Every fragile commands must be
+protected with their own @code{\protect}.  Typically, a @code{\protect}
+command won't hurt, so it is worth a try.
+
+ at c xx True? Length commands are robust and should not be preceded by a \protect command. Nor should a \protect command be used in the argument to \addtocounter or \setcounter command.
+
+In this example the @code{caption} command gives a mysterious error
+about an extra curly brace.  Fix the problem by preceeding each
+ at code{\raisebox} command with @code{\protect}.
+
+ at example
+\begin at domain.hid@}
+  ..
+  \caption at domain.hid headquarters of A\raisebox at domain.hid@}@}
+\end at domain.hid@}
+ at end example
+
+In the next example the @code{\tableofcontents} command gives an error
+because the @code{\(..\)} in the section title expands to illegal @TeX{}
+in the @file{.toc} file.  Solve this by changing @code{\(..\)} to
+ at code{\protect\(..\protect\)}.
+
+ at example
+\begin at domain.hid@}
+\tableofcontents
+ ..
+\section at domain.hid \( e=mc^2 \)@}
+ ..
+ at end example
 
 See also:
 
 @smallexample
- at domain.hid @url{http://www-h.eng.cam.ac.uk/help/tpl/textprocessing/teTeX/latex/latex2e-html/fragile.html}
 @exdent @url{http://www.tex.ac.uk/cgi-bin/texfaq2html?label=protect}
 @end smallexample
 
- at domain.hid xx really need examples.
+
 
 
 @node Counters





More information about the latexrefman-commits mailing list