\newcommand{\filled}[2]{%
#1%
\hfil
#2%
}
\section{\filled{foo}{bar}}
provokes the error. Hyperref goes on to tell you:
It’s not surprising: how would you put the typesetting instructionremoving `\hfil' on input line ...
\hfil into a PDF bookmark?
Hyperref allows you to define an alternative for such
things: the command \texorpdfstring, 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:
\newcommand{\filled}[2]{%
#1%
\texorpdfstring{\hfil}{\space}%
#2%
}
\section{\filled{foo}{bar}}
and with that definition, the example will compile succesfully
(hyperref knows about the macro \space).
This answer was added: 2009-05-29
Go to previous question, or next question
Go to FAQ home.
URL for this question: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=texorpdf
Comments, suggestions, or error reports? - see “how to improve the FAQ”.
This is FAQ version 3.27, released on 2013-06-07.