ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Table of Contents Header?
@ 2021-12-31  2:23 Michael Urban via ntg-context
  2021-12-31  7:45 ` kauśika via ntg-context
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Urban via ntg-context @ 2021-12-31  2:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Michael Urban

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Table of Contents Header?
  2021-12-31  2:23 Table of Contents Header? Michael Urban via ntg-context
@ 2021-12-31  7:45 ` kauśika via ntg-context
  0 siblings, 0 replies; 2+ messages in thread
From: kauśika via ntg-context @ 2021-12-31  7:45 UTC (permalink / raw)
  To: mailing list for ConTeXt users
  Cc: kauśika, Michael Urban via ntg-context, Michael Urban

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-31  7:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-31  2:23 Table of Contents Header? Michael Urban via ntg-context
2021-12-31  7:45 ` kauśika via ntg-context

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).