# Avoid midrule and hline together at head of supertabular

I assume this is a duplicate but I couldn't find this precise problem here nor in the docs.

I am using supertabular to create a long table spanning multiple pages with \midrule after the head and\hline after each row.

Unfortunately, on the second page, the \midrule and the \hline are shown (see picture below), while I would like to have only the \midrule there, i.e. I would like to "skip" this particular \hline. Is that somehow possible.

MWE:

\documentclass{memoir}

\usepackage{supertabular}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{forloop}

\begin{document}

\renewcommand{\arraystretch}{1.3}
\centering
\tablefirsthead{\toprule Row Counter & Random Header \\ \arrayrulecolor{black} \midrule \arrayrulecolor{lightgray}}
\tablehead{Row Counter & Random Header \\ \arrayrulecolor{black} \midrule    \arrayrulecolor{lightgray}}
\tabletail{ \\ \arrayrulecolor{black} \bottomrule \arrayrulecolor{lightgray} \multicolumn{2}{l}{\small \textit{Random tail text.}}\\}
\tablelasttail{\\ \arrayrulecolor{black} \bottomrule}
\bottomcaption{Random caption text.}

\newcounter{rowcounter}
\begin{supertabular}{p{3cm}|p{9cm}}
\forloop{rowcounter}{0}{\value{rowcounter} < 70}{line \arabic{rowcounter} & random text \\ \hline }
last line & random text
\end{supertabular}

\end{document}


You can use the code from David Carlisle's answer https://tex.stackexchange.com/a/52042/15925 as follows

\documentclass{memoir}

\usepackage{supertabular}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{forloop}

\makeatletter
\let\savedST@cr\ST@cr
\def\ST@cr{\noalign{\ifnum0=}\fi\futurelet\st@temp\ST@crhline}
\def\ST@crhline{%
\ifx\st@temp\hline
\global\let\next@a\hline
\global\let\next@b\@gobble
\else
\global\let\next@a\@gobble
\global\let\next@b\@empty
\fi
\ifnum0={\fi}%
\next@a
\savedST@cr
\next@b}
\makeatother

\begin{document}

\renewcommand{\arraystretch}{1.3}
\centering
\tablefirsthead{\toprule Row Counter & Random Header \\
\arrayrulecolor{black} \midrule \arrayrulecolor{lightgray}}

\arrayrulecolor{black} \midrule \arrayrulecolor{lightgray}}

\makeatletter
\tabletail{\arrayrulecolor{black}
\noalign{\ifnum0=}\fi\@BTrule[\heavyrulewidth]
\arrayrulecolor{lightgray} \multicolumn{2}{l}{\small \textit{Random
tail text.}}\\}
\makeatother

\tablelasttail{ \\ \arrayrulecolor{black} \bottomrule}
\bottomcaption{Random caption text.}

\newcounter{rowcounter}

\begin{supertabular}{p{3cm}|p{9cm}}
\forloop{rowcounter}{0}{\value{rowcounter} < 70}{line
\arabic{rowcounter} & random text \\ \hline } last line & random
text
\end{supertabular}

\end{document}


Note the definition of the tail - this a \bottomrule without separation. Alternatively you could set \arrayrulesep to 0pt` throughout.

• awesome, thanks! I actually found that answer but didn't know whether it was really related. And I don't know enough Latex understand the code or adjust it. – ciem Nov 11 '17 at 14:57
• I just realized, that the vertical line on the page before (page 1 in the example) is now going down and crossing the table tail. How could I shorten that? – ciem Nov 12 '17 at 12:53
• @ciem I missed that - code now improved to fix this – Andrew Swann Nov 12 '17 at 15:35