9

I have a table, and I want to print it twice in my document. I want them to have the same label, caption and number, so that in the caption when it says "Table 1: foo" the same number shows up, and so that when I reference its label, it will always reference to the same number. Is this possible?

1 Answer 1

9

One option, using the collect package to collect the table, and then reuse it again with \includecollection; the counter is properly taken care of and also the \label duplication is avoided:

\documentclass{article}
\usepackage{collect}

\definecollection{mytable}
\newcounter{duptable}
\newcounter{tmp}

\makeatletter
\newcommand\resttable{%
\let\oldlabel\label
\let\label\@gobble
\setcounter{tmp}{\value{table}}
\setcounter{table}{\value{duptable}}
\includecollection{mytable}
\let\label\oldlabel
\setcounter{table}{\value{tmp}}
}
\makeatother


\begin{document}

\begin{collect*}{mytable}{\setcounter{duptable}{\value{table}}}{}{}{}
\begin{table}
\centering
\begin{tabular}{cc}
\hline
A & B \\
C & D \\
\hline
\end{tabular}
\caption{A collectable table}
\label{tab:test}
\end{table}
\end{collect*}

\resttable

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.