longtable:hline 不显示在第一页

longtable:hline 不显示在第一页

表头并不\hline在第一页显示,如下图红线所示。

在此处输入图片描述

这是源代码。

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

如果我删除\endfirsthead,就会引发以下错误。

在此处输入图片描述

答案1

您应该将的内容head也添加到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}

在此处输入图片描述

笔记:该代码本身不会在新页面上重复标题。

答案2

放在:\\\hline之前\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}

在此处输入图片描述

相关内容