[NTG-context] Getting the current chapter number in the TOC

Wolfgang Schuster schuster.wolfgang at gmail.com
Thu Apr 17 18:25:38 CEST 2014


Am 17.04.2014 um 17:27 schrieb Maggyero <maggyero at gmail.com>:

> Hello,
> 
> 
> How can I get the following table of contents?
> 
> 
> Contents
> 
> Chapter first MyTitle
> Chapter II MyTitle
> Chapter III MyTitle
> 
> 
> I have tried:
> 
> \MyNumber{\doifelse{\currentsectioncountervalue}{1}{first}{#1}}
> setuplist[chapter][numbercommand=\MyNumber]
> 
> but it does not work. Actually because \currentsectioncountervalue always returns 0 in the table of contents. So I need another command which gives me the current number for testing if it is equal to one (first chapter).

\define[1]\Weirdnumber
  {\ifcase#1\relax
     % 0
   \or
     First% 1
   \else
     \convertnumber{Romannumerals}{#1}%
   \fi}

\defineconversion[Weirdnumber][\Weirdnumber]

\defineconversionset[Weirdchapter][number,Weirdnumber][number]

\setuplist[chapter][width=3em,numberconversionset=Weirdchapter]

\starttext

\completecontent

\dorecurse{10}{\expanded{\chapter{Chapter \recurselevel}}}

\stoptext

Wolfgang



More information about the ntg-context mailing list