[NTG-context] styling individual parts of ToC entry

jbf roma83537 at gmail.com
Sun Sep 6 02:03:42 CEST 2020

Thanks Wolfgang, while I don't pretend to fully understand the setup you 
have provided (but am working on doing so!), of course it provides the 
correct result for a chapter that has a title, an author, and a year.

My ever-so-complicated book (and its authors!) however, throws one small 
further complication into the mix.

Where a chapter does not have a year-range, and I either omit that 
declaration, or I leave the curly brackets empty (e.g. year={}), then I 
find that the author name also does not appear in the ToC. What 
adjustment to the \ChapterListCommand do I need to make to accommodate 
the following? Possibly an \else statement, but not sure how to include 

\startchapter [title={Chapter title}] [author={Author Name}]


On 5/9/20 7:16 pm, Wolfgang Schuster wrote:
> jbf schrieb am 05.09.2020 um 03:35:
>> Now that with Hraban's invaluable assistance I am able to include 
>> title, subtitle, author as and when necessary in the ToC and put them 
>> on the same line if I need to, I have two questions that I have not 
>> found a satisfactory solution to after playing around with various 
>> possibilities.
>> I need:
>> (1) the author's names lined up vertically throughout the ToC, and
>> (2) the first part of the entry (e.g. Foreword) to be bold, but the 
>> author name to be regular text.
>> An adjusted version of Hraban's setup can show what I have tried by 
>> way of example:
>> %----------------
>> \define[1]\TitleTocEntry{%
>>    #1\hskip 1cm% title
>>     \structurelistuservariable{author}%
>>    }
>> \setuplist[title][textstyle=bold,
>>    textcommand=\TitleTocEntry,
>> ]
>> %---------------
>> /Question 1:/ /How to get the two author names to line up 
>> vertically./ Given that I have both a Foreword and a Preface, I am 
>> using \title for these. And both have separate authors. The titles 
>> will be simply 'Foreword' and 'Preface', obviously.
>> *Foreword     Author name*
>> *Preface    Author name*
>> I am using \hskip 1cm to separate the authors' names from either of 
>> those two words. But this does not give me the kind of exact 
>> positioning I need to get the two author names directly underneath 
>> each other in the list. I have tried various alternatives to \hskip, 
>> but none of them can give me the correct proportional distance. The 
>> distance is obviously being controlled by the fact that 'Foreword' is 
>> 8 characters and 'Preface' is 7. Is what I want only obtainable with 
>> a table setup?
>> The issue might or might not be more complicated when I get to main 
>> chapters, where the author names need to line up with the Foreword 
>> and Preface author names as well. There will be, e.g.
>> Chapter One  Title
>>                         Author name
>> //
>> /Question 2:/ /How to independently get Foreword and Preface to be 
>> bold, but the authors' names to be regular./ \setuplist offers me 
>> options like textstyle, pagestyle, numberstyle, but they apply to 
>> everything (both Foreword/Preface and Authors' name are bold). I 
>> thought perhaps I could control it from within the document, e.g.
>> \starttitle[title={\ss\bf Foreword}][author={A. Uthor}]
>> But that does the same - both Foreword and A. Uthor end up bold. And 
>> besides, I also want to style the ToC independently of the heads if I 
>> can.
>> The wiki and various manuals do offer various tips on modifying the 
>> ToC, but I cannot find anything regarding the two questions above - 
>> not yet, anyway. If someone knows where, please point me to it.
> \define[3]\ChapterListCommand
>   {\hbox\bgroup
>      \hbox to 3cm{\currentlistsymbol\hss}% number + labeltext
>      \vtop\bgroup
>        \hsize\dimexpr\makeupwidth-3cm\relax
>        \doifsomething{\rawstructurelistuservariable{year}}
>          {{\it\structurelistuservariable{year}}\crlf}%
>        \currentlistentrytitle % title
>        \doifsomething{\rawstructurelistuservariable{year}}
>          {\crlf{\bf\structurelistuservariable{author}}}%
>        \hfill\currentlistentrypagenumber % pagenumber
>      \egroup
>    \egroup}
> \setuplist
>   [chapter]
>   [label=chapter,
>    alternative=command,
>    command=\ChapterListCommand]
> \setuplabeltext
>   [en]
>   [chapter=Chapter ]
> \starttext
> \completecontent
> \startchapter [title={Chapter title}] [author={Author 
> Name},year={1980--2000}]
> \unknown
> \stopchapter
> \stoptext
> Wolfgang

More information about the ntg-context mailing list