I have several tables that are automatically outputted by a statistical package, with \cline
commands for groups of column headers. I'm including these tables using \input
in a larger document, and I'd like to convert all of the \cline
calls to the more attractive \cmidrule
. Obviously I can manually change them, but this will get tedious if I have to re-generate the tables.
I've tried \renewcommand{\cline}[1]{\cmidrule(lr){#1}}
, but this does something strange.
\documentclass{article}
\usepackage{booktabs}
\renewcommand{\cline}[1]{\cmidrule{#1}}
\begin{document}
\begin{table}[!tbp]
{\centering
\begin{tabular}{lrrcrrcrr}
\toprule
\multicolumn{1}{l}{\bfseries }&\multicolumn{2}{c}{\bfseries Group1}&\multicolumn{1}{c}{\bfseries }&\multicolumn{2}{c}{\bfseries Group 2}&\multicolumn{1}{c}{\bfseries }&\multicolumn{2}{c}{\bfseries Group 3}\tabularnewline
\cline{2-3} \cline{5-6} \cline{8-9}
\multicolumn{1}{l}{}&\multicolumn{1}{c}{Name}&\multicolumn{1}{c}{Name}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{Name}&\multicolumn{1}{c}{Name (\$)}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{Name}&\multicolumn{1}{c}{Name (\$)}\tabularnewline
\midrule
\bottomrule
\end{tabular}}
\end{table}
\end{document}
I'll note that creating the extra empty columns to give space between the clines is an artifact of the stats package, which I unfortunately can't avoid without a lot more work.
Best Answer
The commands look ahead to check for a following command on the same row so you need something with the "expected" definition of
\cmidrule
. Using\let
works here.