我找不到如何在表格中将多行中的行断开。我需要制作一些表格,其中我有一个两行高的单元格,其中有很长的文本,但它不会中断行,并且文本与左侧的另一个单元格重叠。
有什么建议吗?
代码示例:
\begin{center}
\begin{tabular}{|p{1cm}|p{2.5cm}|p{2cm}|p{2cm}|p{2cm}|p{2cm}|}
\hline
\multirow{2}{*}{Long text to break} % HERE IS A PROBLEM
& Thing & \multicolumn{2}{|c|}{Thing 2} & \multicolumn{2}{|c|}{Thing 3}
\\ \cline{2-6}
& sth 1 & sth 1 & sth 2 & sth 1 & sth 2 \\ \hline
\hline
\end{tabular}
\end{center}发布于 2010-10-22 05:01:23
你可以尝试minipage它:
\begin{center}
\begin{tabular}{|l|l|l|l|l|l|}
\hline
\multirow{2}{*}{\begin{minipage}{0.5in}Long text to break\end{minipage}}
& Thing & \multicolumn{2}{|c|}{Thing 2} & \multicolumn{2}{|c|}{Thing 3} \\
\cline{2-6}
& sth 1 & sth 1 & sth 2 & sth 1 & sth 2 \\
\hline
\hline
\end{tabular}
\end{center}但是,在您的特定情况下,我的建议只是放松对其他列的限制,因为那里浪费了太多空间。对于每个p{},这会强制其他列具有一定的宽度,因此没有足够的空间容纳第一列。
当我编译以下代码时,它看起来还不错:
\begin{center}
\begin{tabular}{|l|l|l|l|l|l|}
\hline
\multirow{2}{*}{Long text to break}
& Thing & \multicolumn{2}{|c|}{Thing 2} & \multicolumn{2}{|c|}{Thing 3} \\
\cline{2-6}
& sth 1 & sth 1 & sth 2 & sth 1 & sth 2 \\
\hline
\hline
\end{tabular}
\end{center}发布于 2012-03-27 20:38:07
p列和\parbox也有效:
\usepackage{multirow}
\begin{document}
\begin{center}
\begin{tabular}{|p{1.5cm}|l|l|l|l|l|}
\hline
\multirow{2}{*}{\parbox{1.5cm}{Long text to break}}
& Thing & \multicolumn{2}{|c|}{Thing 2} & \multicolumn{2}{|c|}{Thing 3} \\
\cline{2-6}
& sth 1 & sth 1 & sth 2 & sth 1 & sth 2 \\
\hline
\hline
\end{tabular}
\end{center}
\end{document}

发布于 2015-02-02 23:08:31
对我来说,最简短、最实用的答案是:
使用\linewidth作为{width}参数的长度。
\usepackage{multirow}
\begin{document}
\begin{center}
\begin{tabular}{|p{1cm}|p{2.5cm}|p{2cm}|p{2cm}|p{2cm}|p{2cm}|}
\hline
\multirow{2}{\linewidth}{Long text to break} % HERE IS A PROBLEM
& Thing & \multicolumn{2}{|c|}{Thing 2} & \multicolumn{2}{|c|}{Thing 3}
\\ \cline{2-6}
& sth 1 & sth 1 & sth 2 & sth 1 & sth 2 \\ \hline
\hline
\end{tabular}
\end{center}
\end{document}就是这样!
唯一可能的问题是,在不太可能的情况下,其他单元格中的文本真的很短,它可能看起来像这样:

但是,如果您的表格通常在其他单元格上有更多的文本,而不仅仅是"sth1“,它将看起来很棒:

https://stackoverflow.com/questions/3991259
复制相似问题