0

I want to store the number of Exam in collect environment.
The counter is alway store with final value. PLease help me correct my code with collect package.
Thank you in advance!

\documentclass{article}
\usepackage{collect}
\definecollection{excol}
\newcounter{excout}
\newenvironment{exam}{
    \refstepcounter{excout}
    \begin{center}
        THE EXAM \theexcout
    \end{center}
    \begin{collect}{excol}{}{}{}{}
        The exam {\Large \theexcout} 
    \end{collect}
}{}
\begin{document}
\begin{exam}
Content 1
\end{exam} 
\begin{exam}
Content 1
\end{exam} 

\bigskip
\includecollection{excol}
\end{document}

enter image description here

1 Answer 1

0

I add another counter. I works well. I think that it can be had a better solution.

\documentclass{article}
\usepackage{etoolbox}
\usepackage{xcolor}
\usepackage{collect}
\definecollection{excol}
\newcounter{excoutP}
\def\st{}
\newcommand{\inso}{
    \refstepcounter{excoutP}
    \appto\st{\theexcoutP}
    \st
}
\newcounter{excout}
\newenvironment{exam}{
    \refstepcounter{excout}
    \begin{center}
        THE EXAM \textcolor{red}{\theexcout}
    \end{center}
    \begin{collect}{excol}{}{}{}{}
        The exam {\Large \textcolor{red}{\inso}} 
    \end{collect}
}{}
\begin{document}
\begin{exam}
Content 1
\end{exam} 
\begin{exam}
Content 1
\end{exam} 

\bigskip
\includecollection{excol}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .