我们有一个带有单元格longtabu
的乳胶multirow
,这些单元格包含大量文本。顺便说一下,我们使用了 XeLaTeX。
问题:单元格未垂直拉伸。
为什么?我该如何解决?
我曾尝试使用
\par\medskip\nointerlineskip\hbox to \hsize{\kern-\tabcolsep\hrulefill\kern-\tabcolsep} \vspace{-1mm}
,但线条在 5 和 6 个单元格中偏移。
我尝试了解决方案回复,但在这种情况下,一行单元格会非常宽。
最小工作示例:
\documentclass[10pt, oneside, a4paper]{report}
\usepackage[left=2cm,right=1.5cm,
top=2cm,bottom=2cm,bindingoffset=0cm]{geometry}
\usepackage{metalogo}
\usepackage{tabu}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{color,colortbl}
\usepackage[svgnames]{xcolor}
\definecolor{DarkBlue}{HTML}{074396}
\definecolor{Blue}{HTML}{1C8CCC}
\setmainfont[Ligatures=TeX]{Arial}
\begin{document}
\newcommand{\chbody}[1]{\begin{tabular}{@{}>{\color{Blue}\bfseries}c@{}}#1\end{tabular}}
\newcommand{\ch}[1]{\multicolumn{1}{c|}{\chbody{#1}}}
\newcommand{\fch}[1]{\multicolumn{1}{|c|}{\chbody{#1}}}
\tabulinesep=2mm
\arrayrulecolor{DarkBlue}
\begin{longtabu} to 170 mm {
|X[1.2, c]
|X[2 ]
|X[2, c]
|X[1.5, c]
|X[1.5, c]
|X[2, c]
|X[4]|
}
\arrayrulecolor{DarkBlue}
\hline
\fch{ID}
& \ch{Message}
& \ch{Mode}
& \ch{Priority}
& \ch{ Category}
& \ch{Escalation}
& \ch{Recommended actions}
\\
\hline
10003
& ALARM test. Press ALARM button for stop alarm
& All
& Alarm
& A
& Alarm
& Confirm
\\
\hline
\multirow{2}{=}{10007}
& \multirow{2}{=}{PORT rudder feedback fail. Check steering system}
& \textcolor{Blue}{\textbf{S}}
& Caution
& B
& *
& \multirow{2}{=}{Switch to MAN, check steering system}
\\
\tabucline{3-6}
&
& \textcolor{Blue}{\textbf{A, F, O}}
& Warning
& B
& Alarm
&
\\
\hline
\multirow{2}{=}{10007}
& \multirow{2}{=}{PORT rudder feedback fail. Check steering system}
& \textcolor{Blue}{\textbf{S}}
& Caution
& B
& *
& \multirow{2}{=}{Switch to MAN, check steering system}
\\
\tabucline{3-6}
&
& \textcolor{Blue}{\textbf{A, F, O}}
& Warning
& B
& Alarm
&
\\
\hline
\multirow{2}{=}{10007}
& \multirow{2}{=}{PORT rudder feedback fail. Check steering system}
& \textcolor{Blue}{\textbf{S}}
& Caution
& B
& *
& \multirow{2}{=}{Switch to MAN, check steering system}
\\
\tabucline{3-6}
&
& \textcolor{Blue}{\textbf{A, F, O}}
& Warning
& B
& Alarm
&
\\ \hline
\end{longtabu}
\end{document}
答案1
multirow
单元格中的行数比跨越行中的行数多。
- 一个(非常粗鲁的)解决方案是增加
\tabulinesep
,通过multirow
跨越行(实际上是这些行中的行)来补偿缺失的垂直空间,并在不需要的地方添加垂直空间, - 另一个(我认为更合理的解决方案)是重新设计列宽,使第二列和最后一列单元格中的行数相等。我这样做姆韦下面假设表格中的其他文本长度相似。
\documentclass[10pt, oneside, a4paper]{report}
\usepackage[left=2cm,right=1.5cm,
top=2cm,bottom=2cm,bindingoffset=0cm]{geometry}
\usepackage{metalogo}
\usepackage{tabu}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{color,colortbl}
\usepackage[svgnames]{xcolor}
\definecolor{DarkBlue}{HTML}{074396}
\definecolor{Blue}{HTML}{1C8CCC}
\setmainfont[Ligatures=TeX]{Arial}
\newcommand\ch[1]{\centering
\begin{tabular}{@{}>{\color{Blue}\bfseries}c@{}}
#1
\end{tabular}
}
\begin{document}
{
\tabulinesep=1.5mm % <-- changed
\setlength\tabcolsep{3pt} % <-- added
\arrayrulecolor{DarkBlue}
\begin{longtabu} to 170 mm {
|X[0.8,m] % <-- changed
|X[3.5,L,m] % <-- changed
|X[1,c,m] % <-- changed
|X[1.2,c,m] % <-- changed
|X[1.2,c,m] % <-- changed
|X[1.5,c,m] % <-- changed
|X[3,L,m]| % <-- changed
}
\arrayrulecolor{DarkBlue}
\hline
\ch{ID}
& \ch{Message}
& \ch{Mode}
& \ch{Priority}
& \ch{ Category}
& \ch{Escalation}
& \ch{Recommended\\ actions} %<-- changed
\\
\hline
10003
& ALARM test. Press ALARM button for stop alarm
& All
& Alarm
& A
& Alarm
& Confirm
\\
\hline
\multirow{2}{=}[-1ex]{10007}
& \multirow{2}{=}[-1ex]{PORT rudder feedback fail. Check steering system}
& \textcolor{Blue}{\textbf{S}}
& Caution
& B
& *
& \multirow{2}{=}[-1ex]{Switch to MAN, check steering system}
\\
\tabucline{3-6}
&
& \textcolor{Blue}{\textbf{A, F, O}}
& Warning
& B
& Alarm
&
\\
\hline
\multirow{2}{=}[-1ex]{10007}
& \multirow{2}{=}[-1ex]{PORT rudder feedback fail. Check steering system}
& \textcolor{Blue}{\textbf{S}}
& Caution
& B
& *
& \multirow{2}{=}[-1ex]{Switch to MAN, check steering system}
\\
\tabucline{3-6}
&
& \textcolor{Blue}{\textbf{A, F, O}}
& Warning
& B
& Alarm
&
\\
\hline
\multirow{2}{=}[-1ex]{10007}
& \multirow{2}{=}[-1ex]{PORT rudder feedback fail. Check steering system}
& \textcolor{Blue}{\textbf{S}}
& Caution
& B
& *
& \multirow{2}{=}[-1ex]{Switch to MAN, check steering system}
\\
\tabucline{3-6}
&
& \textcolor{Blue}{\textbf{A, F, O}}
& Warning
& B
& Alarm
&
\\ \hline
\end{longtabu}
}
\end{document}