我正在尝试制作一个长表,它有重复的标题。此外,每行都有规则。然而,在第二页中,规则重复了两次。它看起来不够完美。我该如何解决这个问题?
平均能量损失
\documentclass[11pt, a4paper, oneside]{memoir}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{array}
\usepackage{arydshln}
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1.5pt}
\setlength\arrayrulewidth{0.3pt}
\begin{document}
\begin{longtable}{l}
\toprule
Title \\
\midrule
\endfirsthead
\toprule
Title \\
\midrule
\endhead
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \bottomrule
\end{longtable}
\end{document}
《经济学人》也使用规则
答案1
我偶然发现了一个解决方案。它可能有缺点,但对我来说很有效。
添加这两行即可解决问题
\setlength{\aboverulesep}{0pt}
\setlength{\belowrulesep}{0pt}
MWE 现在成为
\documentclass[11pt, a4paper, oneside]{memoir}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{array}
\usepackage{arydshln}
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1.5pt}
\setlength\arrayrulewidth{0.3pt}
\setlength{\aboverulesep}{0pt}
\setlength{\belowrulesep}{0pt}
\begin{document}
\begin{longtable}{l}
\toprule
Title \\
\midrule
\endfirsthead
\toprule
Title \\
\midrule
\endhead
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \bottomrule
\end{longtable}
\end{document}
第 2 页的输出显示:
答案2
使用新的 LaTeX3 软件包tabularray
,没有重复的水平虚线:
\documentclass[11pt, a4paper, oneside]{memoir}
\usepackage[a6paper]{geometry}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\NewTableCommand{\hdashline}{\hline[0.3pt,dashed]}
\begin{document}
\begin{longtblr}[
caption = {Long Caption},
label = {tblr:test},
]{colspec={X},rowhead=1}
\toprule
Title \\
\midrule
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \hdashline
D \\ \hdashline
A \\ \hdashline
B \\ \hdashline
C \\ \bottomrule
\end{longtblr}
\end{document}