bookmarks using linebreaks in chapter titles
I was trying out line breaks for long titles (at least, long when set in 36 or 48pt text), as well as have pdf bookmarks, so I defined a \1 shorthand local to the chapter heading: ====================================================================== \setupinteraction[state=start] \placebookmarks[chapter] \setupinteractionscreen[option=bookmark] \setuphead[chapter][before={\bgroup\def\1{\hfil\break}}, after={\egroup}] \starttext \chapter{Long\1 title} hello \stoptext ====================================================================== If I inline the \1, as in \chapter{Long\hfil\break title}, then it's mostly fine except that the bookmark has "hfil penalty ..." Is there's another way to avoid that problem? Perhaps a magic option that says what the bookmark should be, the way one can tell \index what to typeset in the index when it is different from the inline text. One solution is to forbid hyphens during the \chapter (with before= and after= definitions) and also shrink the \hsize enough so that tex line breaks where I want, but that method requires unintuitive, fontsize-dependent dimension guessing for each chapter. Putting in line breaks by hand is not too bad. Plus one might want to break the lines according to meaning, which does not always produce the same results as where breaks would go according to line length. But meanwhile trying the hack method above, I get this error (./q.tuo) (./q.tuo) ! Undefined control sequence. <argument> Long\1 title \sanitizePDFdocencoding ...docencoding \edef #2{#1 } \doPDFinsertbookmark ...oding #3\to \bookmarktext \stripstring \bookmarktext.. \doplacebookmarks ...okmarkelement \flushbookmark \egroup \else \expanded {\.. <to be read again> \setupinteractionscreen l.3 \setupinteractionscreen [option=bookmark] It's from this line in q.tuo \listentry{chapter}{1}{1}{Long\1 title}{2--0-1-0-0-0-0-0--1}{1} and the \1 is not defined during \listentry, only during the \chapter. I didn't have a problem when the same code was part of a product (each component being chapter in a book, with the \setuphead in an environment file) -- only had it when I compiled one component, which is how I got to the test case above. [All with ConTeXt ver: 2006.10.24 13:47 MK II fmt: 2006.10.24] -Sanjoy
On Thu, 2 Nov 2006, Sanjoy Mahajan wrote:
I was trying out line breaks for long titles (at least, long when set in 36 or 48pt text), as well as have pdf bookmarks, so I defined a \1 shorthand local to the chapter heading:
Maybe I am missing something here, but why not just use \\. Inside titles it is defined as \crlf\ignorespaces
====================================================================== \setupinteraction[state=start] \placebookmarks[chapter] \setupinteractionscreen[option=bookmark]
\setuphead[chapter][before={\bgroup\def\1{\hfil\break}}, after={\egroup}]
\starttext \chapter{Long\1 title} hello
\stoptext ======================================================================
If I inline the \1, as in \chapter{Long\hfil\break title}, then it's mostly fine except that the bookmark has "hfil penalty ..." Is there's another way to avoid that problem? Perhaps a magic option that says what the bookmark should be, the way one can tell \index what to typeset in the index when it is different from the inline text.
Usual way is \appendtoks\def\1{}\to\simplifiedcommands but something seems to be broken. It seems that you can not use "any" macro inside a chapter title, while using bookmarks. Here is a simple test file. \setupinteraction[state=start] \placebookmarks[chapter] \setupinteractionscreen[option=bookmark] \def\macro{long word} \starttext \chapter{Long\macro title} \stoptext I get same error as you (ConTeXt ver: 2006.11.01 09:59 MK II)
One solution is to forbid hyphens during the \chapter (with before= and after= definitions) and also shrink the \hsize enough so that tex line
You do not require before...after for this. Something like \setuphead[chapter][align={nothyphenated,stretch,tolerant}] should work.
breaks where I want, but that method requires unintuitive, fontsize-dependent dimension guessing for each chapter. Putting in line breaks by hand is not too bad. Plus one might want to break the lines according to meaning, which does not always produce the same results as where breaks would go according to line length.
I agree, for headings, it is better to do linebreak by hand.
But meanwhile trying the hack method above, I get this error
(./q.tuo) (./q.tuo) ! Undefined control sequence. <argument> Long\1 title \sanitizePDFdocencoding ...docencoding \edef #2{#1 } \doPDFinsertbookmark ...oding #3\to \bookmarktext \stripstring \bookmarktext..
\doplacebookmarks ...okmarkelement \flushbookmark \egroup \else \expanded {\.. <to be read again> \setupinteractionscreen l.3 \setupinteractionscreen [option=bookmark]
It's from this line in q.tuo
\listentry{chapter}{1}{1}{Long\1 title}{2--0-1-0-0-0-0-0--1}{1}
and the \1 is not defined during \listentry, only during the \chapter.
I didn't have a problem when the same code was part of a product (each component being chapter in a book, with the \setuphead in an environment file) -- only had it when I compiled one component, which is how I got to the test case above.
[All with ConTeXt ver: 2006.10.24 13:47 MK II fmt: 2006.10.24]
-Sanjoy
On Fri, 3 Nov 2006 01:08:46 -0500 (EST)
Aditya Mahajan
On Thu, 2 Nov 2006, Sanjoy Mahajan wrote:
I was trying out line breaks for long titles (at least, long when set in 36 or 48pt text), as well as have pdf bookmarks, so I defined a \1 shorthand local to the chapter heading:
Maybe I am missing something here, but why not just use \\. Inside titles it is defined as \crlf\ignorespaces
====================================================================== \setupinteraction[state=start] \placebookmarks[chapter] \setupinteractionscreen[option=bookmark]
\setuphead[chapter][before={\bgroup\def\1{\hfil\break}}, after={\egroup}]
\starttext \chapter{Long\1 title} hello
\stoptext ======================================================================
If I inline the \1, as in \chapter{Long\hfil\break title}, then it's mostly fine except that the bookmark has "hfil penalty ..." Is there's another way to avoid that problem? Perhaps a magic option that says what the bookmark should be, the way one can tell \index what to typeset in the index when it is different from the inline text.
Usual way is
\appendtoks\def\1{}\to\simplifiedcommands
but something seems to be broken. It seems that you can not use "any" macro inside a chapter title, while using bookmarks. Here is a simple test file.
\setupinteraction[state=start] \placebookmarks[chapter] \setupinteractionscreen[option=bookmark]
\def\macro{long word}
\starttext \chapter{Long\macro title} \stoptext
You can also make a extra bookmarkentry by hand. \starttext \chapter{A rather long title} \bookmark{Short title} \stoptext
I get same error as you (ConTeXt ver: 2006.11.01 09:59 MK II)
One solution is to forbid hyphens during the \chapter (with before= and after= definitions) and also shrink the \hsize enough so that tex line
You do not require before...after for this. Something like
\setuphead[chapter][align={nothyphenated,stretch,tolerant}]
should work.
breaks where I want, but that method requires unintuitive, fontsize-dependent dimension guessing for each chapter. Putting in line breaks by hand is not too bad. Plus one might want to break the lines according to meaning, which does not always produce the same results as where breaks would go according to line length.
I agree, for headings, it is better to do linebreak by hand.
But meanwhile trying the hack method above, I get this error
(./q.tuo) (./q.tuo) ! Undefined control sequence. <argument> Long\1 title \sanitizePDFdocencoding ...docencoding \edef #2{#1 } \doPDFinsertbookmark ...oding #3\to \bookmarktext \stripstring \bookmarktext..
\doplacebookmarks ...okmarkelement \flushbookmark \egroup \else \expanded {\.. <to be read again> \setupinteractionscreen l.3 \setupinteractionscreen [option=bookmark]
It's from this line in q.tuo
\listentry{chapter}{1}{1}{Long\1 title}{2--0-1-0-0-0-0-0--1}{1}
and the \1 is not defined during \listentry, only during the \chapter.
I didn't have a problem when the same code was part of a product (each component being chapter in a book, with the \setuphead in an environment file) -- only had it when I compiled one component, which is how I got to the test case above.
[All with ConTeXt ver: 2006.10.24 13:47 MK II fmt: 2006.10.24]
-Sanjoy
ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Thanks Aditya and Wolfgang for the information. I've added it all to the wiki http://wiki.contextgarden.net/PDF_Bookmarks_and_Headers so let me know if you find any problems there. I noticed two possible bugs when trying out a few examples -- see below.
If I inline the \1, as in \chapter{Long\hfil\break title}, then it's mostly fine except that the bookmark has "hfil penalty ..." Usual way is \appendtoks\def\1{}\to\simplifiedcommands
Thanks, that's useful (and now I found it elsewhere in the wiki).
One solution is to forbid hyphens during the \chapter (with before= and after= definitions) and also shrink the \hsize enough so that tex line
You do not require before...after for this. Something like
\setuphead[chapter][align={nothyphenated,stretch,tolerant}]
should work.
You can also make a extra bookmarkentry by hand. \starttext \chapter{A rather long title} \bookmark{Short title} \stoptext
Also useful and wikified. Now for the two possible bugs. 1. An empty chapter breaks \bookmark: ============================================================ \setupinteraction[state=start] \placebookmarks[chapter] \setupinteractionscreen[option=bookmark] \starttext \chapter{A very long chapter\\ about splines} \bookmark{Splines} \stoptext ============================================================ The bookmark text is "A very long chapter about splines". But adding a letter or word to the chapter body fixes that: ============================================================ \setupinteraction[state=start] \placebookmarks[chapter] \setupinteractionscreen[option=bookmark] \starttext \chapter{A very long chapter\\ about splines} \bookmark{Splines} hello \stoptext ============================================================ 2. The second problem is perhaps my misunderstanding. The wiki page said to use \placebookmarks[chapter,section,subsection][chapter] to make only chapter bookmarks visible. But I find that chapter bookmarks are open by default in the bookmark window, so I tried the following example instead: ============================================================ \setupinteraction[state=start] \placebookmarks[chapter,section,subsection][chapter,section] \setupinteractionscreen[option=bookmark] \starttext \chapter{The beginning} Hi! \chapter{A very, very\\ long title} Greetings! \section{Why so long} I don't know \subsection{Why not?} Good point. \chapter{The never-ending story} Oh no. \chapter{The never-ending story} \bookmark{Forever!} Oh no. \stoptext ============================================================ I expected chapter and section bookmarks to be open, which they were, but so were the subsection bookmarks. And \placebookmarks[chapter,section,subsection][chapter] made chapter and section bookmarks open. Is there an 'off by one' error \placebookmarks? Or have I misunderstood the purpose of the command (I'll then fix the wiki)? 3. And a third question is whether the bookmark window is open by default. I use xpdf (Ubuntu Linux) and it always opens the bookmark window, whether or not \setupinteractionscreen[option=bookmark] is given. Perhaps that's an xpdf-specific behavior but acroread acts differently? -Sanjoy `Never underestimate the evil of which men of power are capable.' --Bertrand Russell, _War Crimes in Vietnam_, chapter 1.
Sanjoy Mahajan wrote:
Now for the two possible bugs.
1. An empty chapter breaks \bookmark:
============================================================ \setupinteraction[state=start] \placebookmarks[chapter] \setupinteractionscreen[option=bookmark] \starttext \chapter{A very long chapter\\ about splines} \bookmark{Splines} \stoptext ============================================================
The bookmark text is "A very long chapter about splines". But adding a letter or word to the chapter body fixes that:
indeed, bookmarks are flushed at the next paragraph, otherwise they would end up at undefined places Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
The bookmark text is "A very long chapter about splines". But adding a letter or word to the chapter body fixes that:
indeed, bookmarks are flushed at the next paragraph, otherwise they would end up at undefined places
Good point. Does the \bookmark then belong before the \chapter or \section, in case the section ends up as the last line on a page? -Sanjoy `Never underestimate the evil of which men of power are capable.' --Bertrand Russell, _War Crimes in Vietnam_, chapter 1.
participants (4)
-
Aditya Mahajan
-
Hans Hagen
-
Sanjoy Mahajan
-
Wolfgang Schuster