1

I'm working on a document in which I define some numbers. I want to print at the beginning the sum of all these numbers. It's something like the desired result described in this question Displaying a later value of a counter, but I could not modify that code to obtain what I want.

Here is an example of what I want

\documentclass[leqno]{article}
\newcounter{totaldepuntos}
\newcommand\puntos[1]{\textbf{(#1Pt)}\addtocounter{totaldepuntos}{#1}}
\setcounter{totaldepuntos}{0}
\begin{document}
\thetotaldepuntos %Must print 10
\begin{enumerate}
\item \puntos{2} Blablabla %Creates an item, put the text ´(2Pt)´ and     
%sum 2 to the counter totaldepuntos
\item \puntos{4} Blobloblo %Creates an item, put the text ´(4Pt)´ and     
%sum 4 to the counter totaldepuntos
\item \puntos{4} Blublbublu %Creates an item, put the text ´(4Pt)´ and     
%sum 4 to the counter totaldepuntos
\end{enumerate}
\end{document}
  • If the counter starts at 8 and you add 10, then it has to come to 18. Why do you want it to print 10 when it is 18? – cfr Aug 20 '16 at 21:19
  • @cfr Lol, sorry. Edited. – MrSelberg Aug 20 '16 at 21:19
  • @MrSelberg You have looked at the wrong thread – egreg Aug 20 '16 at 21:22
  • Package totcount – user31729 Aug 20 '16 at 21:25

Browse other questions tagged or ask your own question.