# [texhax] Problem with column width

Samuel Lelievre samuel.lelievre.tex at free.fr
Mon May 21 22:13:20 CEST 2007

Kenneth Cabrera wrote:

> Hi TeX users:
>
> Why do I obtain a table with the last column wider than the rest?
> Thank you for your help.
>
> I am attaching the file code.
>
> Thank you for your help.
>
> --
> Kenneth Roy Cabrera Torres
> Cel 315 504 9339

Hi Kenneth,

but since there is a multicolumn on the last 4 columns, the last
of them is expanded to match the length needed for the entry in
multicolumn.

If you make the multicolumn entry shorter (eg by splitting it in
two lines), this problem will disappear.  (cf. code below).

I don't know a way to have the extra space spread evenly among
the last four columns (but I'd be interested in knowing!).

Apart from that, you might be interested in the package booktabs
for professional-looking rules (horizontal lines) in tables.
The package longtable is also useful when your tables need to be
allowed to spread over a page break (I use it by default for any
table that stands on its own, i.e. not included in a paragraph).

Best,
Samuel

----- one way to avoid extra spacing in last column -----

\documentclass{article}
\usepackage[spanish]{babel}
\usepackage[latin1]{inputenc}
\usepackage{graphicx}
\usepackage{amsmath,amssymb,latexsym,amsthm}
\usepackage{fancyvrb}
\usepackage[margin=2cm]{geometry}

\setlength{\parindent}{0pt}
\setlength{\parskip}{1.5ex plus 0.5ex minus 0.2ex}

\begin{document}

\begin{table}[ht]
\begin{center}
\caption{Tabla X}\label{tb}
\vspace{2ex}
\begin{tabular}{ccccccc}
\hline
\multicolumn{3}{c}{} &
\multicolumn{4}{c}{N\'umero de viajes} \\
Tipo     & Capacidad     & N\'umero           &
\multicolumn{4}{c}{diarios en la ruta} \\
\cline{4-7}
de avi\'on & (pasajeros) & de aviones         &  1 & 2 & 3 & 4 \\
\hline
1        & 50            & 5                  & 3  & 2 & 2 & 1 \\
2        & 30            & 8                  & 4  & 3 & 3 & 2 \\
3        & 20            & 10                 & 5  & 5 & 4 & 2 \\
\hline
\multicolumn{3}{l}{N\'umero de clientes diarios} &
1000 & 2000 & 900 & 1200 \\
\hline
\end{tabular}
\end{center}
\end{table}

\end{document}

----- end of modified example file -----

Kenneth Cabrera wrote:

>Hi TeX users:
>
>Why do I obtain a table with the last column wider than the rest?
>
>I am attaching the file code.
>
>
>--
>Kenneth Roy Cabrera Torres
>Cel 315 504 9339