我想设置一个长表以正确适应页面宽度。从现在起,我遇到了这种情况:
相关的 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}