What would be an elegant way to add (in my case tables) to the appendix without leaving the part of the file in am working on? i.e. how should I define the \addtoappendix command in:
Here is an example of a table you can find in \cref{appendix} \addtoappendix{table}.
I have seen this question, is there maybe something easier/shorter?
The setting is as follows: I am using Pythontex to write the tables and I would like to keep a copy of these in the appendix.
EDIT (minimal examples):
First without Pythontex:
\documentclass[11pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsthm, amssymb}
\usepackage{amsfonts}
\usepackage{hyperref}
\usepackage[nameinlink]{cleveref}
\begin{document}
\begin{table}
\center
\begin{tabular}{cc}
$a$&$b$\\
$c$&$d$
\end{tabular}
\caption{A table}
\label{tab:table}
\end{table}
Here is a \cref{tab:table}.
\end{document}
In this case, \addtoappendix{\begin{table}...\end{table}} should print the table in the appendix.
I think adapting this with the Pythonthex should be straighforward, but maybe not:
\documentclass[11pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsthm, amssymb}
\usepackage{amsfonts}
\usepackage{hyperref}
\usepackage{pythontex}
\usepackage[nameinlink]{cleveref}
\begin{document}
\begin{pycode}
def ptable():
print("\\begin{table}\\center")
print("\\begin{tabular}{cc}")
print("$a$&$b$\\\\")
print("$c$&$d$")
print("\\end{tabular}")
print("\\caption{A table}")
print("\\label{tab:table}")
print("\\end{table}")
\end{pycode}
\pyc{ptable()}
Here is \cref{tab:table}
\end{document}
\addtoappendix{\pyc{ptable()}} should print the table in the appendix.
Thank you!
