ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Numbering again..
@ 2011-03-02 14:59 Ian Lawrence
  2011-03-02 15:22 ` Thomas A. Schmitz
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Lawrence @ 2011-03-02 14:59 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1037 bytes --]

Sorry...Again I am stumped.

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]]
% may be used


But \resetnumber[nuggetnumber], where-ever I put it seems to have no impact.
I think the Wiki suggests that it should, and the mailing list back
catalogue and the manual shed no light on the matter....



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=...'


Thanks
Ian

[-- Attachment #1.2: Type: text/html, Size: 1449 bytes --]

[-- Attachment #2: Type: text/plain, Size: 486 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Numbering again..
  2011-03-02 14:59 Numbering again Ian Lawrence
@ 2011-03-02 15:22 ` Thomas A. Schmitz
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas A. Schmitz @ 2011-03-02 15:22 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-03-02 15:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-02 14:59 Numbering again Ian Lawrence
2011-03-02 15:22 ` Thomas A. Schmitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).