Re: [NTG-context] Table of Contents Header?

2021-12-30 Thread kauśika via ntg-context
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 : ntg-context@ntg.nl / 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
___


[NTG-context] Table of Contents Header?

2021-12-30 Thread Michael Urban via ntg-context
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?
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 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
___