I used \dotfill to add dotted lines to certain chapters (list of figures, for example) in the table of contents. (Adding \dotfill manually with \addcontentsline) Everything worked all right but now these characters were added to the bookmarks which correspond to the chapters for which I added the dotted lines in the TOC: to.44em. What could be the cause?
-
1(1)welcome , (2) as always on this site, please provide a full minimal, but minimal, example of this that others can test without having to add anything. – daleif May 12 '17 at 05:50
2 Answers
\dotfill does not work inside bookmarks, see the quote in jleon's answer.
As alternative to \texorpdfstring, macros can be redefined, when the bookmark text is processed by hyperref. The following example replaces \dotfill by three dots:
\usepackage{hyperref}
\pdfstringdefDisableCommands{\def\dotfill{...}}
- 271,626
As stated in Wikibooks:
Problems with bookmarks The text displayed by bookmarks does not always look like you expect it to look. Because bookmarks are "just text", much fewer characters are available for bookmarks than for normal LaTeX text. You can now work around this problem by providing a text string for the bookmarks, which replaces the offending text:
\texorpdfstring{''TEX text''}{''Bookmark Text''}
So my \dotfill option did add a dotted line for the TOC purposes, but at the same time it added to.44em. at the end of the correspondent bookmarks. The hint was found here. The solution was to use \texorpdfstring:
\addcontentsline{toc}{chapter}{\texorpdfstring{My Chapter\dotfill}{My Chapter}}
- 26
-
It looks like you've got two separate accounts, which means you cannot edit your original post or leave comments. The Stack Exchange staff can merge them together for you. – Moriambar May 12 '17 at 21:14