我的表格在逻辑上被分成一组中的 2 行。我希望分页符只出现在组的最后一行之后。如何使用 longtable 来实现这一点?在下面的示例中,分页符出现在“位 6”上
\documentclass[]{article}
\usepackage{longtable,booktabs}
\usepackage{geometry}
\geometry{
a4paper,
total={160mm,257mm},
left=10mm,
top=20mm,
}
\date{}
\begin{document}
\subsubsection{SOME\_REGISTER, 0x100}\label{some_register-0x100}
Some register for XXX
\begin{longtable}[c]{|p{0.15\textwidth}|p{0.4\textwidth}|p{0.15\textwidth}|p{0.15\textwidth}|p{0.2\textwidth}|}
\caption{A sample long table.} \label{tab:long} \\
\hline
{\bf Bit Position} & {\bf Field Name} & {\bf Permissions} & {\bf Reset Value} & {\bf Field Attributes} \\\hline
\endfirsthead
\multicolumn{5}{c}%
{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
\hline {\bf Bit Position} & {\bf Field Name} & {\bf Permissions} & {\bf Reset Value} & {\bf Field Attributes} \\ \hline
\endhead
\hline \multicolumn{5}{|r|}{{Continued on next page}} \\ \hline
\endfoot
\hline \hline
\endlastfoot
0 & Reserved & -- & -- & \\\hline
1 & FIELD1\_NAME & RW & 0x0 & \\*\hline
& \multicolumn{4}{|p{.85\textwidth}|}{
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
} \\\hline
2 & FIELD1\_NAME & RW & 0x0 & \\*\hline
& \multicolumn{4}{|p{.85\textwidth}|}{
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
} \\\hline
3 & FIELD1\_NAME & RW & 0x0 & \\*\hline
& \multicolumn{4}{|p{.85\textwidth}|}{
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
} \\\hline
4 & FIELD1\_NAME & RW & 0x0 & \\*\hline
& \multicolumn{4}{|p{.85\textwidth}|}{
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
} \\\hline
5 & FIELD1\_NAME & RW & 0x0 & \\*\hline
& \multicolumn{4}{|p{.85\textwidth}|}{
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
} \\\hline
6 & FIELD1\_NAME & RW & 0x0 & \\*\hline
& \multicolumn{4}{|p{.85\textwidth}|}{
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
Line1
} \\\hline
\bottomrule
\end{longtable}
\end{document}
答案1
您可以使用\\
允许在此特定行后进行分页。使用\\*
则禁止分页。
答案2
正如 leandriis 所说,这篇文章帮助我实现了正确的分页符:https://tex.stackexchange.com/a/107893/209519