![](https://secure.gravatar.com/avatar/87015c1fb5b105e81f675c17802f27f0.jpg?s=120&d=mm&r=g)
I am playing around with imitating the design of fiction books from the early 20th century. The table of contents for these books often has small headings, 'CHAPTER' (or 'CHAP.') and 'PAGE' over the respective columns. How might this best be accomplished in ConTeXt? Just add a carefully formatted line before the \placecontent ? Or is there some more foolproof way of getting those headers into the right place?
![](https://secure.gravatar.com/avatar/b04967b5f7eb23e9f63b1357c7e8b3cb.jpg?s=120&d=mm&r=g)
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
participants (2)
-
kauśika
-
Michael Urban