ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "kauśika via ntg-context" <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: kauśika <citturs@gmail.com>,
	"Michael Urban via ntg-context" <ntg-context@ntg.nl>,
	"Michael Urban" <urban.m@ca.rr.com>
Subject: Re: Table of Contents Header?
Date: Fri, 31 Dec 2021 13:15:28 +0530	[thread overview]
Message-ID: <11900120.O9o76ZdvQC@sreeramtplt> (raw)
In-Reply-To: <DD70DF72-75FD-44BF-A021-61AC916FF533@ca.rr.com>

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
___________________________________________________________________________________

      reply	other threads:[~2021-12-31  7:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-31  2:23 Michael Urban via ntg-context
2021-12-31  7:45 ` kauśika via ntg-context [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11900120.O9o76ZdvQC@sreeramtplt \
    --to=ntg-context@ntg.nl \
    --cc=citturs@gmail.com \
    --cc=urban.m@ca.rr.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).