Graphics, Figures & Tableslongtable increments table count +2 ?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
sbb
Posts: 3
Joined: Mon Jul 26, 2010 9:56 am

longtable increments table count +2 ?

Post by sbb »

Hi Latex-Community,
this is my first post, so don't tear me up if my MWE isn't correct.
Moreover, I'm not a native speaker, so my english might sound a bit strange sometime.

I use mainly tabularx tables in my Latex-File but I tried to use the longtable environment once today. I wouldn't need it, because the table is only 1/5 of a page but this is more of a training thing to get used to the different latex-tables, so I know how to use them, when I need to.
The problem: tabularx-tables increase the tablecount +1 (normal behavior) but longtable-tables increase the count +2. That means if I create a document with 1. tabularx 2. longtable 3. tabularx, they will be automatically numbered in the captions like that: Tab. 1 - Tab. 2 - Tab. 4.
At the moment, I counter this behavior by inserting a " {\addtocounter{table}{-1}} " at the end of every longtable, but this can't be the right thing.

Here's my MWE, i hope it fits the convetions

Code: Select all

\documentclass[11pt,a4paper,oneside]{article}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{longtable}
\begin{document}

\begin{table}[htbp]
  \caption{Add caption}
   	 \begin{tabularx}{\textwidth}{cccc}
    		\toprule
       		\bottomrule
    \end{tabularx}
  \label{tab:addlabel}
\end{table}	

\begin{table}[htbp]
  \caption{Add caption} 
	\begin{longtable}{cccc}  
 		\toprule
		\midrule
   		\bottomrule
    \end{longtable}
  \label{x}
\end{table}

\begin{table}[htbp]
  \caption{Add caption}
   	 \begin{tabularx}{\textwidth}{cccc}
   		\toprule
    	 	\bottomrule
    \end{tabularx}
  \label{tab:addlabel}
\end{table}	
	
\end{document}

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

longtable increments table count +2 ?

Post by localghost »

sbb wrote:[...] so don't tear me up if my MWE isn't correct. [...]
Au contraire, it's a very good one. Drop the table environment around the longtable environment (it's not supposed to float). The latter one shares the »table« counter and increments it on its own. You can read the details in the longtable manual.


Best regards and welcome to the board
Thorsten
Post Reply