Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Why longtable adds vertical skip after head on subsequent pages and how to fix this?

\documentclass{article}
\usepackage[a6paper,margin=4mm]{geometry}
\usepackage{booktabs,caption,longtable}
\usepackage{lipsum}
\usepackage{tikz}
\pagestyle{empty}
\parindent=0pt
\begin{document}

\begin{longtable}{rp{8cm}}
\caption{Example table}
\\\toprule
\textbf{P} & \textbf{Text}
\\\toprule
\endfirsthead

\caption[]{Example table (continued)}
\\\toprule
\textbf{P} & \textbf{Text}
\\\toprule
\endhead

\multicolumn{2}{r}{\footnotesize continued on the next page}
\endfoot

\bottomrule
\endlastfoot

1 & \lipsum[1]\vspace{-\baselineskip}
\\*\midrule
2 & \lipsum[2]\vspace{-\baselineskip}
\\*\midrule
3 & \lipsum[3]\vspace{-\baselineskip}
\\*\midrule
4 & \lipsum[4]\vspace{-\baselineskip}
\end{longtable}

\begin{tikzpicture}[remember picture, overlay, color=red, line width=0.2pt]
\draw ([yshift=-18.9mm]current page.north west) -- ([yshift=-18.9mm]current page.north east);
\draw ([yshift=-19.9mm]current page.north west) -- ([yshift=-19.9mm]current page.north east);
\end{tikzpicture}%

\end{document}

enter image description hereenter image description here

Above document and images of its pages clearly show the problem (I've used TikZ to stress it).

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

It's the space after a \midrule; you can cancel it by introducing an explicit \addlinespace:

\begin{longtable}{rp{8cm}}
\caption{Example table}
\\\toprule
\textbf{P} & \textbf{Text}
\\\midrule[\heavyrulewidth]
\endfirsthead

\caption[]{Example table (continued)}
\\\toprule
\textbf{P} & \textbf{Text}
\\\midrule[\heavyrulewidth]
\addlinespace[0pt]
\endhead

\multicolumn{2}{r}{\footnotesize continued on the next page}
\endfoot

\bottomrule
\endlastfoot

1 & \lipsum*[1]
\\\midrule
2 & \lipsum*[2]
\\\midrule
3 & \lipsum*[3]
\\\midrule
4 & \lipsum*[4]
\end{longtable}

Notice that \midrule[\heavyrulewidth] is preferable to a \toprule in that position; \lipsum* avoids a final \par command, so that it's not necessary to backspace.

share|improve this answer
    
+1 Thank you! Adding \addlinespace[0pt] in head fixes the problem. Other remarks are also useful. –  przemoc Jul 18 '11 at 20:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.