Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to set a longtable to fit correctly the page-witdh. From now, I've this situation:

longtable-width-error

and the related tex code is:

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

How can I fix the error?

share|improve this question
    
Welcome to TeX.sx! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. –  Papiro Apr 23 '13 at 14:53
add comment

3 Answers

up vote 3 down vote accepted

Use the tabu with its environment

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

For more information, see the documentation of tabu.

share|improve this answer
    
Thank you so much, now it works fine. Just another question: how can I set padding values for the cells? –  vdenotaris Apr 23 '13 at 14:57
    
I don't know, what you mean exactly by "padding values" (English is not my first language). –  Toscho Apr 23 '13 at 14:58
    
I mean the distance between the borders (top, right, bottom and left) and the text inside a cell. –  vdenotaris Apr 23 '13 at 14:59
1  
The horizontal space can be controlled via options to the X columns or usually via @{…}. The vertical space can be controlled via \tabulinesep and \extrarowsep (see the documentation). –  Toscho Apr 23 '13 at 15:09
add comment
 \begin{center}
\begin{longtable}{|c|c|c|}

the center environment has no affect on longtable as the table rows are always full width.

The longtable documentation does give an example of this:

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

...

share|improve this answer
add comment

an ancient solution is possible with the package ltablex: Here is a MWE with booktabs, which provides better rules then \hline (I recommend to read at least chapter 2 from 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}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.