My question is very similar to this one: previous question
but when I vary the example a little (as below), my cells are no longer vertically aligned
\documentclass[12pt]{article}
\usepackage{tabularx,booktabs}
\renewcommand\tabularxcolumn[1]{m{#1}}
\newcolumntype{Z}[0]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}X}%
\newcolumntype{s}[0]{>{\centering\arraybackslash\hsize=.4\hsize}Z}%
\newcolumntype{n}[0]{>{\centering\arraybackslash\hsize=.8\hsize}Z}%
\begin{document}
\begin{table}
\begin{tabularx}{7cm}{s|Z|s|n}
& really really really long\linebreak heading 1 & very very narrow column & \\
\toprule
row 1 & 2314 & 2134 & medium medium column \\ \hline
row 1 & 2314 & 2134 & medium medium column
\end{tabularx}
\end{table}
\end{document}
Best Answer
Beware that for resized
X
cells, the coefficients are like barycentric coordinates and their sum has to be equal to the columns number.Also, I managed horizontal rules meet vertical rules, and set all rules (vertical as well as horizontal rules but one) to have the width of
\midrule
s, and I simplified your code.