2

I'm struggling to understand what's happening here:

I am creating a table, and want the column on the far left to have text which is vertically centered in its cell. However, the vertical alignment seems to be completely inconsistent.

Here is my code (I had to include filler text or the issue was not properly demonstrated, sorry if it looks messy!). I've tried to provide a minimum working example.

\documentclass{article}
\usepackage{multirow}
\usepackage{array}
\usepackage{ragged2e}
\newcolumntype{P}[1]{>{\RaggedRight\hspace{0pt}}p{#1}}

\begin{document}

\begin{table}[htbp]
\caption{Sample Table.}\label{tab1}
\begin{tabular}{ |m{0.5cm}|P{4cm}|P{4.3cm}|P{4.5cm}| }
\hline
\textbf{} &  \textbf{Objective} & \textbf{Criteria} & \textbf{Test Plan}\\
\hline
\multirow{7}{*}{\rotatebox{90}{Performance}} & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler.\\ \cline{2-4}
                        &Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler. \\ \cline{2-4}
                        & & & \\ \cline{2-4}
                        & & & \\ \cline{2-4}
                        & & & \\ \cline{2-4}
                        & & & \\ \cline{2-4}
                        & & & \\ \hline
\multirow{2}{*}{\rotatebox{90}{Dimensions}}  & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler.\\ \cline{2-4}
                         & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler.\\ \hline
\multirow{5}{*}{\rotatebox{90}{Safety}}      & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler.\\ \cline{2-4} 
                        & & & \\ \cline{2-4} 
                        & & & \\ \cline{2-4}
                        & & & \\ \cline{2-4}
                        & & & \\ \hline
\end{tabular}
\end{table}

\end{document}

This produces the following table, in which the left most cells are not properly vertically aligned. How could I fix this? Many thanks!

enter image description here

2

Vertical centering of cell contents is absolutly not a trivial issue. However, you can usually solve it (in a cosmetic way) by using some tricks:

1) Adding a vertical position correction:

change: \multirow{7}{*} to \multirow{7}{*}[-5ex]

change: \multirow{2}{*} to \multirow{2}{*}[-2.5ex]

change: \multirow{5}{*} to \multirow{5}{*}[-3ex]

2) (another approach) Lying about the row number in the \multirow statements:

change: \multirow{7}{*} to \multirow{11}{*}

change: \multirow{2}{*} to \multirow{6}{*}

change: \multirow{5}{*} to \multirow{7}{*}

  • That worked! Thanks for showing me the tricks :) – martina May 31 at 19:13
1

multirow normally works for single-line cells; so in case of multiline cells you have to count the number of lines, not the number of rows. In addition, you can use an optional vertical correction, and in case of rotated material, choose the centre of rotation.

Unrelated: note your table overflows into the margin. It might be of interest to use a tabularx environment to have a table which fits between the margins.

\documentclass{article}
\usepackage{multirow, rotating, caption}
\usepackage{array}
\usepackage{ragged2e}
\newcolumntype{P}[1]{>{\RaggedRight\hspace{0pt}}p{#1}}

\begin{document}

\begin{table}[htbp]
\caption{Sample Table.}\label{tab1}
\begin{tabular}{ |m{0.5cm}|P{4cm}|P{4.3cm}|P{4.5cm}| }
\hline
\textbf{} & \textbf{Objective} & \textbf{Criteria} & \textbf{Test Plan}\\
\hline
\multirow{11}{=}[0.5ex]{\rotatebox[origin =r]{90}{Performance}} & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler.\\ \cline{2-4}
                        &Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler. \\ \cline{2-4}
                        & & & \\ \cline{2-4}
                        & & & \\ \cline{2-4}
                        & & & \\ \cline{2-4}
                        & & & \\ \cline{2-4}
                        & & & \\ \hline
\multirow{6}{=}{\rotatebox[origin =r]{90}{Dimensions}} & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler.\\ \cline{2-4}
                         & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler.\\ \hline
\multirow{7}{=}{\rotatebox[origin =c]{90}{Safety}} & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler. & Filler text to demonstrate problem, filler filler filler filler filler.\\ \cline{2-4}
                        & & & \\ \cline{2-4}
                        & & & \\ \cline{2-4}
                        & & & \\ \cline{2-4}
                        & & & \\ \hline
\end{tabular}
\end{table}

\end{document} 

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.