6

How to trim \toprule (from booktabs package)?

It is probably something basic I'm missing, but I need it and it's nowhere to be found.

4
  • By trimming you mean making it thinner or the spacing after it?
    – percusse
    Mar 22, 2013 at 20:37
  • \toprule[1mm] for example
    – user2478
    Mar 22, 2013 at 20:41
  • The latter -- want to make it shorter so that it begins and ends with the table contents, i.e. similar thing as the (lr) thing does to \cmidrule(lr). Mar 22, 2013 at 20:53
  • Related: booktabs and tiny horizontal space. (The horizontal space (2\tabcolsep) that is usually inserted between columns is also inserted before and after the first and the last column (but only one \tabcolsep).) Mar 23, 2013 at 3:27

1 Answer 1

11

If I understand your objective correctly, you want the lines generated by \toprule -- and by \midrule and \bottomrule too, right? -- start at the left-hand edge and end at the right-hand edge of the contents of the table.

To achieve this objective, you could specify @{} as the first and last items in the argument of a tabular, tabular*, tabularx, etc. environment:

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\noindent
\begin{tabular}{ @{} lccr @{} } % @{} suppresses the whitespace in the corresponding position
\toprule
long story & about & absolutely & nothing \\
\midrule
aa & bb & cc & dd\\
\multicolumn{2}{@{}l}{First thoughts \dots }\\     % note the @{} item before "l"
& & \multicolumn{2}{r@{}}{\dots Final thoughts}\\  % note the @{} item after "r"
\bottomrule
\end{tabular}
\end{document}

enter image description here

The MWE also illustrates that if your table has \multicolumn directives that encompass the first or final columns of the table, you'll again need to supply @{} items, as appropriate, this time in the second argument of the \multicolumn command.

By the way, I believe that suppressing the whitespace at the far left and far right edges of a table is something that the author of the booktabs package recommends doing; see, e.g., the tabular environment at the top of page 5 of the package's user guide; the output of that code is shown on p. 2 of the guide.

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