![带有书页标签的长表,中间规则被推到下一页](https://linux22.com/image/306873/%E5%B8%A6%E6%9C%89%E4%B9%A6%E9%A1%B5%E6%A0%87%E7%AD%BE%E7%9A%84%E9%95%BF%E8%A1%A8%EF%BC%8C%E4%B8%AD%E9%97%B4%E8%A7%84%E5%88%99%E8%A2%AB%E6%8E%A8%E5%88%B0%E4%B8%8B%E4%B8%80%E9%A1%B5.png)
我想在横向模式下制作一个正式的长表。我使用 booktabs 使表格正式化。这是一个示例 tex 文档:
\documentclass{article}
\usepackage{array}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage[english]{babel}
\usepackage[pangram]{blindtext}
\usepackage{lscape}
\begin{document}
\blindtext[5]
\begin{landscape} \sffamily{%
\begin{longtable}{>{\raggedright}p{7cm}>{\centering}p{7cm}}
\toprule
Header & \\
\midrule
\endhead
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\bottomrule
\end{longtable}}\end{landscape}
\end{document}
当文档编译(pdflatex)时,第 2 页最后一行(第 10 行)下方的规则(midrule)被推到下一页,导致标题行下方出现双线。为什么会出现这种情况?如何修复?
编辑:
这是另一个示例,表格稍微复杂一些,有第一个页眉、页脚、页脚和最后一个页脚,也出现了类似的问题。我该如何修复这个问题?
\documentclass{article}
\usepackage{array}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage[english]{babel}
\usepackage[pangram]{blindtext}
\usepackage{lscape}
\begin{document}
\blindtext[5]
\begin{landscape} \sffamily{%
\begin{longtable}{>{\raggedright}p{7cm}>{\centering}p{7cm}}
\toprule
First Header & \\
\midrule
\endfirsthead
\toprule
Header & \\
\midrule
\endhead
Footer & \\
\midrule
\endfoot
Last Footer & \\
\bottomrule
\endlastfoot
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\blindtext[2] & \\
\midrule
\end{longtable}}\end{landscape}
\end{document}
答案1
您必须使用\\*
而不是\\
。这样\midrule
s 就会与其所在行保持在一起。
梅威瑟:
\documentclass{article}
\usepackage{array}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage[english]{babel}
\usepackage[pangram]{blindtext}
\usepackage{lscape}
\begin{document}
\blindtext[5]
\begin{landscape} \sffamily{%
\begin{longtable}{>{\raggedright}p{7cm}>{\centering}p{7cm}}
\toprule
Header & \\
\midrule
\endhead
\blindtext[2] & \\*
\midrule
\blindtext[2] & \\*
\midrule
\blindtext[2] & \\*
\midrule
\blindtext[2] & \\*
\midrule
\blindtext[2] & \\*
\midrule
\blindtext[2] & \\*
\midrule
\blindtext[2] & \\*
\midrule
\blindtext[2] & \\*
\midrule
\blindtext[2] & \\*
\midrule
\blindtext[2] & \\*
\bottomrule
\end{longtable}}\end{landscape}
\end{document}