Graphics, Figures & Tables ⇒ wrong table numbering in a chapter
wrong table numbering in a chapter
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: wrong table numbering in a chapter
Best regards
Thorsten¹
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: wrong table numbering in a chapter
--------------------------------
\documentclass[12pt,a4paper,openright]{book}
\usepackage[includeheadfoot,margin=3cm]{geometry}
\usepackage{booktabs,caption, float,tabularx,ltablex}
\begin{document}
\pagestyle{headings}
%\begin{table}[!ht]
\begin{table}
{\scriptsize
\begin{tabularx}{\linewidth}{ccccccccp{.8cm}p{.8cm}cccc}
\hline
col1&col&col&col&col&col&col&col&col&col&col&col&col&col\\\hline
row&11&49&53&6&13&62&32&34&81&82&31&79&34\\\\
row&12&43&63&30&59&21&11&55&67&70&50&71&50\\\\
row&75&101&119&155&140&0&0&264&31&226&69&144&151\\\\
row&64&48&55&103&80&4&0&62&125&147&34&30&153\\\\
row&68&126&55&165&84&0&0&54&195&211&34&81&159\\\\
row&98&193&235&191&212&83&43&353&179&378&150&294&235\\\\
row&193&339&325&340&382&114&43&635&247&661&212&550&327\\
\hline
\end{tabularx}
}
\caption{This is a caption.}
\label{test}
\end{table}
\end{document}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
wrong table numbering in a chapter
Your code works fine when I omit the the ltablex package. Since this combines both the longtable and the tabularx package, it seems to have the same effect of increasing the table counter like the former one. This effect also appears when using the tabularx environment with ltablex loaded. I suggest to take a look at the longtable manual to learn more about avoiding this effect.
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: wrong table numbering in a chapter
What should be done if in a document, both tabularx and ltablex are used to define the majority of tables with tabularx and some long tables with ltablex if both are in conflict?
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
wrong table numbering in a chapter
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: wrong table numbering in a chapter
wrong table numbering in a chapter
If this is the case, the solution should be simple: Omit the table environment (it does not make sense in combination with a longtable anyway) and put the \caption inside the longtable resp. tabularx.localghost wrote:As far as I know a tabularx environment with ltablex loaded uses the longtable environment. But to find that out is up to you. A look into the manual should do.