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.
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityIf 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}
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.
\toprule[1mm]
for example(lr)
thing does to\cmidrule(lr)
.2\tabcolsep
) that is usually inserted between columns is also inserted before and after the first and the last column (but only one\tabcolsep
).)