4

I'm experiencing a weird issue with a simple table with a multicolumn. If the title of the multicolumn is short enough, the three subcolumns are correctly aligned, otherwise, they get strangely arranged.

Here's the code and the results. Thanks in advance!

\documentclass[a4paper,11pt]{book}
\usepackage{caption,booktabs,multirow}
\begin{document}
\begin{table}[!h]
\centering
\begin{tabular}{ccccccc}
    \toprule
    \toprule
    \multirow{2}*{\textbf{Layer}} & \textbf{Radius} & \multirow{2}*{\#\textbf{Ladders}} & \multicolumn{3}{c}{\textbf{Sensors}} & \multirow{2}*{\textbf{APV25/Sensor}} \\
     & (mm) & & S & L & T & \\
    \midrule 
    3 & 38 & 7 & 2 & 0 & 0 & 12\\
    4 & 80 & 10 & 0 & 2 & 1 & 12\\
    5 & 115 & 12 & 0 & 3 & 1 & 12\\
    6 & 140 & 16 & 0 & 4 & 1 & 12\\
    \bottomrule
\end{tabular} 
\caption{Geometrical parameters of the SVD. S, L, and T stands for small, large, and trapezoidal sensors. The numbering scheme treats the PXD and the SVD as an only object, hence the layer numbers 1 and 2 are taken by the two PXD layers.}
\label{Belle2_SVD_Table}
\end{table}
\end{document}

enter image description here enter image description here

Mico
  • 506,678
  • 2
    if a multicolumn is wider than the columns it spans then all the extra width goes in the last spanned column – David Carlisle Mar 11 '18 at 15:56
  • You can use two lines for "Sensors/Ladder", change the column for "T" to l or add a further column to take the extra space that the long title needs. – Heiko Oberdiek Mar 11 '18 at 15:56

2 Answers2

2

Just add some width to the three columns under the wide header and center them using a new column type like this \newcolumntype{C}{>{\centering}p{2em}}. Also double \toprule is too heavy, I used only one.

Note: The value 2em in p{2em} was chosen by trial-and-error, only a second guess got it right. But you can also get it exact by the following calculation:

\newlength\Dwidth
\settowidth{\Dwidth}{\textbf{Sensors/Ladders}}
\newcolumntype{C}{>{\centering}p{(\Dwidth-4\tabcolsep)/3}}

you will need to add the calc package though to do this. Finally, the result will be very similar to p{2em}, you may not notice a difference.

\documentclass[a4paper,11pt]{book}
\usepackage{caption,booktabs,multirow,array}
\begin{document}

\newcolumntype{C}{>{\centering}p{2em}}

\begin{table}[!h]
\centering
\begin{tabular}{ccc*3{C}c}
    \toprule
    \multirow{2}*{\textbf{Layer}} & \textbf{Radius} & \multirow{2}*{\#\textbf{Ladders}} & \multicolumn{3}{c}{\textbf{Sensors/Ladders}} & \multirow{2}*{\textbf{APV25/Sensor}} \\
     & (mm) & & S & L & T & \\
    \midrule 
    3 & 38 & 7 & 2 & 0 & 0 & 12\\
    4 & 80 & 10 & 0 & 2 & 1 & 12\\
    5 & 115 & 12 & 0 & 3 & 1 & 12\\
    6 & 140 & 16 & 0 & 4 & 1 & 12\\
    \bottomrule
\end{tabular} 
\caption{Geometrical parameters of the SVD. S, L, and T stands for small, large, and trapezoidal sensors. The numbering scheme treats the PXD and the SVD as an only object, hence the layer numbers 1 and 2 are taken by the two PXD layers.}
\label{Belle2_SVD_Table}
\end{table}
\end{document}

enter image description here

AboAmmar
  • 46,352
  • 4
  • 58
  • 127
  • +1. You might want to add a brief explanation of how you came up with 2em as the widths of the S, L, and T columns. – Mico Mar 11 '18 at 16:51
1

I suggest you employ a tabularx environment to allow linebreaks in the right-hand-most header cells.

I would also make the caption text shorter, mainly by moving much of the explanatory material into the legend area immediately below the table.

enter image description here

\documentclass[a4paper,11pt]{book}
\usepackage{caption,booktabs,tabularx,ragged2e}
\newcolumntype{C}{>{\Centering\arraybackslash}X}

\begin{document}
\begin{table}[!h]
\centering
\begin{tabularx}{0.8\textwidth}{@{} l CCcccC @{}}
    \toprule
    \textbf{Layer} & 
    \textbf{Radius} & \#\textbf{Ladders} & 
    \multicolumn{3}{@{}C@{}}{\textbf{Sensors\slash Ladder}} & 
    \textbf{APV25\slash Sensor} \\
    \cmidrule{4-6}
     & (mm) & & S & L & T & \\
    \midrule
    3 & 38 & 7 & 2 & 0 & 0 & 12\\
    4 & 80 & 10 & 0 & 2 & 1 & 12\\
    5 & 115 & 12 & 0 & 3 & 1 & 12\\
    6 & 140 & 16 & 0 & 4 & 1 & 12\\
    \bottomrule
\end{tabularx}

\medskip\RaggedRight\footnotesize
S, L, and T stands for small, large, and trapezoidal sensors. The numbering scheme treats the PXD and the SVD as an only object, hence the layer numbers 1 and 2 are taken by the two PXD layers.
\caption{Geometrical parameters of the SVD}
\label{Belle2_SVD_Table}
\end{table}
\end{document}
Mico
  • 506,678