[Tex/LaTex] Fragile commands in 2021

fragilemacros

Since 2015, \( \), \begin{math} etc. have been made robust. Aside from user-generated commands not created with \DeclareRobustCommand and out-of-date packages, are fragile commands still a thing in LaTeX these days? In other words, can I delete that section from my book for LaTeX users (not programmers)? (Discussing this in a later book for people programming LaTeX is a whole other thing.)

Best Answer

Well not completely gone, but you have to try a lot harder to find a case, and if it's a really plausible case quite possibly we'd accept an enhancement request to make the command robust.

For example \begin has been robust (only since 2019, not 2015) so \begin{tabular} is robust, as is \\ (from 2015) but \cline is not, compare these two \typeout

\documentclass{article}

\begin{document}

\typeout{
  \begin{tabular}{cc}
    a&b\\
    \cline{1-1}
   c&d
  \end{tabular}}

\typeout{
  \begin{tabular}{cc}
    a&b\\
    \protect\cline{1-1}
   c&d
  \end{tabular}}

\end{document}

producing

 \begin {tabular}{cc} a&b\\ \omit \@multicnt 1\advance \@multicnt \m@ne \relax 
\def \iterate {}\iterate \let \iterate \relax \@multicnt 1\advance \@multicnt -
1\advance \@multicnt \@ne \relax \def \iterate {}\iterate \let \iterate \relax 
\leaders \hrule height\arrayrulewidth \hfill \cr \noalign {\vskip -\arrayrulewi
dth } c&d \end {tabular}

and

 \begin {tabular}{cc} a&b\\ \cline{1-1} c&d \end {tabular}

Of course \typeout here could be replaced by any command with moving argument such as caption or section hesdings.

Related Question