部分最後一列的多行不良行為

部分最後一列的多行不良行為

這裡\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>}列)。

相關內容