I'm trying to typeset a table with a fixed width were the cells contents are centered both vertically and horizontally, even if one cell contains a forced line-break.
I've managed to get that done, but now I want to add text with two lines that spans two columns using the \multicolumn
command and have it still centered horizontally.
This is where I'm struggeling:
\documentclass{article}
\usepackage{array, tabularx}
\usepackage[textwidth=6in]{geometry}
\renewcommand{\tabcolsep}{0pt}
\setlength{\extrarowheight}{10pt}
\begin{document}
%
\centering%
%
\begin{tabularx}{\textwidth}{%
>{\centering\arraybackslash}m{0.5\textwidth}|
>{\centering\arraybackslash}m{0.25\textwidth}
>{\centering\arraybackslash}m{0.25\textwidth}
}%
test & test & test\break test\\
test & \multicolumn{2}{X}{test\break test}
\end{tabularx}
%
%
\end{document}
As you can see, the first column of the second row is not centered vertically and the second column is not centered horizontally, which is because I used the X parameter for \multicolumn
, but I don't know what else I should use instead.
How can this problem be solved?
\renewcommand\tabularxcolumn[1]{m{#1}}
and\multicolumn{2}{>{\centering\arraybackslash}X}{test\break test}
?