# [texhax] \protect in LaTeX2e

Morten Høgholm moho01ab at student.cbs.dk
Sat Oct 2 15:47:36 CEST 2004

```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 and
>
> \caption{Blah blah ... blah\nolinebreak\ blah blah blah}
>
> fails rather dismally. This can of course be avoided with \protect, but
> should \nolinebreak be instead made robust?

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.

If you still want to make it robust, simply(?) add

\makeatletter
\DeclareRobustCommand*\nolinebreak{\@testopt\@no at lnbk4}
\makeatother

to your preamble. It takes up an extra command name (robust commands make
a secret command that does the real typesetting) but that doesn't matter