# Making a longtable that does not interfere with table numbering

I would like to use longtable to make list of abbreviations in the front matter of my thesis. I did not caption it, so it (rightly) does not show up in my list of tables. However, it does throw off the numbering of the rest of the tables -- in other words, what should be Table 1 is now captioned and listed in the list of tables as Table 2.

\documentclass{report}
\usepackage{longtable}
\begin{document}
\listoftables

The table I don't want to be numbered:
\begin{longtable}{ll}
\textbf{acac} & acetylacetonate \\
\textbf{Ar} & aryl \\
\end{longtable}

\begin{table}
\begin{center}
\caption{The table that I want to be Table 1}
\begin{tabular}{|c|c|}
\hline
column 1 & column 2 \\ \hline
77 & 43 \\ \hline
\end{tabular}
\end{center}
\end{table}

\end{document}


What is the best way to prevent this mis-numbering to happen? I considered creating a new float environment for this one case, but that seems inelegant.

• yes sorry about that, just put \addtocounter{table}{-1} after the longtable – David Carlisle Jun 3 '15 at 14:41

After long table add \addtocounter{table}{-1} which will decrement temporery value of counter table:

\documentclass{report}
\usepackage{longtable}
\begin{document}
\listoftables

The table I don't want to be numbered:
\begin{longtable}{ll}
\textbf{acac} & acetylacetonate \\
\textbf{Ar} & aryl \\
\end{longtable}

\begin{table}
\begin{center}
\caption{The table that I want to be Table 1}
\begin{tabular}{|c|c|}
\hline
column 1 & column 2 \\ \hline
77 & 43 \\ \hline
\end{tabular}
\end{center}
\end{table}

\end{document}

• Damn, you were quicker with the \addtocounter -- way ;-) – user31729 Jun 3 '15 at 14:46

\addtocounter{table}{-1} is easy, \SuspendCounters{table} from assoccnt package (with globalsuspend option) works too. Use \ResumeSuspendedCounters at the appropiate place then.

\documentclass{report}
\usepackage{longtable}
\usepackage[globalsuspend=true]{assoccnt}

\SuspendCounters{table}
\begin{document}
\listoftables

The table I don't want to be numbered:
\begin{longtable}{ll}
\textbf{acac} & acetylacetonate \\
\textbf{Ar} & aryl \\
\end{longtable}
\ResumeSuspendedCounters

\begin{table}
\begin{center}
\caption{The table that I want to be Table 1}
\begin{tabular}{|c|c|}
\hline
column 1 & column 2 \\ \hline
77 & 43 \\ \hline
\end{tabular}
\end{center}
\end{table}

\end{document}


Not sure if the package author will approve, but this should work:

1. in the code of \longtable, set a new conditional to false
2. in the code of \LT@caption, set this conditional to true
3. in the code of \endlongtable, check the value of the conditional: if it's true, a caption has been typeset in the longtable, do nothing; if it's false, no caption has been used, step down the table counter.
\documentclass{report}
\usepackage{longtable}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\LT@caption}
{\bgroup}
{\bgroup\global\LTpatch@captiontrue}
{}{}
\patchcmd{\longtable}
{\par}
{\par\global\LTpatch@captionfalse}
{}{}
\apptocmd{\endlongtable}
{}{}
\newif\ifLTpatch@caption
\makeatother

\begin{document}
\listoftables

\bigskip

The table I don't want to be numbered:
\begin{longtable}{ll}
\textbf{acac} & acetylacetonate \\
\textbf{Ar} & aryl \\
\end{longtable}

\begin{table}[htp]
\centering
\caption{The table that I want to be Table 1}
\medskip
\begin{tabular}{|c|c|}
\hline
column 1 & column 2 \\ \hline
77 & 43 \\ \hline
\end{tabular}
\end{table}

\end{document}


• The package author will definitely scold you for this vile patching ;-) – user31729 Jun 3 '15 at 15:04
• The package author never reads your answers, so won't notice. – David Carlisle Jun 3 '15 at 15:09