I'm using a multirow
environment to span text over two rows. As it does not support \\
for inserting a line break, I'm nesting it into a shortstack
(see MWE below). However, the text is in neither of both cases (single line text, dual line text) really centered. What am I doing wrong?
Example Image
The red line indicates the center of the heading row (spans over two rows). As shown in the image, neither of both lines are really vertically centered.
MWE
\documentclass[a4paper,twocolumn]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage[a4paper,top=3cm,bottom=2cm,left=1.5cm,right=1.5cm,marginparwidth=1.75cm]{geometry}
\title{Your Paper}
\author{You}
\begin{document}
\begin{table}[htbp]
\caption{Classifier configurations and their performance.}
\label{tblClassifierConfig}
\begin{tabular*}{1.2\columnwidth}{@{\extracolsep{\fill}}lrllll@{}}
\toprule
\multirow{2}{*}{\raisebox{-\heavyrulewidth}{\shortstack[l]{\textbf{N-gram}\\as Range}}} & \multirow{2}{*}{\raisebox{-\heavyrulewidth}{\shortstack[l]{\textbf{Vocab. Size}\\in \#n-grams}}} & \multicolumn{2}{c}{Test Set 1} & \multicolumn{2}{c}{Test Set 2} \\
\cmidrule(l){3-6} & & \textbf{Prec.} & \textbf{Recall} & \textbf{Prec.} & \textbf{Recall} \\ \midrule
(2,4)-char & 500 & 0.9999 & 0.9999 & 0.5085 & 0.5849 \\
(2,4)-char & 1000 & 0.9999 & 0.9999 & 0.5114 & 0.6132 \\
(2,3)-word & 1,500 & 0.9999 & 0.9999 & 0.5134 & 0.6268 \\
(1,3)-word & 2,000 & 0.9999 & 0.9999 & 0.5138 & 0.6307 \\ \bottomrule
\end{tabular*}
\end{table}
\end{document}
Best Answer
in
multirow
cells you also need to consider vertical space introduced by\cmidrule
. it is about0.4
row height, so you can wrotei also suggest in columns with numbers to use
S
column type fromsiunitx
package, not increase table width (it will protrude in next column). istead this rather reducetabocolsep
:which gives