[texhax] Retrieving the value of a counter from previous run

Steve Schwartz s.schwartz at imperial.ac.uk
Fri Apr 13 22:19:19 CEST 2007


This must be easy, but I can't find out how.

I have a counter I use to count names in an included file:

master.tex has:

\newcounter{nnames}
\newcommand\nextname[1]{#1\addtocounter{nnames}{1}}

...

\include{names}

...


names.tex has:

The following \arabic{nnames}\ all agree with me:

%\setcounter{nnames}{0}  %this is what I had in mind to restart

\nextname{Joe Bloggs}
\nextname{Fred Smith}

...

So the idea is to count the names on the first pass through the file,
and then pick up that value on subsequent passes. The problem seems to
be (a) the \newcounter command resets the counter to zero (as one might
expect and normally want) and (b) the value from the previous run (which
I can see in the \@setckpt in names.aux) is then inside the scope of
that checkpoint.

Changing \include to \input needs something else to get a line:

\setcounter{nnames}{xx}

into the main aux file I guess.

Thanks for any help.

Steve

-- 
+-------------------------------------------------------------------+
Professor Steven J Schwartz      Phone: +44-(0)20-7594-7660
Space and Atmospheric Physics    Fax:   +44-(0)20-7594-7772
The Blackett Laboratory          E-mail: s.schwartz at imperial.ac.uk
Imperial College London          Office: Huxley 6M70 
London SW7 2BW, U.K.             Web: http://www.sp.ph.ic.ac.uk/~sjs
+-------------------------------------------------------------------+



More information about the texhax mailing list