[Tex/LaTex] Setting widths in a longtable not working

longtabletableswidth

I want to create a longtable that spans several pages, with column widths set to cms by me:

\documentclass[12pt]{article}
\usepackage{longtable}
\usepackage{seqsplit}
\usepackage[a4paper,landscape,margin=1cm]{geometry}
\usepackage[utf8]{inputenc}

\begin{document}
\begin{longtable}{|p{3,53cm}|p{1,60cm}|p{0,80cm}|p{1,11cm}|p{1,16cm}|p{0,94cm}|p{1,11cm}|p{0,96cm}|p{0,57cm}|p{1,21cm}|p{1,04cm}|p{1,32cm}|p{1,26cm}|p{0,99cm}|p{1,27cm}|p{2,71cm}|p{1,41cm}|}
\hline
\textbf{ \seqsplit{one} } & \textbf{ \seqsplit{tow} } & \textbf{ \seqsplit{three} } & \textbf{ \seqsplit{four} } & \textbf{ \seqsplit{five} } & \textbf{ \seqsplit{six} } & \textbf{ \seqsplit{seven} } & \textbf{ \seqsplit{eight} } & \textbf{ \seqsplit{nine} } & \textbf{ \seqsplit{ten} } & \textbf{ \seqsplit{eleven} } & \textbf{ \seqsplit{twelve} } & \textbf{ \seqsplit{thirteen} } & \textbf{ \seqsplit{fourteen} } & \textbf{ \seqsplit{fifteen} } & \textbf{ \seqsplit{sixteen} } & \textbf{ \seqsplit{seventeen} } \\
\hline
\endhead
\hline
\seqsplit{aaaaaaaaaaaaaaaaaaaaaaaa@gmail.com} & \seqsplit{Jjjjjj} & \seqsplit{Ccccccccl} & \seqsplit{ttrrw} & \seqsplit{xxxxxxxx\ 83} & \seqsplit{ooooooo} & \seqsplit{2222\ rrrrrrr\ oo\ trr\ bbbbb\ bbbbbbb\ ttttttP\ -\ 2111\ eeeedsee\ prrr\ vvv\ ll\ eeeirrrr\ xxrrrttt} & \seqsplit{20/02/2011\ 11:39:37} & \seqsplit{0} & \seqsplit{0,00} & \seqsplit{0,00} & \seqsplit{07/07/2011\ 09:00:00} & \seqsplit{14/07/2013\ 11:00:00} & \seqsplit{700} & \seqsplit{4} & \seqsplit{xxxxooowwwaaaaaaaaapaaa/srsssssss} & \seqsplit{50,00} \hline
\end{longtable}
\end{document}

The problem with this tex is that I have seventeen columns, and the seventeenth appears out of the landscape page. However if we add the widths of the columns, is less than 23 cms. What's going on here?

Best Answer

You observe that the widths assigned to the columns add up to less than the width of the text block (which has width \textwidth), yet the table is too wide to fit into the text block. This is happening because there's also whitespace between the columns, in the amount of 2\tabcolsep. The default value of \tabcolsep is 6pt. Expressed in millimeters, the default amount of intercolumn whitespace comes to roughly 4.2mm. Since you have 17 columns, this makes for more than 7 cm of extra horizontal space.

What to do? You can do one or both of the following: (i) reduce some of the column widths, and (ii) reduce the amount of intercolumn whitespace via a \renewcommand instruction, e.g., \renewcommand\tabcolsep{4pt}. A combination of these instructions should get you to where you want to be.