2

In my table of contents, part is defined like this:

\setuplist[part][pagenumber=no]

I would like to center align the title of the part, so it appears like this in the table of contents:

 __________
| Contents |
|          |
|  Part 1  |
| Ch. 1..1 |
| Ch. 2..5 |
| Ch. 3.10 |
|__________|

I have consulted the article about setuplist at the ConTeXt wiki, but I can see no options for horizontally aligning the entries.

  • How can I center align the part entries in the table of contents?
  • 1
    Does \setuplist [part] [ pagenumber=no, alternative=a, align=middle, ] achieve what you want? – Philipp Gesang May 12 '12 at 1:18
  • This almost centers the entries, but it is to the right of center. – Village May 12 '12 at 14:04
1

Defining a dedicated list alternative may be the wisest choice:

\unprotect

%%% We’ll wrap the header title into a frame for convenience.
\defineframed [centered_list_frame] [
  frame=off,
  width=broad,
  align=middle,
]

%%% A new list alternative employing the frame. The three args are:
%%% #1 -> Item number.
%%% #2 -> Item title.
%%% #3 -> Page number (ignored in this example).
\definelistplacement [centered_list_placement]#1#2#3{%
  \centered_list_frame{\words\sc Part #1:\hskip\emwidth#2}%
}

%%% Here instruct the part list to use the new list alternative.
\setuplist [part] [alternative=centered_list_placement,]

\protect

\starttext

\placelist [part,chapter]

\dorecurse{3} {\part{foo} \dorecurse{5}{\chapter{bar}}}

\stoptext

This way you have complete control over the three items that constitute the TOC entry and can center align them at will.

centered part list header

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.