I'm afraid the tons of questions that are about alignment of a cell in a table don't solve my issue. The problem is that the cell I want to center is a multirow
cell. Using a \multicolumn{1}{|c|}{text}
(as suggested here) inside a multirow
seem not to work.
My MWE:
\documentclass{article}
\usepackage{multirow,multicol}
\begin{document}
\begin{table}
\begin{tabular}{c l c c c}
\hline
\multirow{2}{*}{Text} & \multirow{2}{*}{Text to center} & 1234 & 345 & 543 \\
& & (Four-digit) & (Three-digit) & (Four-digit) \\
\hline \hline
\multirow{3}{*}{Yes} & Managers, and senior officials & 1 & 2 & 1 \\
& Professional occupations & 2 & 2 & 2 \\
& Associate professional occupations & 3 & 3 & 3 \\
\hline
\multirow{3}{*}{No} & Personal service occupations & 5 & 6 & 8 \\
& Agricultural, fishery and related & 9 & 9 & 9 \\
& Health service occupations & 8 & 6 & 6 \\
\hline
\end{tabular}
\end{table}
\end{document}
Note: I want to center because I want the rest of the column to be left-aligned.
Best Answer
Use the
makecell
package for that. It allows for line breaks in cells, and a common formatting. By default, the contents of a\makecell
command is centred both vertically and horizontally (but this may be changed with an optional argument) whatever the alignment in the column. Additionally, you have one less row.I took the opportunity to use the rules of
booktabs
, which adds some vertical padding around them.