Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 8 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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