0

I am trying to make a longtable, that has repeating headers. Also, each row has rules. In the second page, however, the rule repeats twice.It looks unpolished. How do I fix this?

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}

\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}

enter image description here

enter image description here

The Economist too uses rules

Economist

9
  • This is a known feature of longtable and has nothing to do with array, booktabs or memoir, so I deleted the tags
    – user31729
    Commented Aug 20, 2017 at 8:27
  • You should also ask yourself what exactly you're trying to achieve with all those \hddashline directives. The longtable will look a lot cleaner (or, to use your phrase, more polished) if all, or at least most, of these directives are simply omitted. Your readers will thank you.
    – Mico
    Commented Aug 20, 2017 at 8:33
  • Mico, The confusion comes from the MWE. My actual data is several columns wide. I have added a screen-shot. Do you still suggest that omitting rules will improve readability?
    – AK16
    Commented Aug 20, 2017 at 8:38
  • see answer for long table in tex.stackexchange.com/questions/387308/…
    – Zarko
    Commented Aug 20, 2017 at 8:46
  • @AK16 - Are you familiar with the Latin proverb, "Quod licet Iovis, non licet bovis"? Speaking for myself here, I doubt the table from The Economist magazine would be less legible had all dashed lines been omitted. :-)
    – Mico
    Commented Aug 20, 2017 at 8:55

2 Answers 2

1

I kinda stumbled on a solution. It may have drawbacks but it works for me.

Adding these 2 lines removed the problem

\setlength{\aboverulesep}{0pt}
\setlength{\belowrulesep}{0pt}

The MWE now becomes

\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}

Page 2 output is shown:

Output

2
  • 1
    at me it works fine without \setlength{\aboverulesep}{0pt} \setlength{\belowrulesep}{0pt}. probably you have installed outdated packages. upgrade it! and not forget, that longtable need to be compiled at least twice that it gain final format.
    – Zarko
    Commented Jan 17, 2018 at 15:26
  • \endhead solved the issue for me. Thanks.
    – MaduKan
    Commented Jun 30, 2022 at 20:57
1

With the new LaTeX3 package tabularray, there are no repeating horizontal dash lines:

\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}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .