[NTG-context] last chapter number

Andreas Harder aharder at uni-koblenz.de
Sun Jan 17 13:06:59 CET 2010


Am 17.01.2010 um 09:13 schrieb Wolfgang Schuster:

> 
> Am 16.01.2010 um 23:08 schrieb Andreas Harder:
> 
>>> can you try \convertedstructurecounter[chapter][type=last]
>> 
>> Hello Wolfgang,
>> 
>> I tried, but it only outputs nothing visible.
> 
> Sorry, my fault. Section numbering use their own system to save and get the numbers.
> 
> What you can do is to save the number of the last chapter at the end of the document
> with two pass data (\definetwopasslist) and use the result in the second run or you
> what for a solution from Hans.

Thank you Wolfgang! You pointed me to \definetwopasslist and that brought me to the following solution (without \definetwopasslist):

\newcounter\ChapNum
\def\NofChaps{0}

\definehead
  [chapter]
  [before=\increment\ChapNum,
    after=\savecurrentvalue\NofChaps{\countervalue{ChapNum}}]

\starttext
Dieses Dokument besteht aus \NofChaps\ Kapiteln.
\dorecurse{9}{\chapter{Kapitel #1}}
\stoptext

Nonetheless the needed information is already present even more if one uses a table of contents …


	Andreas


More information about the ntg-context mailing list