[texhax] Reference counter turns out to be too big by 1.

Rolf Turner r.turner at auckland.ac.nz
Thu Aug 31 10:22:03 CEST 2017


On 31/08/17 18:54, Herbert Voss wrote:

> Am 31.08.2017 um 07:10 schrieb Rolf Turner:
>>
>> I have defined a new numbered environment and counter by which to 
>> number instances of that environment.  When I label such instances and 
>> refer to
>> the labels, I get values of the counter that are too big by 1.
>>
>> I have attached a reproducible example.  I get Zorch II, Zorch III and
>> Zorch IV where I should get Zorch I, Zorch II and Zorch III.
>>
>> I'm sure that there's a simple explanation and fix, but I can't see what
>> these might be.
> 
> \newcounter{Zorch}
> \setcounter{Zorch}{0}
> \renewcommand{\theZorch}{\Roman{Zorch}}
> \newenvironment{Zorch}{%
>      \refstepcounter{Zorch}%
>      \section*{Zorch \theZorch}%
> }{}


That's great.  Thanks very much.  I thought about starting the Zorch 
counter at zero, but I just figured that this would make the labels of
the "Zorch"es 1 too small.  I didn't see (I feel kind of "duh" now) that
putting the \refstepcounter{} call *before* the \section*{} call would 
fix this.

I *knew* there'd be a simple fix, that I was just too stupid to see.

Thanks again to Susan and Herbert.

cheers,

Rolf Turner

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276


More information about the texhax mailing list