设置 longtable 以适合页面宽度

设置 longtable 以适合页面宽度

我想设置一个长表以正确适应页面宽度。从现在起,我遇到了这种情况:

长表宽度错误

相关的 tex 代码是:

\usepackage{array}
\usepackage{multirow}
\usepackage{longtable}
\usepackage[tableposition=below]{caption}

[...]

We now present a table that summarises the possible scenarios that can happen in the overlap zone.
{\small \begin{center}
\begin{longtable}{|c|c|c|}

\hline \textbf{Type of movement in the overlap zone} & \textbf{State of the object in camera 1} & \textbf{State of the object in camera 2}  \\ \hline
\endfirsthead

\hline \textbf{Type of movement in the overlap zone} & \textbf{State of the object in camera 1} & \textbf{State of the object in camera 2}  \\ \hline
\endhead

\hline
\caption{Table title.}
\endfoot

\caption{Table title.}
\endlastfoot

Object moving from camera 1 to camera 2 & Object will eventually be in the \emph{exiting} state and the be \emph{deleted} & Object will be recognised as a \emph{new} object, then become \emph{to be classified} and eventually \emph{classified} \\ \hline
\end{longtable}  
\end{center}
}

我该如何修复这个错误?

答案1

tabu与其环境一起使用

\begin{longtabu} to \textwidth {|X|X|X|}
\end{longtabu}

有关更多信息,请参阅 的文档tabu

答案2

\begin{center}
\begin{longtable}{|c|c|c|}

由于表行始终是全宽,因此环境center不会产生影响。longtable

文档longtable确实给出了如何制作全宽表的示例:

\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{@{\extracolsep{\fill}}|c|c|c|@{}}

...

答案3

一个古老的解决方案是可能的表列:这是带有的 MWE booktabs,它提供了更好的规则\hline(我建议至少阅读第 2 章texdoc booktabs

\documentclass{article}
\usepackage{ltablex,booktabs}
\begin{document}
\begin{tabularx}{\textwidth}{XXX}
\textbf{Type of movement in the overlap zone} & \textbf{State of the object in camera 1} & \textbf{State of the object in camera 2}  \\ \toprule
\endhead
\caption{Table title.}
\endfoot
Object moving from camera 1 to camera 2 & Object will eventually be in the \emph{exiting} state and the be \emph{deleted} 
& 
Object will be recognised as a \emph{new} object, then become \emph{to be classified} and eventually \emph{classified}
\end{tabularx}
\end{document}

在此处输入图片描述

相关内容