# Example for longtable package use

I am trying to use the longtable package:

\documentclass[12pt]{article}
\usepackage{longtable}
\begin{document}
\begin{longtable}{|c|c|c|c|c|c|}
\centering
\caption{$\chi^2$ - Test of UDP Packet Size Sample Measurements}
\hline
\textbf{Bin Interval Lower Bound} & \textbf{Bin Interval Upper Bound} & \textbf{Histogram Count} & \textbf{Expected Count} & \textbf{Cumulative Distribution} & \textbf{$\chi^2$ - Value}
\hline
\multicolumn{6}{c}
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
\textbf{Bin Interval Lower Bound} & \textbf{Bin Interval Upper Bound} & \textbf{Histogram Count} & \textbf{Expected Count} & \textbf{Cumulative Distribution} & \textbf{$\chi^2$ - Value}
\hline
\hline \multicolumn{6}{r}{\textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot

1000  & 1003,99 & 102   & 100   & 102   & 0,04 \\
1004  & 1007,99 & 105   & 100   & 207   & 0,25 \\
1008  & 1011,99 & 104   & 100   & 311   & 0,16 \\
1012  & 1015,99 & 104   & 100   & 415   & 0,16 \\

\label{Table1}
\end{longtable}
\end{document}


Unfortunately this isn't working. TeXstudio throws some errors such as "Misplaces \omit. \endhead"

Can anyone see what might be the cause of this issue?

• you need \\  after \caption and delete \centering – David Carlisle Jul 19 '18 at 8:18
• ok, did that. But the error remains. I have deleted \centering, but instead I have put \begin{center} before \begin{longtable} and ofc end{center} after \end{longtable} .. can it be that sth is wrong with {\tablename\ \thetable\ -- \textit{Continued from previous page}}\ , because I don't really understand this line. I have copied from an example – user503842 Jul 19 '18 at 9:02
• no \begin{center} around a longtable is always wrong (but doesn't generate an error) – David Carlisle Jul 19 '18 at 10:02

Anyway, this table can't fit between margins of a normal paper size. One has to rotate the column heads. Does this code compile normally for you?

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\usepackage{rotating}
\usepackage{longtable}
\usepackage{makecell}
\setlength{\extrarowheight}{2pt}

\begin{document}

\begin{longtable}{|c|c|c|c|c|c|}
\caption{$\chi^2$-Test of UDP Packet Size Sample Measurements}
\label{Table1}\\
\hline
\rothead{Bin Interval\\ Lower Bound} & \rothead{Bin Interval\\ Upper Bound} & \rothead{Histogram\\ Count} & \rothead{Expected\\ Count} & \rothead{Cumulative\\ Distribution} & \rothead{$\chi^2$-Value} \\
\hline
\multicolumn{6}{c}
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
\rothead{Bin Interval\\ Lower Bound} & \rothead{Bin Interval\\ Upper Bound} & \rothead{Histogram\\ Count} & \rothead{Expected\\ Count} & \rothead{Cumulative\\ Distribution} & \rothead{$\chi^2$-Value} \\
\hline
\hline \multicolumn{6}{r}{\textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
1000 & 1003,99 & 102 & 100 & 102 & 0,04 \\
1004 & 1007,99 & 105 & 100 & 207 & 0,25 \\
1008 & 1011,99 & 104 & 100 & 311 & 0,16 \\
1012 & 1015,99 & 104 & 100 & 415 & 0,16 \\
\end{longtable}

\end{document}


• it gives me undefined control sequence. \rothead – user503842 Jul 19 '18 at 10:08
• Do you have all the required packages installed? – Bernard Jul 19 '18 at 10:15
• yeah, sorry, I did not. But now I included everything, and it gives me option clash for package geometry. \usepackage for the \usepackage{rotating} – user503842 Jul 19 '18 at 10:16
• The option clash comes from geometry already loaded, without this option. It is only used to visualise the margins and see if there's an overflow into the margin. You may safely remove loafding geometry`. Should you want the framed option, you can pass it as an option in the document class anyway. – Bernard Jul 19 '18 at 10:20
• I just realized the following: My table actually continues along 4 pages. For some reason, the table is spaced a little bit more to the left on both the second and the fourth page! It is spaced more to the right for the first and the third page. Can you think of a reason for this? – user503842 Jul 29 '18 at 12:39