19

I have a section heading which includes an epsilon. Furthermore I am using the "hyperref" package to create links in my PDF document.

When compiling I get a strange warning that a math symbol is not allowed in a PDF string, e.g. Token not allowed in a PDF string (PDFDocEncoding): (hyperref) removing \varepsilon on input line 6.

However, if I open the compiled PDF there are no obvious errors and all links are clickable. Am I missing something, or can I just ignore this warning? Are there any alternatives to achieve the same result?

\documentclass{article}
\usepackage{hyperref}

\begin{document}
\tableofcontents
\section{$\varepsilon$SOA}

Text about $\varepsilon$SOA.

\end{document}

Screenshot of the compiled example

Thanks in advance!

lenxn
  • 373
  • 2
    In the pdf, the link itself (such as the one you see under Bookmarks in Adobe Reader) will not be able to display special characters. Check \texorpdfstring{}{} in hyperref manual. – Fato39 Jun 22 '15 at 09:28
  • 2
    Hi, \section{\texorpdfstring{$\varepsilon$}{e}SOA} is what you are looking for. It has been discussed here before, I'll try to find it. – yo' Jun 22 '15 at 09:29
  • 2
    Related / possible duplicate: 1 2 – yo' Jun 22 '15 at 09:33

1 Answers1

31
  • Option pdfencoding=auto or unicode enables bookmarks in Unicode with more symbols.

  • Option psdextra defines lots of math symbols, however it misses \varepsilon.

  • Then \pdfstringdefDisableCommands can be used to define a bookmark replacement string for commands.

Full example:

\documentclass{article}
\usepackage[pdfencoding=auto, psdextra]{hyperref}
\pdfstringdefDisableCommands{\def\varepsilon{\textepsilon}}
\usepackage{bookmark}% faster updated bookmarks

\begin{document}
\tableofcontents
\section{$\varepsilon$SOA}

Text about $\varepsilon$SOA.

\end{document}

If the warnings about math shift should also be removed, then \texorpdfstring helps:

\section{\texorpdfstring{$\varepsilon$}{\textepsilon}SOA}
Heiko Oberdiek
  • 271,626
  • 2
    WHAT? I've been using \texorpdfstring{} this whole time when I could have used pdfencoding=auto? Dammit. – Canageek Jul 30 '15 at 17:43
  • Thanks for the combination to remove LaTeX warnings, which I want to keep at 0 (to get the green (instead of red) line at the end of my compile script :-)) – AstroFloyd Nov 15 '21 at 11:21