[Tex/LaTex] Example for longtable package use

longtable

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
    \endfirsthead
    \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
    \endhead
    \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?

Best Answer

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}
\renewcommand{\theadfont}{\normalsize\boldmath\bfseries}
\settowidth{\rotheadsize}{\bfseries Upper Bound}
\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
    \endfirsthead
    \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
    \endhead
    \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} 

enter image description here

Related Question