I want to create counters in a loop like this (with the packages multido
, totcount
) :
\newcounter{compteurChi}% first counter
\regtotcounter{compteurChi}% define the first counter as a totalcounter
\newcounter{compteurChii}% second iteration
\regtotcounter{compteurChii}
\newcounter{compteurChiii}% third iteration
\regtotcounter{compteurChiii}
So I write this :
\newcounter{AuxCounter}
\renewcommand{\theAuxCounter}{\roman{AuxCounter}}
\multido{\i=1+1}{3}{%
\setcounter{AuxCounter}{\i}
\newcounter{compteurCh\theAuxCounter}
\regtotcounter{compteurCh\theAuxCounter}
}
But this does not work : it creates only the last counter compteurChiii
.
I need to find a way to do this in a loop because I need a lot of counter, and writting it for each is not a solution for me.
I've find answers on the net for problems like mine, but I don't really understand the codes I found to adapt them to definition of counter in a loop.
To be more specific : This example show how it does not work.
I use the totcount
package to store the bigger value of the counter, and it is not stored for any of them excepted for the last counter created by the loop.
As you can see :
\documentclass{article}
\usepackage{multido,totcount}
\newcounter{AuxCounter}
\renewcommand{\theAuxCounter}{\roman{AuxCounter}}
\multido{\i=1+1}{3}{%
\setcounter{AuxCounter}{\i}
\newtotcounter{compteurCh\theAuxCounter}}
\begin{document}
For the first counter : (after compiling two times)
\thecompteurChi
\setcounter{compteurChi}{17}
\thecompteurChi / \total{compteurChi}
\refstepcounter{compteurChi}
\thecompteurChi / \total{compteurChi}
\refstepcounter{compteurChi}
\thecompteurChi / \total{compteurChi}
\refstepcounter{compteurChi}
\thecompteurChi
For the last counter created (the only that works) :
\thecompteurChiii
\setcounter{compteurChiii}{17}
\thecompteurChiii / \total{compteurChiii}
\refstepcounter{compteurChiii}
\thecompteurChiii / \total{compteurChiii}
\refstepcounter{compteurChiii}
\thecompteurChiii / \total{compteurChiii}
\refstepcounter{compteurChiii}
\thecompteurChiii
\end{document}
gives on output :
Thank's for help.