[NTG-context] Numbering again..

Thomas A. Schmitz thomas.schmitz at uni-bonn.de
Wed Mar 2 16:22:52 CET 2011


On Mar 2, 2011, at 3:59 PM, Ian Lawrence wrote:

The following is untested (since you don't include a working example, just snippets of code)

> I have a counter that I'd like to reset
> 
> 
> \newcounter \nuggetnumber
> \def \numberofnuggets{0}
> 
> \definehead [nugget] [section]
> \setuphead [nugget] [number=yes,page=yes, before=\increment \nuggetnumber,
>     after=\savecurrentvalue \numberofnuggets{\countervalue{nuggetnumber}},]
> % LO as nugget
> 
> This counts the number of nuggets.. and seems to work fine.
> 
> But when it gets to an episode it should reset....so, maybe like this
> 
> \definehead [episode] [title]
> \setuphead [episode] [numberstyle=bold, textstyle=cap, number=yes,before=\resetnumber[nuggetnumber]]

Here, you need at least a pair of braces (actually, I'm surprised your code doesn't give an error):

\setuphead [episode] [numberstyle=bold, textstyle=cap, number=yes,before={\resetnumber[nuggetnumber]}]

It's better, however, not to use low-level commands, but context syntax:

\definelabel[nuggetnumber][headstyle=normal,way=bytext,prefix=no,text=]

\definehead [nugget] [section]
\setuphead  [nugget] [number=yes,page=yes, before=\incrementnuggetnumber]

\definehead [episode] [title]
\setuphead  [episode] [numberstyle=bold, textstyle=cap, number=yes,before=\resetnuggetnumber]

context does all the housekeeping for you, no need to savevalue etc.

> 
> while I am at it, I am equally unsure how to reset the numberofnuggets accumulator, which should also be done on meeting the episode structural  element - I'd like to insert a whole chain of commands in the 
> before=...'
> 
if you want a chain of commands, use a syntax like this:

\startsetups what:ever
  \command 1
  \command 2
  ...
\stopsetups

which you can then call with 

\setuphead[argl][after=\setups{what:ever}]

HTH

Thomas


More information about the ntg-context mailing list