blob: 84758f910ae177434dafdfd8ed10f319f91b0681 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
<head>
<title>UK TeX FAQ -- question label texorpdf</title>
</head><body>
<h3>Token not allowed in PDFDocEncoded string</h3>
<p/>The package <i>hyperref</i> produces this error when it doesn’t
know how to make something into a “character” that will go into one
of its PDF entries. For example, the (unlikely) sequence
<blockquote>
<pre>
\newcommand{\filled}[2]{%
#1%
\hfil
#2%
}
\section{\filled{foo}{bar}}
</pre>
</blockquote><p>
provokes the error. <i>Hyperref</i> goes on to tell you:
<blockquote>
<pre>
removing `\hfil' on input line ...
</pre>
</blockquote><p>
It’s not surprising: how would <em>you</em> put the
typesetting instruction <code>\</code><code>hfil</code> into a PDF bookmark?
<p/><i>Hyperref</i> allows you to define an alternative for such
things: the command <code>\</code><code>texorpdfstring</code>, which takes two
arguments — the first is what is typeset, the second is what is put
into the bookmark. For example, what you would probably like in this
case is just a single space in the bookmark; if so, the erroneous
example above would become:
<blockquote>
<pre>
\newcommand{\filled}[2]{%
#1%
\texorpdfstring{\hfil}{\space}%
#2%
}
\section{\filled{foo}{bar}}
</pre>
</blockquote><p>
and with that definition, the example will compile succesfully
(<i>hyperref</i> knows about the macro <code>\</code><code>space</code>).
<p><em>This answer was added: 2009-05-29</em></p>
<p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=texorpdf">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=texorpdf</a>
</body>
|