0

I'm trying to get the vertical spacing in some tables to be less squished and I thought I would do so by making the rows a bit taller and centring the text vertically in the rows. The code below uses the advice from the second answer in this question to add '[XXpt]' after the line break where xx specifies a line height in order to make one of the rows taller. In terms of centering the text vertically, my understanding is that the 'm' prefix in front of the row widths below should do that.

Based on my understanding, the first row of the table below should be tall and have vertically centred text but it is only tall with text at the top. Can anyone tell me why and how to fix it?

\documentclass{report}

\usepackage{supertabular}
\usepackage{hhline}
\usepackage{array}


\begin{document}

\begin{table}
\begin{center}
\begin{supertabular}{m{0.7059598in}m{0.45105985in}m{0.61285985in}m{0.02in}m{0.7573598in}m{1.0121598in}m{0.07535984in}m{0.45105985in}m{0.9045598in}}
\hhline{~--~--~--}
 &
\multicolumn{2}{m{1.0893197in}}{Shouldn't these} &
 &
\multicolumn{2}{m{1.907in}}{Headings be centered} &
 &
\multicolumn{2}{m{1.4343598in}}{Vertically?}\\ [40pt]
\hhline{~--~--~--}
Phantom & Mean & St. Dev. &  & Mean & St. Dev. & & Mean & 95\% CI\\\hline
Seroma 1 & 5.73 & 0.04 &  & 5.57 & 0.14 &  & 0.16 & [-0.06, 0.37]\\ [20pt]
Seroma 2 & 3.75 & 0.03 &  & 3.61 & 0.13 &  & 0.15 & [-0.08, 0.37]\\
\end{supertabular}
\end{center}
\end{table}

\end{document} 
  • \\[xx] adds to the depth of the previous row, an m does not centre in the space for the surrounding row, it just puts the baseline of the content in the contents vertical centre (like \parbox[c]) finally tex is not accurate to more than about 5 dp , so 0.7059598in is a bit odd, also if you have a span it should be \dimexpr0.7059598in+0.45105985in+2\tabcolsep\relax which is rather more than the 1.0893197in you have used. – David Carlisle Oct 28 '17 at 8:23
  • There's no point in using supertabular in a table environment. – egreg Oct 28 '17 at 8:42
  • @DavidCarlisle thanks for your input. Table spacing like "0.7059598in" is a result of using writer2latex (writer2latex.sourceforge.net) on a file originally written in Microsoft Word. It's simply an artifact of the table sizes previously set. If it's not actually that precise it's fine by me. – JMikes Oct 28 '17 at 14:06
  • Similarly to my above comment, @egreg, the nested environments were created by writer2latex and I've simply tried to not fix what isn't broken. I'll look into the package documentation at some point but for now am looking to meet a deadline and deal with the finer points later. Thanks for your input. – JMikes Oct 28 '17 at 14:11
2

mwe

The solution for center heads is simply to use \multicolumn{2}{c}{text}, not m columns. For vertical padding, note the effects of booktabs rules and the command \arraystretch, so you can avoid using \\[Xpt] and empty columns in most cases. Using \cmidrule(rl){2-3} you can also avoid using empty columns. Note also that it is usually preferable to use \centering instead of center because the first does not add extra vertical space around the table. For wide tables, I strongly suggest reading the manuals of tabularx and tabulary packages.

\documentclass{report}
\usepackage{tabulary,booktabs,array,lipsum}
\renewcommand\arraystretch{1.2} % change as needed
\renewcommand\belowcaptionskip{1ex} % change as desired
\begin{document}
\lipsum[2]
\begin{table}
\caption{The caption}
\centering
\begin{tabulary}{\linewidth}{LCCCCCC}
\toprule
& \multicolumn{2}{c}{Multicolumns}  
& \multicolumn{2}{c}{Centered} 
& \multicolumn{2}{c}{Vertically}\\
\cmidrule(rl){2-3}\cmidrule(rl){4-5}\cmidrule(rl){6-7}
Phantom  & Mean & St. Dev. & Mean & St. Dev. & Mean & 95\% CI\\
\midrule
Seroma 1 & 5.73 & 0.04 & 5.57 & 0.14 & 0.16 & [-0.06, 0.37]\\ 
Seroma 2 & 3.75 & 0.03 & 3.61 & 0.13 & 0.15 & [-0.08, 0.37]\\
\bottomrule
\end{tabulary}
\end{table}
\end{document} 
  • Beautiful. I'll look into the documentation for the tabulary package you used. Thanks for your help! – JMikes Oct 28 '17 at 14:14

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.