TransWikia.com

using xltabular to break over multiple pages results in a list of tables with multiple entries for the same table

TeX - LaTeX Asked by Alex Schultz on January 11, 2021

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

2 Answers

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

Answered by Alex Schultz on January 11, 2021

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. I have also added addtocounter{table}{-1} right after the first caption command. Otherwise the caption on the second pages would start with Table 2 instead of Table 1.

documentclass{article}
usepackage{xltabular}


begin{document}

tableofcontents
listoftables

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

            caption{Connector Pin Designation}
            addtocounter{table}{-1}\ hline
            test1 & test2 & test3 & test4 \ hline
            endfirsthead
            caption[]{Connector Pin Designation}\ hline
            test1 & test2 & test3 & test4 \ hline
            endhead 
            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}

Answered by leandriis on January 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP