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 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!

share|improve this question

migrated from stackoverflow.com Jul 26 '12 at 18:12

This question came from our site for professional and enthusiast programmers.

    
Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. –  Werner Jul 26 '12 at 18:14

2 Answers 2

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.

share|improve this answer

AFAIK, you cannot limit or otherwise specify the width of centered columns. You have to use justified columns (that is, "p") to accomplish this, as in "p{3cm}".

See also here.

share|improve this answer

Your Answer

 
discard

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