1

table head and \hline do not display on the first page, as shown the red line below.

enter image description here

Here is the source code.

\documentclass[twoside,12pt]{article}
\usepackage{longtable}

\begin{document}

\begin{longtable}{|c|c|r|r|r|r|r|r|r|l|}
    \caption{The throughput improvements achieved by network coding in Toulouse}
    \label{table:throughput improvement 2}
    \endfirsthead
    \hline
    line1   &   line2   &   $t_1$       &   $t_{12}$    &   $t_2$       &   $r$(\%)&    $D$(GB)&    $D_{nc}(GB)$&$G_t$(\%)&Station\\    % table head
    \hline
    \endhead % all the lines above this will be repeated on every page
    \hline
    \endfoot %  to appear at the bottom of each page
    10  &   2       &   0:22:00 &   9:46:00 &   2:00:00 &   80.49   &   159.18  &   302.25  &   89.88   &   Cours Dillon    \\
    10  &   109 &   1:19:00 &   8:55:00 &   1:40:00 &   74.93   &   188.48  &   319.09  &   69.3    &   Malepère    \\
    % more data is here
\end{longtable}

\end{document}

If I remove \endfirsthead, it raised the following error.

enter image description here

3
  • Put \\\hline before \endfirsthead – Ulrike Fischer Feb 3 '17 at 10:24
  • @UlrikeFischer, thx but it doesn't work:-( The result is totally the same. – SparkAndShine Feb 3 '17 at 10:39
  • Works fine for me. See below. – Ulrike Fischer Feb 3 '17 at 10:43
1

You should add content of the head also to the firsthead:

\documentclass[twoside,12pt]{article}
\usepackage{longtable}

\begin{document}
    \begin{longtable}{|c|c|r|r|r|r|r|r|r|l|}
    \caption{The throughput improvements achieved by network coding in Toulouse}
    \label{table:throughput improvement 2}\\ %<-- added
\hline%<-- added
line1 & line2 & $t_1$ & $t_{12}$ & $t_2$  & $r$(\%) & $D$(GB) & $D_{nc}(GB)$ & $G_t$(\%) & Station\\  %<-- added
\hline%<-- added
    \endfirsthead
    \hline
    line1   &   line2   &   $t_1$       &   $t_{12}$    &   $t_2$       &   $r$(\%)&    $D$(GB)&    $D_{nc}(GB)$&$G_t$(\%)&Station\\    % table head
    \hline
    \endhead % all the lines above this will be repeated on every page
    \hline
    \endfoot %  to appear at the bottom of each page
    10  &   2       &   0:22:00 &   9:46:00 &   2:00:00 &   80.49   &   159.18  &   302.25  &   89.88   &   Cours Dillon    \\
    10  &   109 &   1:19:00 &   8:55:00 &   1:40:00 &   74.93   &   188.48  &   319.09  &   69.3    &   Malepère    \\
% more data is here
    \end{longtable}
\end{document}

enter image description here

Note: The code, as it is, will not repeat caption on the new page.

1
  • thx a lot. It works perfectly. – SparkAndShine Feb 3 '17 at 10:58
1

Put \\\hline before \endfirsthead:

\documentclass[twoside,12pt]{article}
\usepackage{longtable}

\begin{document}

\begin{longtable}{|c|c|r|r|r|r|r|r|r|l|}
    \caption{The throughput improvements achieved by network coding in Toulouse}
    \label{table:throughput improvement 2}
    \\\hline
    \endfirsthead
    \hline
    line1   &   line2   &   $t_1$       &   $t_{12}$    &   $t_2$       &   $r$(\%)&    $D$(GB)&    $D_{nc}(GB)$&$G_t$(\%)&Station\\    % table head
    \hline
    \endhead % all the lines above this will be repeated on every page
    \hline
    \endfoot %  to appear at the bottom of each page
    10  &   2       &   0:22:00 &   9:46:00 &   2:00:00 &   80.49   &   159.18  &   302.25  &   89.88   &   Cours Dillon    \\
    10  &   109 &   1:19:00 &   8:55:00 &   1:40:00 &   74.93   &   188.48  &   319.09  &   69.3    &   Malepère    \\
    % more data is here
\end{longtable}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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