1

Background

Looking to place the page number on the left of each section heading in the frontmatter's table of contents, similar to the following (where "Title Here" is a section title and the page numbers are hyperlinks):

ToC Picture

By default the "alternative" styles (a through f) always place the page number to the right of the section title. For example:

\setupcombinedlist[content][
  alternative=a,
]

Problem

I cannot determine how to check whether or not to display the chapter title in the ToC.

Code

Here is what I have so far:

\startsetups [list:TOC]
\starttabulate
\currentlistentrypagenumber{} \hskip 1em \NC \currentlistentrytitle{} \NR
\stoptabulate
\stopsetups

\definelistalternative
  [TOC]
  [renderingsetup=list:TOC]

% Format the ToC style.
\setupcombinedlist[content][
  alternative=TOC,
]

\starttext
  \completecontent
  \startchapter [title=alpha] \stopchapter
    \startsection[title=alphasec] \stopsection
  \startchapter [title=beta]  \stopchapter
    \startsection[title=alphasec] \stopsection
  \startchapter [title=gamma] \stopchapter
    \startsection[title=alphasec] \stopsection
\stoptext

Question

How do you determine whether or not the chapter title should be displayed?

Ideas

The code on the wiki reveals:

\doifelse\currentlistentrylocation{\structureheadlocation{chapter}}
        {{\bfb\currentlistentrytitle}}
        {     \currentlistentrytitle}\NC\NR

However, there are a number of syntax errors with the code and the conditional expression assumes that the ToC is being placed on every page. This assumption allows it to resolve the namedstructureheadlocation value. For a regular ToC, there is no "current chapter" and so the conditional fails.

Related

1

From the mailing list:

\define[3]\SectionListEntry
  {\par \leftaligned\bgroup
     \hbox to 2em{\color[red]{#3}}%
         \hskip   1em
         \vtop{\hsize\dimexpr\textwidth-3em\relax#2}
  \egroup \par}

\setuplist[chapter][headnumber=no,pagenumber=no,style=\bfc]
\setuplist[section][alternative=command,command=\SectionListEntry]

Instead of using a setup, apply a command to the list entry format for the sections.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.