需要中间休息一下

需要中间休息一下

我有一张很长的表格,它与两页重叠。我不想让它横屏。我需要表格在我的文档中竖屏显示。我遇到过类似的问题,并实施了使用 longtable 和 \* 来保持中间规则的建议,但不幸的是它们对我不起作用。名称列很大,其他三个只是数字列。我需要一张可读的表格,因为它很混乱。我是 Latex 的新手,我很感激任何能得到的建议。

 \documentclass[12pt,a4paper,oneside]{book}
\usepackage[bindingoffset=1.5cm, left=3cm, right=3cm, top=3cm, bottom=3cm]{geometry}
\usepackage{setspace}\doublespacing
\usepackage{multirow}
\usepackage{longtable}
 \usepackage{booktabs}
 \renewcommand{\arraystretch}{1.2}
\usepackage{tabularx}
\usepackage{graphicx}
\usepackage[section]{placeins}
\setlength{\arrayrulewidth}{1mm}
\setlength{\tabcolsep}{18pt}
\renewcommand{\arraystretch}{1.5}
\usepackage{dcolumn}
\usepackage{array}                                                                       
\begin{document} 
\begingroup
        \renewcommand{\arraystretch}{1.1}
        \begin{table}
        \caption{Results from Analysis}
        \begin{tabular}{p{0.6\textwidth-3\tabcolsep}p{0.27\textwidth-3\tabcolsep}p{0.23\textwidth-3\tabcolsep}p{0.25\textwidth-3\tabcolsep}} 
        \toprule
        Name & Significance & Group A & GroupB  \\
        \midrule
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 6.16E-05 & 35 & 18\\

       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX9 & 4.91E-04 & 25 & 12\\

       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 4.91E-04 & 25 & 12\\

      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.31E-03 & 20 & 9\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.55E-03 & 23 & 12\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 2.00E-03 & 17 & 7\\

        pXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXe & 2.41E-03 & 13 & 4\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 3.81E-03 & 8 & 1\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 4.77E-03 & 12 & 4\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 7.65E-03 & 19 & 11\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX& 1.13E-02 & 13 & 6\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.16E-02 & 23 & 16\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX& 1.20E-02 & 14 & 7\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.22E-02 & 21 & 14\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.26E-02 & 30 & 24\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX (C5) & 1.26E-02 & 19 & 12\\

        eXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.54E-02 & 9 & 3\\

        2XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.76E-02 & 10 & 4\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  & 1.92E-02 & 6 & 1\\

       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.92E-02 & 6 & 1\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.92E-02 & 6 & 1\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 2.55E-02 & 7 & 2\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 2.55E-02 & 7 & 2\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 2.62E-02 & 4 & 0\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 2.62E-02 & 4 & 0\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 2.62E-02 & 4 & 0\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 27 & 23\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX* & 3.25E-02 & 9 & 4\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 3.31E-02 & 16 & 11\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX0 & 3.37E-02 & 24 & 20\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 3.47E-02 & 14 & 9\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 3.52E-02 & 13 & 8\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 3.53E-02 & 12 & 7\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 4.19E-02 & 5 & 1\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 4.19E-02 & 5 & 1\\
        \bottomrule
        \end{tabular}
        \end{table}
        \endgroup
\end{document}

答案1

您的代码显示出几个错误。

例如,你调用了 package longtable,但你没有在代码中使用它。请参阅以下 MWE。

为了能够计算列长度,{p{0.6\textwidth-3\tabcolsep}您需要调用包calc。请参阅以下 MWE。

为了能够在姓名列中换行,您需要添加空格或允许使用连字符 ( \-),如下所示:

XXXXXXXXXXX XXXXXXXXX XXXXXXXXX XXXXXXXXX      & 6.16E-05 & 35 & 18\\
XXXXXXXXXXX XXXXXXXXX XXXXXXXXX XXXXXXXXX9     & 4.91E-04 & 25 & 12\\
XXXXXXXX XXXXXX XXXX XXXX XXXXXXXXXXXXXXXX     & 4.91E-04 & 25 & 12\\
XXXXXXXX\-XXXXXXXX\-XXXXXX\-XXXXXXXXX\-XXXXXXX & 1.31E-03 & 20 & 9\\

完成 MWE

\documentclass[12pt,a4paper,oneside]{book}
\usepackage[bindingoffset=1.5cm, left=3cm, right=3cm, top=3cm, bottom=3cm]{geometry}
\usepackage{setspace}\doublespacing
\usepackage{multirow}
\usepackage{longtable}
 \usepackage{booktabs}
 \renewcommand{\arraystretch}{1.2}   % <============== ?????????
\usepackage{graphicx}
\usepackage[section]{placeins}
\setlength{\arrayrulewidth}{1mm}
\setlength{\tabcolsep}{18pt}
\renewcommand{\arraystretch}{1.5}  % <============== ?????????
\usepackage{dcolumn}
\usepackage{array} 
\usepackage{calc}  % <==================================================


\begin{document} 
\begingroup
  \renewcommand{\arraystretch}{1.1}

  \begin{longtable}{p{0.6\textwidth-3\tabcolsep}p{0.27\textwidth-3\tabcolsep}p{0.23\textwidth-3\tabcolsep}p{0.25\textwidth-3\tabcolsep}} 
  \caption{Results from Analysis}\\
  \toprule
  Name & Significance & GroupA & GroupB  \\
  \midrule
\endfirsthead % <===============================================
  \toprule
  Name & Significance & GroupA & GroupB  \\
  \midrule
\endhead % <===============================================
XXXXXXXXXXX XXXXXXXXX XXXXXXXXX XXXXXXXXX      & 6.16E-05 & 35 & 18\\
XXXXXXXXXXX XXXXXXXXX XXXXXXXXX XXXXXXXXX9     & 4.91E-04 & 25 & 12\\
XXXXXXXX XXXXXX XXXX XXXX XXXXXXXXXXXXXXXX     & 4.91E-04 & 25 & 12\\
XXXXXXXX\-XXXXXXXX\-XXXXXX\-XXXXXXXXX\-XXXXXXX & 1.31E-03 & 20 & 9\\

        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.55E-03 & 23 & 12\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 2.00E-03 & 17 & 7\\
        pXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXe & 2.41E-03 & 13 & 4\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 3.81E-03 & 8 & 1\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 4.77E-03 & 12 & 4\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 7.65E-03 & 19 & 11\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX& 1.13E-02 & 13 & 6\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.16E-02 & 23 & 16\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX& 1.20E-02 & 14 & 7\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.22E-02 & 21 & 14\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.26E-02 & 30 & 24\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX (C5) & 1.26E-02 & 19 & 12\\
        eXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.54E-02 & 9 & 3\\
        2XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.76E-02 & 10 & 4\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  & 1.92E-02 & 6 & 1\\
       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.92E-02 & 6 & 1\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 1.92E-02 & 6 & 1\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 2.55E-02 & 7 & 2\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 2.55E-02 & 7 & 2\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 2.62E-02 & 4 & 0\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 2.62E-02 & 4 & 0\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 2.62E-02 & 4 & 0\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 27 & 23\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX* & 3.25E-02 & 9 & 4\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 3.31E-02 & 16 & 11\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX0 & 3.37E-02 & 24 & 20\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 3.47E-02 & 14 & 9\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 3.52E-02 & 13 & 8\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 3.53E-02 & 12 & 7\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 4.19E-02 & 5 & 1\\
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX & 4.19E-02 & 5 & 1\\
  \bottomrule
\end{longtable}
\endgroup
\end{document}

得到第一页:

第一页

相关内容