I would like to create a custom list environment that collects the contents of these lists and places it at the beginning of the document.
\begin{objectives}
\item See no evil.
\end{objectives}
lots of stuff 1
\begin{objectives}
\item Hear no evil.
\end{objectives}
lots of stuff 2
\begin{objectives}
\item Speak no evil.
\end{objectives}
lots of stuff 3
I would like the objectives environment to be defined so that the commands above have the same effect as
\begin{enumerate}
\item See no evil.
\item Hear no evil.
\item Speak no evil.
\end{enumerate}
lots of stuff 1
lots of stuff 2
lots of stuff 3
(The reason I can't just move the objectives to the start of the document manually is that my content is spread across multiple files that will be combined a la carte.) I know I can use the collect
package to obtain the list at the end of the document by defining
\usepackage{collect}
\definecollection{ob}
\newenvironment{objective}{%
\collect{ob}{}{}}{\endcollect}
..earlier content..
\begin{enumerate}
\includecollection{ob}
\end{enumerate}
It seems that a solution would need to depend on \immediate\write\tempfile{}
to create a temporary file to store the contents. However, each of my attempts to create a temporary file will only succeed if I place the list at the end.
I know it is possible to collect content to be placed at the beginning of a document because a table of contents or a list of figures does just that. I haven't been able to make heads or tails of the code in the todonotes
package or tocloft
package.
Could you please point me in the right direction?