1

I am using xltabular to break a table over multiple pages. When I use \caption for the table, It produces a caption for each page that the table is on. I do not need this behavior, but can look passed it. However, it does produce multiple entries in my LoT. That behavior is expected if its creating new captions on every page; but it is behavior that i cannot continue with.

Is there anyway to get a xltabular to break over pages, but not re-caption everything? or is there a way to tell \listoftables to not display duplicates?

below is a MWE:

\documentclass{article}
\usepackage{xltabular}


\begin{document}

\tableofcontents
\listoftables

\section{test}
\begin{xltabular}{\linewidth}{|c|c|c|X|}

            \caption{Connector Pin Designation}\\ \hline


            % Create the header
            test1 & test2 & test3 & test4 \\ \hline
            \endhead \hline % Finish the header

            \endfoot \hline  % Finish the footer (nothing here)



            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\


\end{xltabular}

\end{document}

Which results in the following list of tables. enter image description here

3 Answers 3

2

By using (relative new) package `tabularray your problems cannot happen:

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\usepackage{lipsum}

\begin{document}

\tableofcontents
\listoftables

\section{test}
\begin{longtblr}[
caption = {Connector Pin Designation},
  label = {tab:longtblr},
                ]{
    vlines,
    colspec = {c c c X[j]},
    row{1}  = {font=\bfseries},
    rowhead = 1  }
% table body
    \toprule
test1 & test2 & test3 & test4 \\ 
    \midrule
test1 & test2 & test3 & \lipsum[66] \\
test1 & test2 & test3 & \lipsum[66] \\
test1 & test2 & test3 & \lipsum[66] \\
test1 & test2 & test3 & \lipsum[66] \\
test1 & test2 & test3 & \lipsum[66] \\
test1 & test2 & test3 & \lipsum[66] \\
test1 & test2 & test3 & test4 \\
test1 & test2 & test3 & test4 \\
    \bottomrule
\end{longtblr}

\begin{table}[ht]
\caption{Test of caption numbering}
\lipsum[1][1-2]
\end{table}

\end{document}

A description of syntax tabularray can be found in its documentation.

enter image description here

1

Using different \caption commands for the caption on the first and the following pages can help here.

I have used an empty optional argument for the captions that are shwon on the following pages to suppress these from showing in the list of tables.

\documentclass{article}
\usepackage{xltabular}


\begin{document}

\tableofcontents
\listoftables

\section{test}
\begin{xltabular}{\linewidth}{|c|c|c|X|}

            \caption{Connector Pin Designation}
            \\ \hline
            test1 & test2 & test3 & test4 \\ \hline
            \endfirsthead
            \caption[]{Connector Pin Designation}\\ \hline
            test1 & test2 & test3 & test4 \\ \hline
            \endhead 
            \hline
            \endfoot   % Finish the footer (nothing here)
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\


\end{xltabular}

\end{document}
4
  • Thank you for the answer! I am was hoping that I wouldn't have to do that. It feels kind of like a hack (just blank out the caption). So I played around a little bit with the new commands that you have in your response. It turns out that you don't need to add the second caption at all. you just need a \endfirstheader with the caption, then a \endheader without a caption. Apr 13, 2020 at 16:27
  • @AlexSchultz: Leaving out the second caption command entirely will definitely work. You will however loose the caption on the following pages with this approach. Since you used \endhead in your original question, I was under the impression you wanted the caption to repeat on every page of the table.
    – leandriis
    Apr 14, 2020 at 8:17
  • @leandriis, (i) you not need to correct table counter, (ii) your table preamble has errors, correct is: \begin{xltabular}{\linewidth}{|c|c|c|X|} \caption{Connector Pin Designation}\\ \hline test1 & test2 & test3 & test4 \\ \hline \endfirsthead \caption[]{Connector Pin Designation}\\ \hline test1 & test2 & test3 & test4 \\ \hline \endhead \hline % Finish the footer (nothing here) \endfoot % table body
    – Zarko
    May 6 at 22:37
  • @Zarko: Prior to version 0.2d of the xltabular package, a second caption incorrectly increased the table counter, hence the correction in the previous version of my answer. With the most recent version of xltabular this correction isn't needed any more. I have adjusted my answer accordingly.
    – leandriis
    May 7 at 12:31
0

xltabular uses the commands \endfirsthead and endhead. These can help you in your search.

\endfirsthead designates the first header as something different than what is printed on the rest of the page. The \caption command will also be included in this header.

\endhead works the same as the \endfirsthead but on every page that the table breaks to. So if you put a \caption here, then it will print a caption of every page.

Here is your MWE with the proper fix:

\documentclass{article}
\usepackage{xltabular}


\begin{document}

\tableofcontents
\listoftables

\section{test}
\begin{xltabular}{\textwidth}{|c|c|c|X|}

            \caption{Connector Pin Designation}\\ \hline


            % Create the first header
            test1 & test2 & test3 & test4 \\
            \endfirsthead \hline % Finish the header


            % Create the header for the rest of the pages
            % (if you leave this out, then you wont get headers on
            %  your pages.) 

            % dont add a \caption
            test1 & test2 & test3 & test4 \\
            \endhead \hline % Finish the header


            \endfoot \hline  % Finish the footer (nothing here)



            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\
            test1 & test2 & test3 & test4 \\


\end{xltabular}


\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.