[Tex/LaTex] Repeat entire table

tables

Is there a method to repeat an entire table? I've defined a custom table format using xparse and I have potentially ~50 of these custom tables. I would like to create an appendix of the tables, including all content. I don't want to duplicate the content as it's changing frequently

EDIT: One solution is to use a separate file and include it multiple times. This is not a great solution as some of my "tables" are really only 2-3 rows long, and I have a large number of them anyway (e.g. ~50 separate include files would be much harder to work with than the current inline tables)

Best Answer

What about using filecontents package? This method essentially creates separate file but is much easier to handle. Check the example:

\documentclass{article}
\usepackage{filecontents}

\begin{document}
\begin{filecontents}{mytable.tex}
\begin{center}
\begin{tabular}{l*{6}{c}r}
Team              & P & W & D & L & F  & A & Pts \\
\hline
Manchester United & 6 & 4 & 0 & 2 & 10 & 5 & 12  \\
Celtic            & 6 & 3 & 0 & 3 &  8 & 9 &  9  \\
Benfica           & 6 & 2 & 1 & 3 &  7 & 8 &  7  \\
FC Copenhagen     & 6 & 2 & 1 & 3 &  5 & 8 &  7  \\
\end{tabular}
\end{center}
\end{filecontents}

\input{mytable.tex}

\input{mytable.tex}

\input{mytable.tex}

\input{mytable.tex}

\end{document}

and its result:enter image description here

Of course, you can combine this package with other ones, such as ltxtable, to enhance the result, as suggested by the package document.

Tabular example taken from LaTeX wikibook.