[Tex/LaTex] Ignore numbering of some tables

captionscounterstables

I have a document with two tables. I want my second table to be Table 1 both in List of Tables and caption.

\documentclass{article} 
\usepackage{tabu}
\usepackage{longtable}
\begin{document}

\begin{longtabu}{|l|l|}
\hline
1 & 2\\
\hline
%\caption{my table}
\end{longtabu}

\begin{longtabu}{|l|l|}
\hline
1 & 2\\
\hline
\caption{my table}
\end{longtabu}

\end{document}

enter image description here

Resetting the counter does not solve my problem because my content is dynamic and I cannot exclude having a small table inside my first table. And I may want this small table to be numbered. So I just want to tell the compiler to ignore some tables.

Best Answer

A 'dirty' workaround: Use a wrapper environment named Longtabu having the same parameters and say \addtocounter{table}{-1} in the environment end code, in conjunction with \caption*{}, which does not make an entry to the LoT.

Small drawback

A better setup would test, if the figure number is already larger than 0, otherwise this could lead to bad counter values ;-)

\documentclass{article} 
\usepackage{tabu}
\usepackage{longtable}




\newenvironment{Longtabu}[2][c]{%

\longtabu[#1]{#2}  
}{\addtocounter{table}{-1}\endlongtabu}


\begin{document}



\begin{Longtabu}{|l|l|}
\hline
1 & 2\\
\hline
\caption*{my table}
\end{Longtabu}

\begin{longtabu}{|l|l|}
\hline
1 & 2\\
\hline
\caption{my table}
\end{longtabu}

\begin{longtabu}{|l|l|}
\hline
1 & 2\\
\hline
\caption{my other table}
\end{longtabu}

\begin{Longtabu}{|l|l|}
\hline
1 & 2\\
\hline
\caption*{Even another table}
\end{Longtabu}

\end{document}