2016-11-10 69 views
-2

我想在表格的多行中的第一列垂直居中'測試'。代碼如下:如何在表格中以多行方式垂直居中文本

\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} 

任何想法做到這一點。

回答

0

test應該跨越5行,而不是4;含12行跨越兩行,你應該在你的\multirow聲明適應:

enter image description here

\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}