Here is an example that illustrates my goal:
Code: Select all
\documentclass[a4paper,12pt]{report}
\newcounter{totalpoints}
\setcounter{totalpoints}{0}
\newcounter{question}
\setcounter{question}{0}
\newenvironment{question}[1]%
{%begindef
\refstepcounter{question}%
\addtocounter{totalpoints}{#1}%
\fbox{\textbf{\thequestion}} [#1\ points]%
}%
{%enddef
}
\begin{document}
Max points: \maxpoints \\
\begin{question}{10}
What is your pet's name?
\end{question}
\begin{question}{30}
What is your mother's maiden name?
\end{question}\\
\newcommand{\maxpoints}{\thetotalpoints}
Max points: \maxpoints \\
\end{document}