[Tex/LaTex] \cmidrule’s trim option

booktabstables

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}

Best Answer

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.

Related Question