2

How can I change thickness of \cmidrule because I need it in my report.

2
  • 2
    You can set the optional argument like \cmidrule[5pt]{1-2} which would print a line that is 5pt thick. This information can be found in the booktabs package manual. Commented Mar 14, 2023 at 22:55
  • 3
    Default width is \cmidrulewidth.
    – Werner
    Commented Mar 14, 2023 at 22:57

2 Answers 2

6

The \cmidrule macro (which is defined by the booktabs package) can take an optional argument which you can use to define the line thickness explicitly. For example, using \cmidrule[5pt]{1-2}, you would get a line that is 5pt thick and spans over the first two columns. The thickness of \toprule, \bottomrule and \midrule can be adjusted in a similar way using the relevant optional argument.

Another way to set the thickness of \cmidrule would be do set the length for \cmidrulewidth which holds the default value for the thickness of any \cmidrule (thanks to Werner for pointing to this). Setting the default length might be a good idea if you want to redefine the thickness in more than one tabular. The thickness of \toprule and \bottomrule is defined by \heavyrulewidth, while the thickness of \midrule is defined by \lightrulewidth.

Compare the following (totally unaesthetic) modified example taken from the package manual:

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{tabular}{@{}llr@{}} \toprule[10pt]
\multicolumn{2}{c}{Item} \\ \cmidrule[5pt](r){1-2}
Animal & Description & Price (\$)\\ \midrule[15pt]
Gnat & per gram & 13.65 \\
& each & 0.01 \\
Gnu & stuffed & 92.50 \\
Emu & stuffed & 33.33 \\
Armadillo & frozen & 8.99 \\ \bottomrule[20pt]
\end{tabular}

\bigskip

\setlength{\lightrulewidth}{15pt}
\setlength{\heavyrulewidth}{20pt}
\setlength{\cmidrulewidth}{5pt}

\begin{tabular}{@{}llr@{}} \toprule
\multicolumn{2}{c}{Item} \\ \cmidrule(r){1-2}
Animal & Description & Price (\$)\\ \midrule
Gnat & per gram & 13.65 \\
& each & 0.01 \\
Gnu & stuffed & 92.50 \\
Emu & stuffed & 33.33 \\
Armadillo & frozen & 8.99 \\ \bottomrule
\end{tabular}

\end{document}

enter image description here

3

Using the booktabs package:

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{table}[htbp]
\centering
\begin{tabular}{ccc}
\toprule
One  & Two  & Three  \\
\midrule[\heavyrulewidth] % thick rule using booktabs package
One  & Two  & Three  \\
\cmidrule[4pt](r){1-2} % custom thickness of 1pt, trimming on the right side
One  & Two  & Three  \\
\bottomrule
\end{tabular}
\caption{Example Table}
\label{tab:example}
\end{table}

\end{document}

enter image description here

1
  • 1
    colortbl is not used at all here other than making the rule blue, which wasn't requested Commented Mar 14, 2023 at 23:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .