具有换行文本的多行列--自动调整大小

具有换行文本的多行列--自动调整大小

我正在尝试生成具有以下结构的表:

表格示例

问题是红色的 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}

相关内容