I'd like to have a counter, called ProblemPoints
in the MWE, which is dependent on an environment problem
, such that I can print the total points of each problem.
\documentclass{article}
\usepackage{totcount}
\newtotcounter{ProblemPoints}
\newenvironment{problem}
{
\setcounter{ProblemPoints}{0}
Problem: (\total{ProblemPoints} points)
}
{\vspace{1cm}}
\begin{document}
\begin{problem}
Question 1: (2 points)\addtocounter{ProblemPoints}{2}
Question 2: (2 points)\addtocounter{ProblemPoints}{2}
\end{problem}
\begin{problem}
Question 1: (5 points)\addtocounter{ProblemPoints}{5}
Question 2: (1 points)\addtocounter{ProblemPoints}{1}
\end{problem}
\end{document}
Here it just prints 6 (the total points of the last Problem) at each problem.
exam
document class? BTW, you set the counter to 0 whenever you start the environment.exam
class.