[NTG-context] How to use \setuplist for formatting a chapter entry?

Rob Heusdens robheus at xs4all.nl
Tue Feb 3 09:57:36 CET 2015


Hello list,

I have one little problem that I need to solve to finish my work on a
document. I want to format a list entry for the TOC for chapters like
this:

"Hoofdstuk #1 -- #2 . . . . . . . . #3"

Where #1 is the chapter number, #2 is the title and #3 the page number
where the chapter begins.

Of course the ". . . " entry is just like the normal cases where the dots
fill the rest of the line.

I have an *almost* correct solution using numbercommand and setting the
width for the title, but this leaves a gap between the formatted chapter
number and the title, because "chapter 9" and "chapter 10" don't take the
same width.

So, some other solution is needed. I tried using the command option, which
needs 3 arguments, but could not get it to work.

Here is how it looks now:

\define[1]\ChapterNumberToc%
	 {Hoofdstuk #1 -- }

\definecombinedlist[content][chapter]
\setupcombinedlist[content][level=4, alternative=c]
\setuplist[chapter][headnumber=yes,style=bold,width=8em,numbercommand=\ChapterNumberToc]
\starttext
\completecontent
\dorecurse{5}{
\chapter {Knuth} \input knuth
\chapter {Zapf}  \input zapf}
\stoptext

As you can see, there is a different between the 9-th and 10-th chapter,
because title is set at a specific width, and doesn't adapt to the width
of the formatted chapter number entry.

How to solve this, so that the title is placed directly after the
"Hoofdstuk #1 -- " entry, thereafter the filler with dots and finally the
page number at the location where it is now.

Thanks,

Rob



More information about the ntg-context mailing list