The code below is found here. It works normally: if \numexpr\totvalue{<counter>}is replaced by \the<counter> the result is wrong (0).
\documentclass{article}
\usepackage{totcount}
\newtotcounter{totalpoints}
\setcounter{totalpoints}{0}
\begin{document}
Total points are \the\numexpr\totvalue{totalpoints}
\begin{enumerate}
\item [5 points]\addtocounter{totalpoints}{5} Here is the first question.
\item [6 points]\addtocounter{totalpoints}{6} Here is the second.
\end{enumerate}
\end{document}
I find that if the usual \the<counter>is placed after the last incrementation it provides the result properly.
Could someone explain what these two commands do?
\totvalueis most likely what allows the command for writing the number to be put anywhere in the source code but it might have some other use in this code, and in that case I'd like to know what it is.
As for \numexpr, in two cases of use that I tried this command is not needed, nor is it needed in the code shown above. Is this a TEX primitive? a LATEX command? What does it do generally? Why has it been added in the code above? In prevision of what possible problem has it been added?
\the\numexpr\value{<counter>}should work.\the\numexpr\value{<counter>}works or not and it surely doesn't when substituted in the above code to\the\numexpr\totvalue{<counter>}, but it is, except that\totvalueis most likely what allows the command for writing the number to be put anywhere in the source code, what is the use of\numexpr? Is that a TEX command?… – LPH May 15 '20 at 19:04