# [texhax] \protect in LaTeX2e

Robert Hunt reh10 at cam.ac.uk
Mon Oct 4 17:54:50 CEST 2004

Morten Høgholm wrote:
>
> On Fri, 01 Oct 2004 17:51:03 +0100 (BST), Robert Hunt
> <R.E.Hunt at damtp.cam.ac.uk> wrote:
>
> > In section 2.6 of Kopka & Daly's book, they state that "The issue of
> > fragile commands ... with LaTeX2e has become of academic interest: all
> > commands that are likely to be used in moving arguments are now robust." I
> > recently discovered that this isn't true: \nolinebreak is not robust an.
> >
> > \caption{Blah blah ... blah\nolinebreak\ blah blah blah}
> >
> > fails rather dismally. This can of course be avoided with \protect, but
>
> I'd say it is not worth the trouble because the effect is easier to get
> with \nobreakspace or its shorthand ~ because \nobreakspace happens to be
> robust. Unless you want to use the optionl argument of \nolinebreak of
> course.

The situation in which this arose was in fact an equation: e.g. \$0 <
\nolinebreak x < 1\$. Using \nobreakspace is therefore not an option,
unfortunately. Using DeclareRobustCommand, or just using \protect as a
one-off, is OK; but it would be nicer for \nolinebreak to be robust in
the first place, because nowadays people don't expect to have to deal
with fragile commands. The error messages which result from the
\nolinebreak problem are not very informative, of course, so it takes a
while to track the problem down!