# table overflows the page

I use \documentclass[a4paper,14pt]{report} and the longtable package. Also I have

\usepackage[left=3cm,right=1cm,top=2cm,bottom=2cm,bindingoffset=0cm]{geometry}


in the preamble.

I have some problems with the table:

\begin{longtable}{|p{50mm}|p{50mm}|p{50mm}|}


(I've tried {|p{0.1\textwidth}|p{0.2\textwidth}|p{0.2\textwidth}|}) but it makes no sense).

I'm very new to LaTeX and all help will be appreciated! What's wrong?

-
There is no 14pt option in the report document class. –  Andrey Vihrov May 22 '11 at 14:44
tnx, you're right. I have \usepackage[14pt]{extsizes} –  Fluffy May 22 '11 at 14:59

Your line width is 17cm: A4 paper is 21cm wide and you want margins 3cm wide on the left and 1cm wide on the right. With the shown input

\begin{longtable}{|p{50mm}|p{50mm}|p{50mm}|}


you don't get an overfull box. Indeed the width of the table is

150mm + 6\tabcolsep + 4*0.4pt = 163.215mm

as \tabcolsep is usually 6pt and the vertical rules are 0.4pt wide. But your example is not what you show, since it' obvious that the second column is much wider than the first one (I suspect 100mm instead of 50). If the longtable preamble is

\begin{longtable}{|p{50mm}|p{100mm}|p{100mm}|}


it's clear that the table will not fit in the line width. If you need a table where the second and third columns are twice as wide as the first one, you can do

\begin{longtable}{|p{\dimexpr.2\textwidth-2\tabcolsep-0.8pt}|
p{\dimexpr.4\textwidth-2\tabcolsep-0.4pt}|
p{\dimexpr.4\textwidth-2\tabcolsep-0.4pt}|}


Actually the first column is not exactly half of the second (it's shortened by 0.4pt), but this shouln't be a problem. This table will occupy exactly the line width. Just remember that LaTeX adds \tabcolsep at both sides of each column.

You can play with this measures, as long as the sum of the factors to \textwidth is 1, or try with Herbert's trick if the first column's width must be computed automatically.

Wide and long tables often require manual intervention.

-

try \begin{longtable}{|l|p{50mm}|p{50mm|} or use package ltxtable

\usepackage{ltxtable}
\usepackage{filecontents}
...
\begin{filecontents}{longtab.tex}
\begin{longtable}{|l|X|X|}
.. table contents ...
\end{longtable}
\end{filecontents}

\LTXtable{\linewidth}{longtab}
...


With package filecontents you are able to overwrite the external file longtab.tex, which maybe of any other name

-