![具有换行文本的多行列--自动调整大小](https://linux22.com/image/351436/%E5%85%B7%E6%9C%89%E6%8D%A2%E8%A1%8C%E6%96%87%E6%9C%AC%E7%9A%84%E5%A4%9A%E8%A1%8C%E5%88%97--%E8%87%AA%E5%8A%A8%E8%B0%83%E6%95%B4%E5%A4%A7%E5%B0%8F.png)
我正在尝试生成具有以下结构的表:
问题是红色的 X - 我希望单元格中的文本换行,并且单元格高度自动调整。我尝试使用 minipage,调整大小、parbox 等。它似乎无法同时自动调整行大小和换行。一旦两个多行已满,文本将始终溢出到下一行。
\documentclass[12pt,a4paper,titlepage]{article}
\usepackage{rotating}
\usepackage{multirow}
\usepackage{lscape}
\usepackage{caption}
\begin{document}
\begin{landscape}
\captionsetup{format=plain}
\centering
\begin{tabular}{c|c c c |p{\linewidth}}
\multirow{3}{*}{} & \multicolumn{3}{c}{Range of} & \multirow{2}{*}{} \\
& parameter1 & param 2 & param 3 & \\ \hline
\multirow{2}{*}{1} &value & value & value & \multirow{3}{*}{\begin{minipage}{15cm}pretty long description that wraps over more than two lines pretty long description that wraps over more than two linespretty long description that wraps over more than two linespretty long description that wraps over more than two linespretty long description that wraps over more than two lines\end{minipage}} \\
& value & value & value & \\ \hline
\end{tabular}
\captionof{table}{caption caption caption}
\end{landscape}
\end{document}
答案1
multirow
不会自动扩展跨行,因此如果跨行条目大于表的其余部分,则需要使用\[..]
\documentclass[12pt,a4paper,titlepage]{article}
\usepackage{rotating}
\usepackage{multirow}
\usepackage{lscape}
\usepackage{caption}
\begin{document}
\begin{landscape}
\captionsetup{format=plain}
\centering
\begin{tabular}{c|c c c |p{\linewidth}}
\multirow{3}{*}{} & \multicolumn{3}{c|}{Range of} &
\multirow{2}{*}{} \\[10pt]
& parameter1 & param 2 & param 3 & \\[10pt]
\hline
\multirow{2}{*}{1} &value & value & value &
\multirow{3}{15cm}{pretty long description that
wraps over more than two lines pretty long description
that wraps over more than two linespretty long description
that wraps over more than two linespretty long description
that wraps over more than two linespretty long description
that wraps over more than two lines} \\[20pt]
& value & value & value & \\[10pt]
\hline
\end{tabular}
\captionof{table}{caption caption caption}
\end{landscape}
\end{document}