4

I'm doing a table with booktabs:

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

  \newcommand{\crI}[2]{\cmidrule(#1){#2}}

  \begin{tabular}{@{}lllll@{}}
    \toprule
    \multicolumn{1}{c}{} & a & b & c & d  \\ 
    %\cmidrule(lr){2-2} \cmidrule(lr){3-3} \cmidrule(lr){4-4} \cmidrule(l){5-5} 
    %     \crI{lr}{2-2}      \crI{lr}{3-3}      \crI{lr}{4-4}      \crI{l}{5-5}     
    q1   & 1 & 2 & 3 & 4   \\ 
    q2   & 1 & 2 & 3 & 4   \\ 

    \bottomrule
  \end{tabular}

\end{document}

I made a shortcut \crI for the underrules \cmidrule, but they result in a staircase. With the upper line commented out, I get:

enter image description here

With the lower line, however, I get:

enter image description here

David Carlisle
  • 757,742
user2740
  • 493
  • 2
  • 9
  • 4
    cmidrule looks ahead to see a following cmidrule to put them on the same line, the shortcut defeats that. You could duplicate the definition and make it look ahead for cRI but unless you are doing lots of these, that will probably take more characters than you save using the shortcut – David Carlisle Oct 03 '14 at 13:49
  • @DavidCarlisle Thanks, that answers my question completely. Make it an answer and I'll accept it. – user2740 Oct 03 '14 at 15:33

1 Answers1

5

\cmidrule looks ahead to see a following \cmidrule to put them on the same line, the shortcut defeats that. You could duplicate the definition and make it look ahead for \cRI but unless you are doing lots of these, that will probably take more characters than you save using the shortcut

David Carlisle
  • 757,742