如何在 table 中将多行文本垂直居中

How to vertically center text in multirow in table

我试图将 'test' 在第一列中垂直居中,这是 table 的多行。代码如下:

\begin{table}[]
\tiny
\caption{a}

\begin{tabular}{|M{0.1in}|p{0.7in}|p{1.4in}|p{2in}|}
  \hline
  % after \: \hline or \cline{col1-col2} \cline{col3-col4} ...
   & \textbf{Factor Name} & \textbf{Explanation} & \textbf{Rationale} \
  \hline
  \multirow{4}{*}{\rotatebox[origin=c]{90}{test}}& body1 &body2 &\multirow{2}{*}{\parbox{2in}{body3}}  \
  \hhline{~--~}
   & 1 & 2 \newline & \
     \hhline{~---}
   & 3& 3 & \multirow{2}{*}{5}  \
     \hhline{~--~}
   & 6 & 7 & \
   \hhline{----}


   \hline
\end{tabular}
\end{table}

有什么想法可以做到这一点。

test 应该跨越 5 行,而不是 4;包含 12 的行跨越两行,您应该在 \multirow 语句中容纳它们:

\documentclass{article}

\usepackage{multirow,hhline,graphicx,array}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}

\begin{tabular}{|M{0.1in}|p{0.7in}|p{1.4in}|p{2in}|}
  \hline
  % after \: \hline or \cline{col1-col2} \cline{col3-col4} ...
   & \textbf{Factor Name} & \textbf{Explanation} & \textbf{Rationale} \
  \hline
  \multirow{5}{*}{\rotatebox[origin=c]{90}{test}}& body1 &body2 &\multirow{2}{*}{\parbox{2in}{body3}} \
  \hhline{~--~}
   & 1 & 2 \newline & \
   \hhline{~---}
   & 3 & 3 & \multirow{2}{*}{5} \
   \hhline{~--~}
   & 6 & 7 & \
   \hhline{----}
\end{tabular}

\end{document}