使用 longtable 时页面不会中断

使用 longtable 时页面不会中断

我知道这个问题已经以多种形式被问到,但从我目前读过的回答和长表文档来看,我搞不清楚我哪里做错了。我希望表格在其余文本中断的地方自然中断。目前,表格比我设置的底部边距向下移动得更远,并与页码重叠。

我尝试使用 \pagebreak 和 \newpage,但无济于事。还尝试将 \hline 粘贴到我通常将 \ 放在行末的位置,但仍然没有成功。

任何帮助都值得感激,谢谢!

梅威瑟:

\begin{table}

\begin{flushleft}
\noindent \caption{table title}
\end{flushleft} 

\footnotesize
\begin{longtable}[h]{p{0.15\linewidth}p{0.6\linewidth}p{0.15\linewidth}}
\toprule
\textbf{Factor} & \textbf{Roles} & \textbf{References}  \endhead
\midrule 
\multicolumn{3}{l}{\textit{section1}} \\
\midrule
ATX & 
Roles \newline
Role2 &
Refs here \\
\midrule
CXCLs & 
Roles \newline
Role2 &
Refs here \\
\midrule
Endothelin-2 & 
Roles \newline
Role2 &
Refs here \\
\midrule
IGF-1 & 
Roles \newline
Role2 &
Refs here \\
\midrule
Laminin-2 & 
Roles \newline
Role2 &
Refs here \\
\midrule
PDGF-A & 
Roles \newline
Role2 &
Refs here \\
\midrule
Retinoic Acid & 
Roles \newline
Role2 &
Refs here \\
\midrule
Sema3F & 
Roles \newline
Role2 &
Refs here \\
\midrule 
\multicolumn{3}{l}{\textit{section2}} \\
\midrule
BMPs & 
Roles \newline
Role2 &
Refs here \\
\midrule
Hyaluronan & 
Roles \newline
Role2 &
Refs here \\
\midrule
LINGO-1 & 
Roles \newline
Role2 &
Refs here \\
\midrule
Notch-1 & 
Roles \newline
Role2 &
Refs here \\
\midrule
Sema3A & 
Roles \newline
Role2 &
Refs here \\
\multicolumn{3}{l}{\textit{section3}} \\
\midrule
Fibronectin & 
Roles \newline
Role2 &
Refs here \\
\midrule
FGF &
Roles \newline
Role2 &
Refs here \\
\midrule
GPR17 & 
Roles \newline
Role2 &
Refs here \\
\midrule
Netrin-1 & 
Roles \newline
Role2 &
Refs here \\
\midrule
PSA-NCAM & 
Roles \newline
Role2 &
Refs here \\
\midrule
S1P & 
Roles \newline
Role2 &
Refs here \\
\midrule
Wnt/$\beta$-catenin & 
Roles \newline
Role2 &
Refs here \\
\bottomrule
\end{longtable}
\end{table}

答案1

除了已经给出的建议之外——不要将longtable环境封装在table环境中;正确使用\caption命令;不要提供无用的[h]定位说明符(因为长表不会浮动)——您还应该更好地利用机制longtable——特别是\endfirsthead\endhead\endfoot\endlastfoot——为表格材料提供一些必要的结构。另外,不要过度使用水平线,因为(垂直)空白同样有效。

在此处输入图片描述

...

在此处输入图片描述

\documentclass{article}
\usepackage{longtable,booktabs}
% Set up two length variables to store widths of 1st and 3rd columns
\newlength\mylena
\settowidth{\mylena}{Endothelin-2}
\newlength\mylenb
\settowidth{\mylenb}{\textbf{References}} 

\begin{document}

\begin{longtable}{@{} p{\mylena}p{0.6\linewidth}p{\mylenb}@{}}

%% Define headers and footers
\caption{Table title}\\
\toprule
\textbf{Factor} & \textbf{Roles} & \textbf{References} \\ \midrule 
\endfirsthead

\multicolumn{3}{@{}l}{Table \thetable, continued}\\
\addlinespace
\toprule
\textbf{Factor} & \textbf{Roles} & \textbf{References} \\ \midrule 
\endhead

\midrule
\multicolumn{3}{r@{}}{\em\small (continued on next page)}\\
\endfoot

\bottomrule
\endlastfoot

%% Body of table
\multicolumn{3}{@{}l}{\textit{Section 1}} \\
\cmidrule(r){1-1}  % no need to extend this line across full width of table
ATX & 
Roles \newline
Role2 &
Refs here \\
\addlinespace
CXCLs & 
Roles \newline
Role2 &
Refs here \\
\addlinespace
Endothelin-2 & 
Roles \newline
Role2 &
Refs here \\
\addlinespace
IGF-1 & 
Roles \newline
Role2 &
Refs here \\
\addlinespace
Laminin-2 & 
Roles \newline
Role2 &
Refs here \\
\addlinespace
PDGF-A & 
Roles \newline
Role2 &
Refs here \\
\addlinespace
Retinoic Acid & 
Roles \newline
Role2 &
Refs here \\
\addlinespace
Sema3F & 
Roles \newline
Role2 &
Refs here \\
\midrule 
\multicolumn{3}{@{}l}{\textit{Section 2}} \\
\cmidrule(r){1-1}
BMPs & 
Roles \newline
Role2 &
Refs here \\
\addlinespace
Hyaluronan & 
Roles \newline
Role2 &
Refs here \\
\addlinespace
LINGO-1 & 
Roles \newline
Role2 &
Refs here \\
\addlinespace
Notch-1 & 
Roles \newline
Role2 &
Refs here \\
\addlinespace
Sema3A & 
Roles \newline
Role2 &
Refs here \\
\midrule
\multicolumn{3}{@{}l}{\textit{Section 3}} \\
\cmidrule(r){1-1}
Fibronectin & 
Roles \newline
Role2 &
Refs here \\
\addlinespace
FGF &
Roles \newline
Role2 &
Refs here \\
\addlinespace
GPR17 & 
Roles \newline
Role2 &
Refs here \\
\addlinespace
Netrin-1 & 
Roles \newline
Role2 &
Refs here \\
\addlinespace
PSA-NCAM & 
Roles \newline
Role2 &
Refs here \\
\addlinespace
S1P & 
Roles \newline
Role2 &
Refs here \\
\addlinespace
Wnt\slash \mbox{$\beta$-catenin} & 
Roles \newline
Role2 &
Refs here \\

\end{longtable}
\end{document}

相关内容