Inserting a mini toc into the chapter heading
I'm stymied! I've looked at Hans' code for inserting a local toc into a chapter heading: http://ml-archives.mini.pw.edu.pl/ntg-context/msg04713.html I just can't get it to generate a local toc. Could someone please run the example. % output=pdftex \setuplist [section] [style=boldslanted, align=left, interaction=all, symbol=1, width=1em, pagenumber=no, before=, after=] \setuphead [chapter] [header=empty, style=BigHeadFont, alternative=command, command=\ContentsHead, page=right, after={\blank[2*big]}] \definefont[BigHeadFont][Serif at 36pt] \def\ContentsHead#1#2% {%\setupframed[frame=off] \framed[width=\hsize,offset=overlay] {\placesidebyside {\doifelsenothing{#1} {\framed[width=.6\hsize]{}} % dummy {\framed [width=.6\hsize,offset=1em,strut=no,align=right,background=screen] {In this chapter: \blank \placelist[section][criterium=chapter]}}} {\framed [width=.4\hsize,offset=1em,strut=no,align=left] {#1\par#2}}}} \starttext \title {Berend} \chapter {Berend} \section {Botje} \section {Botje} \section {Botje} \stoptext I've also a related question: Berend mentions a visual debugger, I want one! (by the way what is a visual debugger).
Hi Guy, a propos visual debugger ... personally I often use \showframe This is usefull, if things are not placed where expected. Willi
At 11:15 AM 2/12/2003 +0100, you wrote:
Hi Guy,
a propos visual debugger ...
personally I often use
\showframe
This is usefull, if things are not placed where expected.
ok then, for the dirty details lovers: \showimplicits \showbaselines \showpagebuilder \showwhatsits (tricky) \showfills \showboxes \showskips \showpenalties plus some 50 other tracing thingies (personally i also have a bunch of \fake<thisorthat>'s) Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
At 03:55 PM 2/11/2003 +0800, you wrote:
I'm stymied!
I've looked at Hans' code for inserting a local toc into a chapter heading:
http://ml-archives.mini.pw.edu.pl/ntg-context/msg04713.html
I just can't get it to generate a local toc. Could someone please run the example.
Here it does generate the toc, but it's obscure because you haven't enables colors: \setupcolors[state=start] ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
Thanks Hans, Your macros at: http://ml-archives.mini.pw.edu.pl/ntg-context/msg04713.html were indeed generating a local toc, and as you guessed I hadn't enabled colors. I've modified your definition slightly, but in doing so I had to resort to plain TeX. The definition now places the Chapter title underneath the table of contexts. This is to cater for longer Chapter titles. My modification, using \llap, is very fragile, in that I've had to hardwire in dimensions. One day soon I'll think in multiple levels of indirection like you do. Again, however I'm stalled. My modification has had the side-effect that the chapter number which is the most important navigation aid, now commands little respect. I'd like to elevate its status, by pushing it up into the top-right corner (even perhaps slightly out into the margin) and increasing its weight to extra bold. I tried to increase the weight by using cmssbx10, but had no luck. Here's my attempt: % output=pdftex %% chapter head layout \setupcolors[state=start] \setuplist[section] [style=boldslanted, align=right, interaction=all, symbol=1, width=0.5em, pagenumber=no, before=, after=] \setuphead[chapter] [header=empty, style=BigHeadFont, alternative=command, command=\ContentsHead, page=right, after={\blank[2*big]}] \definefont[BigHeadFont][Serif at 36pt] \font\BigHeadNumberFont=cmssbx10 at 36pt \def\ContentsHead#1#2% {\setupframed[frame=off] \framed[width=\hsize,offset=overlay] {\placesidebyside {\doifelsenothing{#1} {\framed[width=.6\hsize]{}} % dummy {\framed [width=.6\hsize,offset=1em,strut=no,align=right,background=screen] {{\tfa In this chapter:} \blank \placelist[section][criterium=chapter]}}} {\framed [width=.4\hsize,offset=1em,strut=no,align=left] {{\BigHeadNumberFont #1}}}} \llap{\lower43.2pt\hbox{#2\hskip1em}}} % 36pt x 1.2 \starttext \chapter {Berend} \section {Botje} \section {Botje} \section {Botje} \stoptext
Just following up on my own post. The following code has the effect I was after. If you want to use it as a template, you'd be advised to read my method in constructing such ugliness. To remind you, I want to increase the font weight of the chapter number, but not increase the font weight of the chapter title. Thus, facing my usual dilemma -- so many commands and no f*cking clues, I added the \string command immediately before the parameter containing the chapter number, #1, to see what #1 actually contained. If you do this, you'll see that #1 contains something else, infact #1 starts out as ``dostartattributes@@ko ... ''. I've no idea how to read the source code, so at this point, I decided to redefine my chapter style parameter \BigHeadFont locally, before #1 is expanded. And so, if you read the code, you'll see a font definition \definefont[BigHeadFont][SerifBold at 40pt] buried deep within the code. This seems to work, although redefining font definitions on the fly is probably not good practice. I also wanted to move the chapter number, up to the top right hand corner of the main text area. I did this increasing the amount of glue until the number was pushed outside its box. Here is the code: %% chapter head layout \setupcolors[state=start] \setuplist[section] [style=boldslanted, align=right, interaction=all, symbol=1, width=0.5em, pagenumber=no, before=, after=] \setuphead[chapter] [header=empty, style=BigHeadFont, alternative=command, command=\ContentsHead, page=right, after={\blank[2*big]}] \definefont[BigHeadFont][Serif at 24.9pt] \def\ContentsHead#1#2% {\setupframed[frame=off] \framed[width=\hsize,offset=overlay] {\placesidebyside {\doifelsenothing{#1} {\framed[width=.6\hsize]{}} % dummy {\framed [width=.6\hsize,offset=1em,strut=no,align=right,background=screen] {{\tfa In this chapter:} \blank \placelist[section][criterium=chapter]}}} {\framed [width=.4\hsize,strut=no,align=left] {\definefont[BigHeadFont][SerifBold at 40pt] %% Typeset Chapter Number \hbox{% \vbox to 24.9pt{% size of BigHeadFont \vss #1}}} \vfilll}} %% Typeset Chapter Title \llap{\lower29.9pt\hbox{#2\hskip1em}}} % 24.9pt x 1.2 \starttext %\showmakeup \chapter {Berend} \section {Botje} \section {Botje} \section {Botje} \stoptext
At 11:04 AM 2/13/2003 +0800, Guy Worthington wrote:
number, but not increase the font weight of the chapter title. Thus, facing my usual dilemma -- so many commands and no f*cking clues, I added the \string command immediately before the parameter containing the chapter number, #1, to see what #1 actually contained.
how about using numberstyle=... textstyle=... instead of style=
If you do this, you'll see that #1 contains something else, infact #1 starts out as ``dostartattributes@@ko ... ''. I've no idea how to
right, #1 is something raher tex Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
Thanks Hans, splitting the [style=...] option in the \setuphead[] macro, into the [numberstyle=...,textstyle=...] options, was the last piece in the jigsaw, for chapter headings (I hope).
For all you propeller-heads that like to see bad code here's my chapter heading setup: -------------------------------------------------- %output=pdf %% chapter head layout \setupcolors[state=start] \setuplist[section] [style=boldslanted, align=right, interaction=all, symbol=1, width=0.5em, pagenumber=no, before=, after=] \setuphead[chapter] [header=empty, numberstyle=ChapterTitleNumberFont, textstyle=ChapterTitleTextFont alternative=command, command=\ContentsHead, page=right, after={\blank[2*big]}] \definefont[ChapterTitleTextFont][Serif at 24.9pt] \definefont[ChapterTitleNumberFont][SerifBold at 40pt] \def\ContentsHead#1#2% {\setupframed[frame=off] \framed[width=\hsize,offset=overlay] {\placesidebyside {\doifelsenothing{#1} {\framed [width=.6\hsize]{}} % dummy {\framed [width=.6\hsize,offset=1em,strut=no,align=right, background=screen] {\vi In this chapter: \blank \placelist[section][criterium=chapter]}}} {\framed [width=.4\hsize,strut=no,align=left] %% Typeset Chapter Number {\hbox{\vbox to 24.9pt{% height ChapterTitleTextFont \vss #1}}} \vfilll} }% %% Typeset Chapter Title \llap{\lower24.9pt\hbox{#2\hskip0.5em}}} \showmakeup \starttext \chapter {Berend} \section {Botje} \section {Botje} \section {Botje} \stoptext --------------------------------------------------
At 09:10 PM 2/14/2003 +0800, you wrote:
For all you propeller-heads that like to see bad code here's my chapter heading setup:
--------------------------------------------------
%output=pdf
%% chapter head layout \setupcolors[state=start] \setuplist[section] [style=boldslanted, align=right, interaction=all, symbol=1, width=0.5em, pagenumber=no, before=, after=] \setuphead[chapter] [header=empty, numberstyle=ChapterTitleNumberFont, textstyle=ChapterTitleTextFont alternative=command, command=\ContentsHead, page=right, after={\blank[2*big]}] \definefont[ChapterTitleTextFont][Serif at 24.9pt] \definefont[ChapterTitleNumberFont][SerifBold at 40pt] \def\ContentsHead#1#2% {\setupframed[frame=off]
^ add % here to prevent spurious space
\framed[width=\hsize,offset=overlay] {\placesidebyside {\doifelsenothing{#1}
or \doifmodeelse{*sectionnumber}
{\framed [width=.6\hsize]{}} % dummy {\framed [width=.6\hsize,offset=1em,strut=no,align=right, background=screen] {\vi In this chapter: \blank \placelist[section][criterium=chapter]}}} {\framed [width=.4\hsize,strut=no,align=left] %% Typeset Chapter Number {\hbox{\vbox to 24.9pt{% height ChapterTitleTextFont \vss #1}}} \vfilll} }% %% Typeset Chapter Title \llap{\lower24.9pt\hbox{#2\hskip0.5em}}}
\showmakeup
i didn't look how it looks (so i will not comment on that) about bad code: you will always need some low level coding to achieve certain effects; also the code does not look that bad -) Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
Thanks for posting this Guy. Looks good (though the bullet in the TOC looks kind of cramped in relation to the text entry). This is just the kind of "code that actually" works example I love to see (since I could not do something like on my own, or simply looking at code snippets in a manual). Can you explain the below if you have a chance Hans? On Friday, February 14, 2003, at 08:32 AM, Hans Hagen wrote:
{\setupframed[frame=off] ^ add % here to prevent spurious space
If I am reading the above right, you are suggesting {\setupframed%[frame=off], but that doesn't seem right. Bruce
Bruce D'Arcus said this at Fri, 14 Feb 2003 08:50:34 -0500:
On Friday, February 14, 2003, at 08:32 AM, Hans Hagen wrote:
{\setupframed[frame=off] ^ add % here to prevent spurious space
If I am reading the above right, you are suggesting {\setupframed%[frame=off], but that doesn't seem right.
I think he means: {\setupframed[frame=off]% to avoid the newline/whitespace between here and the next line. adam -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Adam T. Lindsay atl@comp.lancs.ac.uk Computing Dept, Lancaster University +44(0)1524/594.537 Lancaster, LA1 4YR, UK Fax:+44(0)1524/593.608 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Hi Bruce, Sorry when I give an answer to this ... In Context you are allowed to add a linefeed after \setupframed in order to put the [...] options on a new line indented. To prevent spurious spaces if the options follow on the next line you are adviced to add a % after \setupframed%. Willi
On Friday, February 14, 2003, at 08:32 AM, Hans Hagen wrote:
{\setupframed[frame=off] ^ add % here to prevent spurious space
If I am reading the above right, you are suggesting {\setupframed%[frame=off], but that doesn't seem right.
At 09:15 PM 2/14/2003 +0100, Willi Egger wrote:
Hi Bruce,
Sorry when I give an answer to this ...
In Context you are allowed to add a linefeed after \setupframed in order to put the [...] options on a new line indented. To prevent spurious spaces if the options follow on the next line you are adviced to add a % after \setupframed%.
actually, no space is needed after a \cs \def\mymacro {\something \more \\% 2 char cs, space is obeyed \setupthis[this]% \setupthat[that] [more]% \ifnum\aaa=\bbb % if \bbb=counter/chardef \ifnum\aaa=\bbb\relax % if \bbb is macro \ifnum\aaa=0 idem for ifdim etc, but \ifskip\aaa=\bbb\relax % to prevent lookahead etc esp dangerous is \dimexpr(..) since this has a confusing lookahead (and syntax as well) Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
participants (6)
-
Adam Lindsay
-
Bruce D'Arcus
-
Guy Worthington
-
Hans Hagen
-
Patrick Gundlach
-
Willi Egger