[Tex/LaTex] longtable in LaTeX too wide

longtablewidth

I am having problems with a longtable, it goes off the side of the page and any attempt to limit the width only seems to work on the first page. Here is a cut down version of my table

% Appendix B
\chapter{Elelments for the MetDB Retrieval}
\label{AppendixB}
\lhead{Appendix B. \emph{Elelments for the MetDB Retrieval}}
\chapter{Elelments for the MetDB Retrieval}
\label{AppendixB}
\lhead{Appendix B. \emph{Elelments for the MetDB Retrieval}}

\begin{center}
\begin{longtable}{|c|c|c|} %try definind the width here
\hline
\textbf{Element Name} & \textbf{Element Description} & \textbf{Units} \\
\hline
\endfirsthead
\hline
\textbf{Element Name} & \textbf{Element Description} & \textbf{Units} \\
\hline
\endhead
\hline

table entries...

\hline
%\end{tabular}
\caption{Elelments for the metDB retrieval}
\end{longtable}
\end{center}

Here is an image:

enter image description here

Any help on this subject would be nice!

Best Answer

Add

 \usepackage{array}

then you may use an extended preamble syntax.

Then replace

\begin{longtable}{|c|c|c|}

by

\begin{longtable}{|*{3}{>{\centering\arraybackslash}p{3cm}|}}

for 3 3cm wide columns, adjust the width to taste.

Related Question