longtable caption

534 views
Skip to first unread message

Dai

unread,
Jul 10, 2008, 5:11:01 AM7/10/08
to LaTeX Users Group
The command sequence for producing a table is as follows:

\begin{center}
\begin{longtable}{ccc|ccc}
\toprule
.
.
.
\bottomrule
\caption[short caption]{long caption whichgoesonforseverallines...}
\endlongtable
\label{}
\end{center}

When the file is compiled, the caption is only as wide as the number
of columns in the table, which makes it spill over onto another page,
which I think is unnecessary as well as looking ugly. Anyone know a
fix for this? Essentially I want my longtable caption to be the same
width as \textwidth.

Cheers

Werner Grundlingh

unread,
Jul 10, 2008, 5:02:44 PM7/10/08
to LaTeX Users Group
This is the way you should attempt making such tables then... compile
the following minimal example to see what I'm talking about:

\documentclass{article}

\usepackage{lipsum}
\usepackage{longtable}

\begin{document}

\lipsum[1]

\begin{table}[htb]
\begin{longtable}{ccc|ccc}
\hline
line & 1 & 2 & 3 & 4 & 5 \\
line & 1 & 2 & 3 & 4 & 5 \\
line & 1 & 2 & 3 & 4 & 5 \\
line & 1 & 2 & 3 & 4 & 5 \\
line & 1 & 2 & 3 & 4 & 5 \\
line & 1 & 2 & 3 & 4 & 5 \\
line & 1 & 2 & 3 & 4 & 5 \\
line & 1 & 2 & 3 & 4 & 5 \\
line & 1 & 2 & 3 & 4 & 5 \\
line & 1 & 2 & 3 & 4 & 5 \\
line & 1 & 2 & 3 & 4 & 5 \\
\hline
\end{longtable}
\caption[short caption]{\lipsum[2]}
\label{tester}
\end{table}

\lipsum[3]

\end{document}

Is there any particular reason why you do not enclose you longtable
environment within a table environment?

Werner

Dai

unread,
Jul 12, 2008, 4:33:12 AM7/12/08
to LaTeX Users Group
I found putting longtable inside the table environment negated its
function and the results didn't split over several pages.
Reply all
Reply to author
Forward
0 new messages