How to use a longtable with only one entry in the list of tables

by adnc   Last Updated October 19, 2019 22:23 PM

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?



Answers 3


use for the \endfirsthead the default \caption and for \endhead the starred version of \caption.

user2478
user2478
August 18, 2011 11:59 AM

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}
lockstep
lockstep
November 11, 2011 20:14 PM

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}
Alex
Alex
October 19, 2019 22:15 PM

Related Questions


Updated June 16, 2019 10:23 AM

Updated April 22, 2018 17:23 PM

Updated November 04, 2018 11:23 AM

Updated September 26, 2016 09:09 AM