1

I am really new to LaTeX and I am using the following codes to make a long table cross pages:

\documentclass[12pt,letterpaper]{report}

\usepackage{multirow}

\usepackage{longtable}

\usepackage{slashbox}

\begin{document}

\begin{center}

\begin{longtable}{|c|c|c|c|c|c|c|c}


\caption{A table} \\\hline

\backslashbox[-1cm][0]{$c$}{$N_1$}& 0.01    & 0.02    & 0.03    & 0.04    & 0.05    & 0.06    & \multicolumn{1}{l|}{0.07}    \\ \hline

$c_1$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \\ \hline

$c_2$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \\ \hline

$c_3$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \\ \hline

$c_4$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \\ \hline

$c_5$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \\ \hline

$c_6$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \\ \hline

$c_7$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \\ \hline

$c_8$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \\ \hline

$c_9$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0011}  \\ \hline

$c_{10}$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0016}  \\ \hline

$c_{11}$ & 0.0033  & 0.0025  & 0.0019  & 0.0013  & 0.0008  & 0.0003  & \multicolumn{1}{l|}{0.0005}  \\ \hline

$c_{12}$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0006}  \\ \hline

$c_{13}$& 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \\ \hline

$c_{14}$ & 0.0095  & 0.0071  & 0.0053  & 0.0038  & 0.0023  & 0.0008  & \multicolumn{1}{l|}{0.0000}  \\ \hline

$c_{15}$ & -0.0004 & -0.0092 & -0.0114 & -0.0147 & -0.0179 & -0.0211 & \multicolumn{1}{l|}{-0.0234} \\ \hline

$c_{16}$& 0.0001  & -0.0036 & -0.0065 & -0.0090 & -0.0114 & -0.0139 & \multicolumn{1}{l|}{-0.0155} \\ \hline

$c_{17}$ & 0.0000  & -0.0014 & -0.0035 & -0.0081 & -0.0127 & -0.0174 & \multicolumn{1}{l|}{-0.0206} \\ \hline

$c_{18}$ & 0.0000  & 0.0000  & -0.0016 & -0.0075 & -0.0133 & -0.0192 & \multicolumn{1}{l|}{-0.0232} \\ \hline

$c_{19}$ & 0.0000  & -0.0001 & -0.0051 & -0.0051 & -0.0051 & -0.0051 & \multicolumn{1}{l|}{-0.0052} \\ \hline

$c_{20}$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \\ \hline

\backslashbox[-1cm][0]{$c$}{$N_1$}& 0.08    & 0.09    & 0.1     & 0.11    & 0.12    & 0.13    & \multicolumn{1}{l|}{0.14}    \\ \hline

$c_1$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \\ \hline

$c_2$& 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \\ \hline

$c_3$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \\ \hline

$c_4$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \\ \hline

$c_5$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \\ \hline

 \backslashbox[-1cm][0]{$c$}{$N_1$}& 0.15    & 0.16    & 0.17    & 0.18    & 0.19    & 0.2     &                               \\ \cline{1-7}
$c_1$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \\ \cline{1-7}

$c_2$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \\ \cline{1-7}

$c_3$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \\ \cline{1-7}

$c_4$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \\ \cline{1-7}

$c_5$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \\ \cline{1-7}

$c_6$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \\ \cline{1-7}

$c_7$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \\ \cline{1-7} 

$c_8$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \\ \cline{1-7}

$c_9$  & 0.0077  & 0.0075  & 0.0073  & 0.0072  & 0.0070  & 0.0068  &                              \\ \cline{1-7}

$c_{10}$ & 0.0046  & 0.0047  & 0.0047  & 0.0047  & 0.0048  & 0.0048  &                              \\ \cline{1-7}

$c_{11}$ & -0.0003 & -0.0007 & -0.0011 & -0.0015 & -0.0019 & -0.0023 &                              \\\cline{1-7}

$c_{12}$& 0.0019  & 0.0016  & 0.0013  & 0.0009  & 0.0006  & 0.0003  &                              \\ \cline{1-7}

$c_{13}$& 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \\ \cline{1-7}

$c_{14}$& -0.0070 & -0.0080 & -0.0091 & -0.0102 & -0.0113 & -0.0124 &                              \\ \cline{1-7}



\end{longtable}

\end{center}

\end{document}

However for the first row on the second page, the upper horizontal border is missing and it seems to only stay at the previous page like this:enter image description here enter image description here

I am guessing it is because I use \cline for some of the rows but I don't know how to fix it. Thanks in advance for you help :).

2
  • slashbox is a really old package.
    – user31729
    Apr 7, 2015 at 20:41
  • Apart from my answer: I suggest to split this huge table in two separate longtables, one with 8 columns and the other one with 7 columns
    – user31729
    Apr 7, 2015 at 20:56

1 Answer 1

1

Use the commands \endfirsthead and \endhead from longtable package to solve this issue (however, this is not failsafe)

As it stands, the number of table columns is reduced by one in the lower part of the first page and for the rest which should appear on the second page, so \cline{1-7} is the correct form for horizontal lines there.

\endfirsthead

\cline{1-7}
\endhead

will first provide the \hline for the first head (i.e. the table header on the first page.) and afterwards it's changed to \cline{1-7} for any following header on the remaining page(s).

This procedure requires finetuning!

\documentclass[12pt,letterpaper]{report}

\usepackage{multirow}

\usepackage{longtable}

\usepackage{slashbox}

\begin{document}

\begin{center}
\begin{longtable}{|*{7}{c|}c} % Shorter form (easier to handle)
%\begin{longtable}{|c|c|c|c|c|c|c|c}

\endfirsthead

\cline{1-7}
\endhead
\caption{A table} \tabularnewline\hline

\backslashbox[-1cm][0]{$c$}{$N_1$}& 0.01    & 0.02    & 0.03    & 0.04    & 0.05    & 0.06    & \multicolumn{1}{l|}{0.07}    \tabularnewline \hline

$c_1$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \tabularnewline \hline

$c_2$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \tabularnewline \hline

$c_3$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \tabularnewline \hline

$c_4$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \tabularnewline \hline

$c_5$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \tabularnewline \hline

$c_6$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \tabularnewline \hline

$c_7$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \tabularnewline \hline

$c_8$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \tabularnewline \hline

$c_9$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0011}  \tabularnewline \hline

$c_{10}$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0016}  \tabularnewline \hline

$c_{11}$ & 0.0033  & 0.0025  & 0.0019  & 0.0013  & 0.0008  & 0.0003  & \multicolumn{1}{l|}{0.0005}  \tabularnewline \hline

$c_{12}$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0006}  \tabularnewline \hline

$c_{13}$& 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \tabularnewline \hline

$c_{14}$ & 0.0095  & 0.0071  & 0.0053  & 0.0038  & 0.0023  & 0.0008  & \multicolumn{1}{l|}{0.0000}  \tabularnewline \hline

$c_{15}$ & -0.0004 & -0.0092 & -0.0114 & -0.0147 & -0.0179 & -0.0211 & \multicolumn{1}{l|}{-0.0234} \tabularnewline \hline

$c_{16}$& 0.0001  & -0.0036 & -0.0065 & -0.0090 & -0.0114 & -0.0139 & \multicolumn{1}{l|}{-0.0155} \tabularnewline \hline

$c_{17}$ & 0.0000  & -0.0014 & -0.0035 & -0.0081 & -0.0127 & -0.0174 & \multicolumn{1}{l|}{-0.0206} \tabularnewline \hline

$c_{18}$ & 0.0000  & 0.0000  & -0.0016 & -0.0075 & -0.0133 & -0.0192 & \multicolumn{1}{l|}{-0.0232} \tabularnewline \hline

$c_{19}$ & 0.0000  & -0.0001 & -0.0051 & -0.0051 & -0.0051 & -0.0051 & \multicolumn{1}{l|}{-0.0052} \tabularnewline \hline

$c_{20}$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \tabularnewline \hline

\backslashbox[-1cm][0]{$c$}{$N_1$}& 0.08    & 0.09    & 0.1     & 0.11    & 0.12    & 0.13    & \multicolumn{1}{l|}{0.14}    \tabularnewline \hline

$c_1$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \tabularnewline \hline

$c_2$& 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \tabularnewline \hline

$c_3$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \tabularnewline \hline

$c_4$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \tabularnewline \hline

$c_5$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & \multicolumn{1}{l|}{0.0000}  \tabularnewline \hline

 \backslashbox[-1cm][0]{$c$}{$N_1$}& 0.15    & 0.16    & 0.17    & 0.18    & 0.19    & 0.2     &                               \tabularnewline \cline{1-7}
$c_1$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \tabularnewline \cline{1-7}

$c_2$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \tabularnewline \cline{1-7}

$c_3$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \tabularnewline \cline{1-7}

$c_4$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \tabularnewline \cline{1-7}

$c_5$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \tabularnewline \cline{1-7}

$c_6$ & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \tabularnewline \cline{1-7}

$c_7$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \tabularnewline \cline{1-7} 

$c_8$  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \tabularnewline \cline{1-7}

$c_9$  & 0.0077  & 0.0075  & 0.0073  & 0.0072  & 0.0070  & 0.0068  &                              \tabularnewline \cline{1-7}

$c_{10}$ & 0.0046  & 0.0047  & 0.0047  & 0.0047  & 0.0048  & 0.0048  &                              \tabularnewline \cline{1-7}

$c_{11}$ & -0.0003 & -0.0007 & -0.0011 & -0.0015 & -0.0019 & -0.0023 &                              \tabularnewline\cline{1-7}

$c_{12}$& 0.0019  & 0.0016  & 0.0013  & 0.0009  & 0.0006  & 0.0003  &                              \tabularnewline \cline{1-7}

$c_{13}$& 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  & 0.0000  &                              \tabularnewline \cline{1-7}

$c_{14}$& -0.0070 & -0.0080 & -0.0091 & -0.0102 & -0.0113 & -0.0124 &                              \tabularnewline \cline{1-7}



\end{longtable}

\end{center}

\end{document}

enter image description here

2
  • No comments on the various lines in this table please ;-) That's another issue ;-)
    – user31729
    Apr 7, 2015 at 20:52
  • @JennyLiang: You're welcome. Happy TeXing!
    – user31729
    Apr 7, 2015 at 21:02

You must log in to answer this question.

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