7

I was reading in latex2e about the use of \protect. In section 13.8 it mentions "expressions in tabular and array enviornments" as examples of moving arguments. I was a bit surprised by this. Could someone clarify what's meant here? Or, why that's the case?

I tried experimenting, such as

\documentclass{article}
\usepackage{etoolbox}

\makeatletter

\newcommand\ae@suchthat{\mid}
\newcommand\set[1]{%%
  \begingroup
    \let\suchthat\ae@suchthat
      \{\,#1\,\}%%
  \endgroup
}

\makeatother

\begin{document}

\begin{tabular}{lc}
This & $\set{x\in X \suchthat x>42}$
\end{tabular}

\end{document}

But there doesn't seem to be a problem here. What am I misunderstanding about fragile vs robust?

1

1 Answer 1

5

The manual should mention “@-expressions in tabular and array”, to be consistent with the official manual by Leslie Lamport. Here's an example:

\documentclass{article}
\usepackage{graphicx}
\begin{document}

\begin{tabular}{l@{ \resizebox{2mm}{!}{$x$} }l}
A & B \\
C & D
\end{tabular}
\end{document}

will end up with a typical error message due to fragile commands in moving arguments:

! Use of \@array doesn't match its definition.
\@ifnextchar ... \reserved@d =#1\def \reserved@a {
                                                  #2}\def \reserved@b {#3}\f...
l.5 ...in{tabular}{l@{ \resizebox{2mm}{!}{$x$} }l}

If we use \protect\resizebox we get no error.

Quoting from “LaTeX, A Document Preparation System”, page 168:

C.1.3 Fragile commands

Commands are classified as either robust and fragile. [...] The following are all the commands and environments with moving arguments:

  • [...]

  • An @ in array or tabular environment. (Although @ is not a command, fragile commands in an @-expression must be \protect'ed as if they were in a moving argument.)

2
  • The manual I got is what popped up when I called texdoc latex2e from the command line. Which manual are you referring to? I can't seem to find it
    – A.Ellett
    Commented May 3, 2015 at 21:58
  • @A.Ellett It's the official manual by L. Lamport: “LaTeX, A Document Preparation System”. OK, the unofficial manual misses @ in front of “expressions” (it uses it in section 9.24).
    – egreg
    Commented May 3, 2015 at 22:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .