I'm using longtable to spread my table over three pages. Unfortunately the caption is also added three times to the list of tables. Is is possible to have it displayed only once?
use for the \endfirsthead
the default \caption
and for \endhead
the starred version of \caption
.
-
1Same here, for the starred version of
\caption
inside longtables thecaption
package is not needed. – Axel Sommerfeldt Aug 18 '11 at 12:03 -
did I said something different ... :-)) – user2478 Aug 18 '11 at 12:05
-
1
\caption*
does not print the table number.\caption[]{…}
does print the number but does not make an entry to the list of tables. – Schweinebacke Jun 7 '17 at 14:39
In case you want a numbered caption on follow-up table pages, use
\caption{<Caption Text>}
\endfirsthead
\caption[]{<Caption Text>}
\endhead
Minimal working example:
\documentclass{article}
\usepackage{longtable}
\renewcommand*{\arraystretch}{5}% just for the example
\begin{document}
\listoftables
\section{foo}
\begin{longtable}{c}
\caption{A table}
\endfirsthead
\caption[]{A table}
\endhead
bar \\
bar \\
bar \\
bar \\
bar \\
bar \\
bar \\
bar \\
\end{longtable}
\end{document}
You can also use the \usepackage{tabularx} to solve the problem. The following code will produce a list of tables with a caption added only once.
\documentclass{article}
\usepackage{array}
\usepackage{multirow}
\usepackage{textcomp}
\usepackage{changepage}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{booktabs}
\usepackage{ltablex}
\usepackage{longtable}
\begin{document}
\listoftables
\begin{tabularx}{1\textwidth}{
>{\raggedright\arraybackslash}m{2cm}
>{\raggedright\arraybackslash}m{2.2cm}
>{\raggedright\arraybackslash}m{4cm}}
\caption{Table A} \label{tab:Table A} \\
\toprule
\textbf{Sample 1} & \textbf{Sample 2} & \textbf{Sample 3} \\
\midrule
\endfirsthead
\caption[]{Table A} \label{Table A} \\
\toprule
\textbf{Sample 1} & \textbf{Sample 2} & \textbf{Sample 3} \\
\midrule
\endhead
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
3 & 2 & 6 \\
2 & 6 & 1 \\
7 & 8 & 3 \\
\bottomrule
\end{tabularx}
-
Welcome to TeX.SE! Unfortunately;
tabularx
is not an environment for multi-page tables. – CarLaTeX Oct 19 at 22:20
\caption
several times. Try to replace it all but the first with\caption*
. This might require thecaption
package. – Martin Scharrer♦ Aug 18 '11 at 11:59\caption*
inside longtables is offered by thelongtable
package itself. So no need for thecaption
package. (This differs from\caption*
inside floating environments, this one is offered by thecaption
package) – Axel Sommerfeldt Aug 18 '11 at 12:02\endhead
instead of\endfirsthead
– user2478 Aug 18 '11 at 12:06