# “Undefined control sequence” on left parenthesis after midrule in longtable

With this file:

\documentclass{article}
\usepackage{longtable}
\usepackage{booktabs}
\begin{document}
{
\begin{longtable}{p{.3\textwidth}p{.5\textwidth}}
\midrule
label & value \\
\midrule
(2) label & value \\
\midrule
\end{longtable}
}
\end{document}


running pdflatex, I get:

! Undefined control sequence.
<argument> ...al \expandafter \let \cmrsideswitch
\@tempa \fi \fi
l.10 (2)
label & value \\


There seems to be something about the midrule that makes a left parenthesis invalid. But with tabular instead of longtable, there is no such problem.

You are running into the same problem as in "[" as first character in table row.

booktabs defines the rules to take an optional argument in the form [..] or (..). The use of (2) on the row immediately following \midrule is being interpreted as an optional argument, yet it doesn't match the definition that's expected with that type of optional argument.

To avoid this, use

\midrule\relax


\documentclass{article}
\usepackage{longtable,booktabs}
\begin{document}
\begin{longtable}{p{.3\textwidth}p{.5\textwidth}}
\midrule
label & value \\
\midrule\relax
(2) label & value \\
\midrule
\end{longtable}
\end{document}

• relax isn't needed with tabular, just longtable; that's the confusing part – ysth Feb 18 '15 at 5:12
• @ysth: This may stem from the fact that longtable does some calculation in order to estimate page breaks. tabular doesn't do that. – Werner Feb 18 '15 at 5:16
• @ysth -- booktabs does things slightly differently if longtable is loaded (i.e., it tests for ( with \@ifnextchar). – jon Feb 18 '15 at 5:18
• ah, it is documented: "There is an addition worth noting: within a longtable, you can use the optional left and right trimming commands, which normally only work for \cmidrules, with \toprule, \midrule and \bottomrule (and if you must, also with \specialrule)." – ysth Feb 18 '15 at 6:14
• It probably would make sense that, in this case, the non space skipping \@ifnextchar used by amsmath is used. – egreg Feb 18 '15 at 9:11