我对 LaTeX 不太熟悉,在格式化表格时遇到了问题。我正在使用longtable
和mulitrow
,以下部分代码导致了问题:
REQ-015 & \multirow{1}{=}{Verified in Ansys dynamic analysis.}
& \multirow{1}{=}{Use of shakers with slip table and head
expander for in-plane and out-of-plane vibration
respectively. Use of strain gauges and accelerometers
for measurements.} \\
\cline{1-1}
REQ-016 & & \\
\hline
REQ-017 &Verified through static load testing in Ansys. & \\
\hline
发生的情况是,第 3 列 REQ-015 和 REQ-016 的合并行中的文本溢出到 REQ-017 中,如下所示:
有人能帮我解决这个问题吗?表中还有其他类似的行,它们不会造成问题,但我似乎无法解决这个问题。
答案1
我不太清楚你想实现什么,但我的解决方案如下tabularray
:
\documentclass{article}
\usepackage{geometry}
\usepackage{tabularray}
\begin{document}
\begin{longtblr}[
caption={My long table}
]{
colspec={lp{5cm}p{7cm}},
vlines,
vspan=even,
}
\hline
& \SetCell[r=2]{l} Verified in Ansys dynamic analysis. & \SetCell[r=4]{l} Use of shakers with slip table and head expander for in-plane and out-of-plane vibration respectively. Use of strain gauges and accelerometers for measurements. \\
REQ-015 & & \\
\cline{1-1}
REQ-016 & & \\
& & \\
\hline
REQ-017 &Verified through static load testing in Ansys. & \\
\hline
\end{longtblr}
\end{document}
答案2
我想出了这样的事情:
\documentclass{article}
\usepackage{longtable}
\usepackage{multirow}
\begin{document}
\noindent
\begin{longtable}{| l | p{5cm} | p{7cm} |}
\hline
& \multirow{2}{=}{Verified in Ansys dynamic analysis.} & \multirow{4}{=}{Use of shakers with slip table and head expander for in-plane and out-of-plane vibration respectively. Use of strain gauges and accelerometers for measurements.} \\*
REQ-015 & & \\* \cline{1-1}
REQ-016 & & \\*
& & \\
\hline REQ-017 &Verified through static load testing in Ansys. & \\ \hline
\end{longtable}
\end{document}
为了防止在一个“单元”内出现分页符,最好在不需要分页符的地方用\\
替换。\\*