我在多行表中垂直对齐(和换行)文本时遇到问题。因此,我希望 estmeed 社区能在这方面提供一些帮助。请参见下文:
\begin{table}
\caption{Story of Humpty Dumpty}
\centering
\begin{tabular}{c|c|c}
\hline
\multirow{3}{*}{Humpty Dumpty Sat} & on & \begin{tabular}[c]{@{}c@{}}the wall\\ and had a great fall \end{tabular}\\ \cline{2-3}
& \begin{tabular}[c]{@{}c@{}} on\end{tabular} & \begin{tabular}[c]{@{}c@{}}the wall\\ and had a great fall \end{tabular}\\ \cline{2-3} & \begin{tabular}[c]{@{}c@{}}on\\ \end{tabular} & \begin{tabular}[c]{@{}c@{}}the wall\\ and had a great fall\end{tabular} \\ \hline
\end{tabular}
\end{table}
我希望实现以下目标:
答案1
答案2
或者,使用较短的代码,采用m
列类型并center
设置“多行单元格:
\documentclass{article}
\usepackage{array, multirow}
\begin{document}
\begin{table}
\caption{Story of Humpty Dumpty}
\centering
\renewcommand\multirowsetup{\centering} % <---
\renewcommand\arraystretch{1.3}
\begin{tabular}{p{6em}|c|>{\centering\arraybackslash}m{8em}} <---
\hline
\multirow{4.5}{=}{Humpty Dumpty Sat} % 4.5=6 spanned lines-2 lines text + 0.5 line for gaps in rows
& on & the wall and had a great fall \\ \cline{2-3}
& on & the wall and had a great fall \\ \cline{2-3}
& on & the wall and had a great fall \\
\hline
\end{tabular}
\end{table}
\end{document}