Graphics, Figures & Tableslongtable | Long Table appears twice in LoT

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
marie2011
Posts: 138
Joined: Mon Feb 06, 2012 4:58 pm

longtable | Long Table appears twice in LoT

Post by marie2011 »

Dear forum members,

I am struggling with a couple of tables in my list of tables. I am including a minimal example where you can see two long tables. The first one is OK, but the second one appears twice in the index. Do you know why? When I compile this minimal example I get an error and instead of Table 1, it appears “red”, but this does not happen in my work. I do not know why, but at the end the document can be compiled anyway. I think there is something wrong with:

Code: Select all

 \ifpdf
  \tableofcontents

Code: Select all

\documentclass[
12pt,%
%  draft,%
  twoside,%
  BCOR10mm,%
  bib=totoc,        
toc=listof,
toc=bibliography,
numbers=noenddot
]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish,ngerman,catalan,english]{babel}
\usepackage{natbib}
\usepackage{tabularx}
\usepackage{mystyle}
\usepackage{longtable}
\usepackage{caption}

\captionsetup[table]{labelsep=quad}
\captionsetup[figure]{labelsep=quad}

\addto\captionsspanish{%
%\renewcommand{\listfigurename}{Índice de Figuras}
\renewcommand{\listfigurename}{Índice de Figuras}
\renewcommand{\listtablename}{Índice de Tablas}
\renewcommand{\figurename}{Figura}
\renewcommand{\tablename}{Tabla}
\renewcommand{\bibname}{Referencias bibliográficas}
\renewcommand{\appendixname}{Apéndices}
\renewcommand{\appendixtocname}{Apéndices}
\renewcommand{\appendixpagename}{Apéndices}}

\pagenumbering{roman}
 \ifpdf
  \tableofcontents

{\listoftables
\let\cleardoublepage\relax
\let\clearpage\relax
\listoffigures
\let\cleardoublepage\relax
\let\clearpage\relax
\listofgraficos
}

\pagenumbering{arabic}

\begin{document}

\ref{tab:errors}

\begin{center}
\begin{longtable}  {|p{1.20cm}| p{10cm}|r|r|r|}   
\caption{Errores} \label{tab:errors} \\

\hline \multicolumn{1}{|l|}{\textbf{Num}} &
\multicolumn{1}{X|}{\textbf{Cat}} &
\multicolumn{1}{l|}{\textbf{Total}}         \\ \hline
\endfirsthead

\multicolumn{3}{c}%
{{\tablename\ \thetable{}:   Errors }} \\
\hline \multicolumn{1}{|l|}{\textbf{Num}} &
\multicolumn{1}{X|}{\textbf{Cat}} &
\multicolumn{1}{l|}{\textbf{Total}} \\
\hline
\endhead

\hline \multicolumn{3}{|r|}{{\emph{continuación}}} \\ \hline
\endfoot

\hline \hline
\endlastfoot



\textbf{1} & \textbf{Errors} & \%\\
\hline
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\
1.1&Example I&15 (1,32\%)\\

\end{longtable}
\end{center}

\ref{tab:example}

\begin{longtable} {lp{13cm}}
  \caption{Example}\label{tab:example}
\hline
    
 \textbf{nume} & \textbf{Examples} \\ \hline
 \endhead
\hline \multicolumn{2}{l}{{\emph{continuación}}}\\ \hline
\endfoot
\hline \hline
\endlastfoot
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
2.2&Example II\\
\end{longtable}
\end{document}
But, as I wrote, my question is why the second table appears twice in the index. Attached you will find a picture so that you can see what I mean. Sorry, but I cannot make the attachment smaller.

Many thanks in advance.

Regards,

Marie
Attachments
list-of-tables.png
list-of-tables.png (16.47 KiB) Viewed 8109 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

longtable | Long Table appears twice in LoT

Post by sommerfee »

I cannot compile your sample code:

Code: Select all

! LaTeX Error: File `mystyle.sty' not found.
But usually one places

Code: Select all

\caption{<Legend>}\label{<label>}\\
within the \endfirsthead part and a

Code: Select all

\caption[]{<Legend>}\\
within the \endhead part of the longtable.

This way the LOT entry will be suppressed for every page of the longtable except the first one.

See also documentation of the longtable package, section 3 "Captions and Headings":
You may wish the caption on later pages to be different to that on the first page.
In this case put the \caption command in the first heading, and put a subsidiary
caption in a \caption[] command in the main heading. If the optional argument
to \caption is empty, no entry is made in the list of tables. Alternatively, if
you do not want the table number to be printed each time, use the \caption*
command.
marie2011
Posts: 138
Joined: Mon Feb 06, 2012 4:58 pm

Re: longtable | Long Table appears twice in LoT

Post by marie2011 »

Hello sommerfee,

Many thanks for your explanation.

Cheers,

Marie
Post Reply