longtable 包使用示例

longtable 包使用示例

我正在尝试使用 longtable 包:

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

不幸的是,这不起作用。TeXstudio 会抛出一些错误,例如“放错 \omit。\endhead”

谁能看到造成该问题的原因是什么?

答案1

无论如何,此表格无法放入正常纸张大小的边距内。必须旋转列标题。此代码对您来说可以正常编译吗?

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

在此处输入图片描述

相关内容