6

The \cmidrule in booktabs package has trim option to specify how much to trim from left or right. However from the following example \cmidrule(l{2pt}r{2pt}){1-2} shows the line is shifted, not shortened; I may be confused about the this trim option, but I expected 2 points from left and right should be removed (trimmed).

The next code \cmidrule(l{2pt}r{2pt}){3-3} is even more confusing to show that the line is shifted to the left.

How to interpret the trim option with \cmdrule?

enter image description here

\documentclass[12pt]{article}
\usepackage{booktabs}

\begin{document}
\begin{tabular}{@{}llr@{}}
\toprule
    \multicolumn{2}{c}{Item} &\multicolumn{1}{c}{Price/lb} \\
\cmidrule(r){1-2}\cmidrule(l){3-3}
    a & b & c \\
\cmidrule(l{2pt}r{2pt}){1-2}\cmidrule(l{2pt}r{2pt}){3-3}
\morecmidrules
\cmidrule(l{2pt}r{2pt}){2-3}
\addlinespace[5pt]
    Food& Category & \multicolumn{1}{c}{\$}\\
\midrule
    Apples & Fruit  & 1.50 \\
    Oranges & Fruit & 2.00 \\
\addlinespace
    Beef & Meat     & 4.50 \\
\specialrule{.5pt}{3pt}{3pt}
    x & y & z \\
\bottomrule
\end{tabular}

\end{document}
  • I don't know whether my answer answers your question. I think you're confused by the look of the \cmidrules since you're not using a \tabcolsep on the outer edges of the first/last column. That is, you're using @{} to suppress it. – Werner Oct 31 '16 at 16:44
3

Your interpretation of the trim option is correct. What seems confusion here is the fact that removed the column space on the outer edges of your tabular.

When considering the tabular version without the end \tabcolsep removed

\begin{tabular}{ l l r }

enter image description here

the adjustments for \cmidrule using the left and right trim options seem more in line with what one would expect.


The default trim, if not specified explicitly is \cmidrulekern which is set to .5em. This equates to 5pt under the 10pt (default) document class option, 5.475pt under 11pt and 5.87494pt under 12pt. Perhaps, instead of specifying trims in absolute values, is a font-related width like em.

1

Without any parameters, the default value for the trim seems to be larger than 2pt to cause the confusion.

When I changed the code not to have any trimming with the following code, I can get the expected trimmed result.

\cmidrule(l{0pt}r{0pt}){1-2}\cmidrule(l{0pt}r{0pt}){3-3}

enter image description here

  • 1
    Yes, the default trim value is \cmidrulekern which is set to .5em. You can just use \cmidrule{1-3} instead of specifying a 0pt trim on all sides. – Werner Oct 31 '16 at 17:16
  • If this is "the answer to your question", I don't understand how it relates to your question. – Werner Oct 31 '16 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.