最后一列出现多行不良行为

最后一列出现多行不良行为

这里\multirow文档(我没有找到答案),这是我的 MWE(但没有按预期工作,说明了问题):

\documentclass[twoside,a4paper,11pt,chapterprefix=true]{scrbook}

\usepackage[UTF8]{inputenc} %encodage clavier
\usepackage[T1]{fontenc} %encodage police
\usepackage[francais]{babel} %langue
\usepackage{multirow}

\begin{document}
\begin{tabular}{|c|c|c|c|}
\hline      
    \multicolumn{4}{|c|}{my little 1rst line} \\
\hline  
    \multicolumn{2}{|c|}{blabla}    & \multicolumn{2}{c|}{blabla} \\
\hline  
    blabla & blabla & \multirow{2}{*}{whaou there is so much text here, that's embarassing, look the cell goes beyond the tabular, and even beyond the page, the worst being : you don't even get a warning for going out of the page, and i'm not even talking about the margins...} \\
\cline{1-2} 
    \multicolumn{2}{|c|}{blabla} & \\
\hline  
\end{tabular}
\end{document}

我希望的行为是不超过单元格,无论是通过拉伸单元格还是强制在单元格内换行。

答案1

使用*in\multirow会使单元格宽度为其内容的宽度。您可以在第二个参数中使用固定的适当长度:

\documentclass[twoside,a4paper,11pt,chapterprefix=true]{scrbook}
\usepackage[utf8]{inputenc} %encodage clavier
\usepackage[T1]{fontenc} %encodage police
\usepackage[francais]{babel} %langue
\usepackage{multirow}
\usepackage{array}

\begin{document}
\noindent\begin{tabular}{|c|c|c|c|}
\hline      
    \multicolumn{4}{|c|}{my little 1rst line} \\
\hline  
    \multicolumn{2}{|c|}{blabla}    & \multicolumn{2}{>{\centering\arraybackslash}p{5cm}|}{blabla} \\
\hline  
    blabla & blabla & \multirow{2}{5cm}{whaou there is so much text here, that's embarassing} \\
\cline{1-2} 
    \multicolumn{2}{|c|}{blabla} & \\
\hline  
\end{tabular}
\end{document}

在此处输入图片描述

当然,根据表格的实际内容,您的列规范可能会发生变化(如果需要文本换行,最好使用p{<length>}列)。

相关内容