On Friday, December 31, 2021 7:53:08 AM IST Michael Urban via ntg-context 
wrote:
> Or is there some more foolproof way of getting those headers into the right
> place?

Here is something I quickly wrote up:

First, define some labels for the columns of the ToC —
    \definesynonyms[toclabel][toclabel][\TOCLabel]
    \setupsynonyms[toclabel][textstyle=\sc]
    \toclabel{TOCNumberLabel}{Chapter}
    \toclabel{TOCTitleLabel}{Title}
    \toclabel{TOCPageLabel}{Page}
Then compute the width of the chapter-number and page-number labels
    \setwidthof\TOCLabel{TOCNumberLabel}\to\TOCNumberLabelWidth
    \setwidthof\TOCLabel{TOCPageLabel}\to\TOCPageLabelWidth
and define a 'paragraphs' block with 3 columns with a separation of 1em between 
each column
    \defineparagraphs
        [TOCpar]
        [n=3]
    \setupparagraphs
        [TOCpar]
        [each]
        [distance=1em]
Set the width of the first column to the width of the label (and center chapter 
number)
    \setupparagraphs
        [TOCpar]
        [1]
        [width=\dimexpr\TOCNumberLabelWidth,
         align=middle]
and similarly for the third column (and center the page number)
    \setupparagraphs
        [TOCpar]
        [3]
        [width=\dimexpr\TOCPageLabelWidth,
         align=middle]
Finally, wrap it all up in the macro 
    \define[3]\TOCEntry{%
    \startTOC
        #1 \TOCpar #2 \TOCpar #3%
    \stopTOC%
    }
and indicate the command to use in the setup 
    \setuplist
        [chapter]
        [alternative=interactive,
         command=\TOCEntry,
         after=\endgraf] % required

The ToC along with column labels is placed with 
    \TOCLabel{TOCNumberLabel}%
    \hfill\TOCLabel{TOCTitleLabel}\hfill%
    \TOCLabel{TOCPageLabel}
    \placecontent

Of course, you can choose to not set the 'align' keys in \setupparagraphs[TOC] 
if center alignment is not required/desired.

Hope this helps.

Best,
kauśika


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

maillist : [email protected] / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to