3

I'm trying to create a table using booktabs, but for some reason I get extra whitespace between my last two columns.

\documentclass{article}

\usepackage{booktabs}
\begin{document}

\begin{table}\centering
\begin{tabular}{@{} c c c @{}} \toprule
\multicolumn{3}{c}{coordinates space filler}\\
\cmidrule{1-3}
x & y & z \\
\midrule
a & 0 & 0  \\
b & 0 & 0  \\
c & 0 & 0  \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

And this produces a large white space between the y-column and the z-column. The larger I make the 'coordinates space filler' the worse it becomes. But the distance between my x and y column is always okay.

Thanks in advance!

2

Your tabular without the coordinates space filler is not wide enough. I suggest using a fixed-width column for all columns to stretch things out far enough:

enter image description here

\documentclass{article}

\usepackage{booktabs}
\usepackage{array}
\newcolumntype{C}{>{\centering\arraybackslash}p{3em}}
\begin{document}

\begin{tabular}{@{} C C C @{}}
  \toprule
  \multicolumn{3}{c}{coordinates space filler} \\
  \cmidrule{1-3}
  x & y & z \\
  \midrule
  a & 0 & 0  \\
  b & 0 & 0  \\
  c & 0 & 0  \\
  \bottomrule
\end{tabular}
\end{document}
1

If a spanning cell is wider than the columns it spans all the extra space goes into the last column.

You can hide the width with

\multicolumn{3}{c}{\makebox[0pt]{coordinates space filler}}\\

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.