How to use \setuplist for formatting a chapter entry?
Hello list, I have one little problem that I need to solve to finish my work on a document. I want to format a list entry for the TOC for chapters like this: "Hoofdstuk #1 -- #2 . . . . . . . . #3" Where #1 is the chapter number, #2 is the title and #3 the page number where the chapter begins. Of course the ". . . " entry is just like the normal cases where the dots fill the rest of the line. I have an *almost* correct solution using numbercommand and setting the width for the title, but this leaves a gap between the formatted chapter number and the title, because "chapter 9" and "chapter 10" don't take the same width. So, some other solution is needed. I tried using the command option, which needs 3 arguments, but could not get it to work. Here is how it looks now: \define[1]\ChapterNumberToc% {Hoofdstuk #1 -- } \definecombinedlist[content][chapter] \setupcombinedlist[content][level=4, alternative=c] \setuplist[chapter][headnumber=yes,style=bold,width=8em,numbercommand=\ChapterNumberToc] \starttext \completecontent \dorecurse{5}{ \chapter {Knuth} \input knuth \chapter {Zapf} \input zapf} \stoptext As you can see, there is a different between the 9-th and 10-th chapter, because title is set at a specific width, and doesn't adapt to the width of the formatted chapter number entry. How to solve this, so that the title is placed directly after the "Hoofdstuk #1 -- " entry, thereafter the filler with dots and finally the page number at the location where it is now. Thanks, Rob
Am 03.02.2015 um 09:57 schrieb Rob Heusdens
: Hello list,
I have one little problem that I need to solve to finish my work on a document. I want to format a list entry for the TOC for chapters like this:
"Hoofdstuk #1 -- #2 . . . . . . . . #3"
Where #1 is the chapter number, #2 is the title and #3 the page number where the chapter begins.
Of course the ". . . " entry is just like the normal cases where the dots fill the rest of the line.
I have an *almost* correct solution using numbercommand and setting the width for the title, but this leaves a gap between the formatted chapter number and the title, because "chapter 9" and "chapter 10" don't take the same width.
So, some other solution is needed. I tried using the command option, which needs 3 arguments, but could not get it to work.
Here is how it looks now:
\define[1]\ChapterNumberToc% {Hoofdstuk #1 -- }
\definecombinedlist[content][chapter] \setupcombinedlist[content][level=4, alternative=c] \setuplist[chapter][headnumber=yes,style=bold,width=8em,numbercommand=\ChapterNumberToc] \starttext \completecontent \dorecurse{5}{ \chapter {Knuth} \input knuth \chapter {Zapf} \input zapf} \stoptext
As you can see, there is a different between the 9-th and 10-th chapter, because title is set at a specific width, and doesn't adapt to the width of the formatted chapter number entry.
How to solve this, so that the title is placed directly after the "Hoofdstuk #1 -- " entry, thereafter the filler with dots and finally the page number at the location where it is now.
You have to write your own layout for the complete list entry. When you don’t need hyperlinks for the list entries you can use “alternative=command” instead of “alternative=interactive” for \setuplist. \setupcombinedlist[content][list=chapter] \definefiller[ChapterFiller] \define[3]\ChapterListEntry {\vbox{Hoofdstuk #1 – #2 \filler[ChapterFiller] #3}} \setuplist[chapter][alternative=interactive,command=\ChapterListEntry] \starttext \completecontent \dorecurse{5}{ \chapter {Knuth} \input knuth \chapter {Zapf} \input zapf} \stoptext Wolfgang
You have to write your own layout for the complete list entry. When you donât need hyperlinks for the list entries you can use âalternative=commandâ instead of âalternative=interactiveâ for \setuplist.
\setupcombinedlist[content][list=chapter]
\definefiller[ChapterFiller]
\define[3]\ChapterListEntry {\vbox{Hoofdstuk #1 â #2 \filler[ChapterFiller] #3}}
\setuplist[chapter][alternative=interactive,command=\ChapterListEntry]
\starttext \completecontent \dorecurse{5}{ \chapter {Knuth} \input knuth \chapter {Zapf} \input zapf} \stoptext
Wolfgang
Hello Wolfgang, The example works. However, if I do the same changes you made to my example to my actual document, the result is different for some reason. The chapter entry in the list (TOC) gets printed like: "#1 #2 . . . . . . . . . . . #3" So the "Hoofdstuk" and " -- " element is not printed, and title is on a fixed position. The entry IS interactive (printed green but not bold). Here are my changes (replaced \ChapterToc for \ChapterListEntry) \definefiller[ChapterFiller] \define[3]\ChapterToc% {\vbox{\bf Hoofdstuk #1 -- #2 \filler[ChapterFiller] #3}} \setuplist[chapter][alternative=interactive,command=\ChapterToc] And my list is defined like this: \definecombinedlist[content][chapter,section,intro,summary,appendix,back] \setupcombinedlist[content][level=4, alternative=c] I don't understand why making the same changes you did to the example, performed on my document, makes a difference. Can other \setuplist definitions have something to do with it? Here are some other definitions I used: \definehead[intro][chapter] \definehead[back][chapter] \definehead[appendix][chapter] \definehead[summary][section] \setuplist[chapter][alternative=interactive,command=\ChapterToc] \setuplist[section][headnumber=no] \setuplist[summary][headnumber=no] \setuplist[appendix][headnumber=no,style=bold,textcommand=\AppendixToc] \setuplist[back][headnumber=no,style=bold,textcommand=\BackToc] Entries for appendix chapter and back chapter get printed correctyly but they don't have chapter number, only normal chapters have that. Still puzzled by this... Rob
Am 03.02.2015 um 12:15 schrieb Rob Heusdens
: You have to write your own layout for the complete list entry. When you donât need hyperlinks for the list entries you can use âalternative=commandâ instead of âalternative=interactiveâ for \setuplist.
\setupcombinedlist[content][list=chapter]
\definefiller[ChapterFiller]
\define[3]\ChapterListEntry {\vbox{Hoofdstuk #1 â #2 \filler[ChapterFiller] #3}}
\setuplist[chapter][alternative=interactive,command=\ChapterListEntry]
\starttext \completecontent \dorecurse{5}{ \chapter {Knuth} \input knuth \chapter {Zapf} \input zapf} \stoptext
Wolfgang
Hello Wolfgang,
The example works. However, if I do the same changes you made to my example to my actual document, the result is different for some reason.
The chapter entry in the list (TOC) gets printed like:
"#1 #2 . . . . . . . . . . . #3"
So the "Hoofdstuk" and " -- " element is not printed, and title is on a fixed position. The entry IS interactive (printed green but not bold).
Here are my changes (replaced \ChapterToc for \ChapterListEntry)
\definefiller[ChapterFiller]
\define[3]\ChapterToc% {\vbox{\bf Hoofdstuk #1 -- #2 \filler[ChapterFiller] #3}}
\setuplist[chapter][alternative=interactive,command=\ChapterToc]
And my list is defined like this:
\definecombinedlist[content][chapter,section,intro,summary,appendix,back] \setupcombinedlist[content][level=4, alternative=c]
Remove the line above (the level key down’t work with MkIV) and use \setuplist to set “alternative=c” for the list entries where you want to apply this layout. Wolfgang
Remove the line above (the level key downât work with MkIV) and use \setuplist to set âalternative=câ for the list entries where you want to apply this layout.
Wolfgang
I commented out the \setupcombinedlist command and placed "alternative=c" into the other \setuplist entries (except for \setuplist[chapter] which has "alternative=interactive" Then the result is even worse: * the Introduction entry gets printed strangely like this: "[intro: Inleiding 13]" * the chapther entries are NOT interactive (black instead of green, but do have bold), and while containing the right entries, they are indented to the right. Other entries do print ok. If I also set "alternative=c" for the chapter list entry, the other errors go away, but the chapter line again looks like this: "#1 #2 . . . . . #3" and interactive (green) but not bold. Still puzzled..... Rob
Am 03.02.2015 um 12:43 schrieb Rob Heusdens
: Remove the line above (the level key downât work with MkIV) and use \setuplist to set âalternative=câ for the list entries where you want to apply this layout.
Wolfgang
I commented out the \setupcombinedlist command and placed "alternative=c" into the other \setuplist entries (except for \setuplist[chapter] which has "alternative=interactive"
Then the result is even worse:
* the Introduction entry gets printed strangely like this: "[intro: Inleiding 13]"
* the chapther entries are NOT interactive (black instead of green, but do have bold), and while containing the right entries, they are indented to the right. Other entries do print ok.
If I also set "alternative=c" for the chapter list entry, the other errors go away, but the chapter line again looks like this:
"#1 #2 . . . . . #3"
and interactive (green) but not bold.
Still puzzled…..
You have to write a working minimal example for further help. Wolfgang
You have to write a working minimal example for further help.
Wolfgang
So this is the example: \setupinteraction[state=start] \definehead[intro][chapter] \definehead[back][chapter] \definehead[appendix][chapter] \definecombinedlist[content][chapter,intro,appendix,back] \setupcombinedlist[content][alternative=c] \setupheadtext[content=Inhoud] \setupheadtext[chapter=Hoofdstuk] \setupheadtext[appendix=Bijlage] \setupheadtext[back=Noten] \definefiller[ChapterFiller] \define[1]\MyContentCommand% {\framed[frame=off,offset=none,frameoffset=0pt] {\vbox{\blank[4cm]\Word{#1}}}} \define[1]\MyIntroCommand% {\framed[frame=off,offset=none,frameoffset=0pt] {\vbox{\blank[4cm]\Word{#1}}}} \define[2]\MyChapterCommand% {\framed[frame=off,offset=none,frameoffset=0pt] {\vbox{\blank[4cm]{\small \headtext{chapter} #1}\blank\unhyphenated{#2}}}} \define[1]\MyAppendixCommand% {\framed[frame=off,offset=none,frameoffset=0pt] {\vbox{\blank[4cm]{\small \headtext{appendix}}\blank\unhyphenated{#1}}}} \define[1]\MyBackCommand% {\framed[frame=off,offset=none,frameoffset=0pt] {\vbox{\blank[4cm]{\small \headtext{back}}\blank\unhyphenated{#1}}}} \definefiller[ChapterFiller] \define[1]\ChapterNumberToc% {Hoofdstuk #1 -- } \define[3]\ChapterToc% {\vbox{\bf Hoofdstuk #1 -- #2 \filler[ChapterFiller] #3}} \define[1]\AppendixToc% {Bijlage -- #1} \define[1]\BackToc% {Noten -- #1} \setuphead[intro][number=no,header=nomarking,command=\MyIntroCommand] \setuphead[chapter][header=nomarking,command=\MyChapterCommand,aligntitle=yes,align={flushleft,nothyphenated,verytolerant}] \setuphead[title][command=,textcommand=\MyContentCommand] \setuphead[appendix][number=no,header=nomarking,command=,textcommand=\MyAppendixCommand,align={flushleft,nothyphenated,verytolerant}] \setuphead[back][number=no,header=nomarking,command=,textcommand=\MyBackCommand,align={flushleft,nothyphenated,verytolerant}] \setuplist[chapter][headnumber=yes,style=bold,width=17ex,numbercommand=\ChapterNumberToc] %\setuplist[chapter][headnumber=yes,style=bold,alternative=command,command=\ChapterToc] \setuplist[appendix][headnumber=no,style=bold,textcommand=\AppendixToc] \setuplist[back][headnumber=no,style=bold,textcommand=\BackToc] \starttext \completecontent \startfrontmatter \intro{Intro} \stopfrontmatter \startbodymatter \dorecurse{5}{ \chapter {Knuth} \input knuth \chapter {Zapf} \input zapf} \stopbodymatter \startappendices \appendix{Appendix} \stopappendices \startbackmatter \back{Back} \stopbackmatter \stoptext As you can see, starting from chapter 10 (there are 21 chapters in the real document) there is now no space between the endash and the title, like it is for the first 9 chapters. So, instead of using the numbercommand for the \setuplist[chapter] I tried using: \setuplist[chapter][headnumber=yes,style=bold,alternative=command,command=\ChapterToc] (by uncommenting that line and commenting out the old \setuplist[chapter] with the command \ChapterToc already defined in the MWE. However, that does not produce the desired result. Can you give a clue? Thanks, Rob
Am 04.02.2015 um 15:33 schrieb Rob Heusdens
: You have to write a working minimal example for further help.
Wolfgang
So this is the example:
[…]
You can remove the following lines:
\definefiller[ChapterFiller]
\define[1]\ChapterNumberToc% {Hoofdstuk #1 -- }
\define[3]\ChapterToc% {\vbox{\bf Hoofdstuk #1 -- #2 \filler[ChapterFiller] #3}}
\define[1]\AppendixToc% {Bijlage -- #1}
\define[1]\BackToc% {Noten -- #1}
[…]
and replace these list setups
\setuplist[chapter][headnumber=yes,style=bold,width=17ex,numbercommand=\ChapterNumberToc] %\setuplist[chapter][headnumber=yes,style=bold,alternative=command,command=\ChapterToc] \setuplist[appendix][headnumber=no,style=bold,textcommand=\AppendixToc] \setuplist[back][headnumber=no,style=bold,textcommand=\BackToc]
with the following definitions: \setuplist [chapter] [width=fit,style=bold,numbercommand=\groupedcommand{Hoofdstuk }{ – }] \setuplist [appendix] [style=bold,textcommand=\groupedcommand{Bijlage – }{}] \setuplist [back] [style=bold,textcommand=\groupedcommand{Noten – }{}] Wolfgang
Am 04.02.2015 um 15:33 schrieb Rob Heusdens
: You have to write a working minimal example for further help.
Wolfgang
So this is the example:
[â¦]
You can remove the following lines:
\definefiller[ChapterFiller]
\define[1]\ChapterNumberToc% {Hoofdstuk #1 -- }
\define[3]\ChapterToc% {\vbox{\bf Hoofdstuk #1 -- #2 \filler[ChapterFiller] #3}}
\define[1]\AppendixToc% {Bijlage -- #1}
\define[1]\BackToc% {Noten -- #1}
[â¦]
and replace these list setups
\setuplist[chapter][headnumber=yes,style=bold,width=17ex,numbercommand=\ChapterNumberToc] %\setuplist[chapter][headnumber=yes,style=bold,alternative=command,command=\ChapterToc] \setuplist[appendix][headnumber=no,style=bold,textcommand=\AppendixToc] \setuplist[back][headnumber=no,style=bold,textcommand=\BackToc]
with the following definitions:
\setuplist [chapter] [width=fit,style=bold,numbercommand=\groupedcommand{Hoofdstuk }{ â }] \setuplist [appendix] [style=bold,textcommand=\groupedcommand{Bijlage â }{}] \setuplist [back] [style=bold,textcommand=\groupedcommand{Noten â }{}]
Wolfgang
This works! Thank you Wolfgang. I finally completed my document now! Rob
participants (2)
-
Rob Heusdens
-
Wolfgang Schuster