In the simplest form of the problem I am facing, I need to define a command that accepts two parameters, uses the first to put some contents in the document exactly where the command is invoked, and save the second parameter to be used later in the document.
To be specific, I am defining a command to help me fill an activities report. The command will accept the description of some activity (first parameter) and the name of a file that proves that the activity was performed (a scanned page or a PDF) (the second parameter). The command must format the first parameter in a nice table and add a \ref to the PDF, which will be automatically included in a section at the end of the document, with the corresponding \label.
Right now I use the label as the second parameter and include the file by hand, as shown in the example below.
\documentclass[]{article}
\newcounter{ctannex}
\DeclareRobustCommand{\annex}[1]{%
\refstepcounter{ctannex}%
\label{#1} %
Annex \arabic{ctannex} %
}
\newcounter{ctactivity}
\DeclareRobustCommand{\activity}[3]{%
\refstepcounter{ctactivity}%
\label{#1} %
Activity \arabic{ctactivity}\\ %
Description: #3\\ %
Receipt: \ref{#2}
}
\usepackage{graphicx}
\begin{document}
\section{Activities}
\begin{itemize}
\item \activity{actLabel}{annexLabel}{nothing, really}
\end{itemize}
\section{Annexes}
\begin{itemize}
\item \annex{annexLabel}
\includegraphics[width=\textwidth]{falta}
\end{itemize}
\end{document}
Ideally I would have the command called just as
\activity{actLabel}{file.png}{nothing, really}
