8
\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}

\usepackage[bookmarksnumbered=true]{hyperref}
\hypersetup{
%   bookmarks=true,           % show bookmarks bar?
    bookmarksopen=true,
    unicode=true             % non--Latin characters in Acrobat’s bookmarks
}


\begin{document}
\listoffigures

\section{
    \texorpdfstring{Math symbols $\sum, \int$}%
    {Math symbols sum, integral}
}
\section{Example: %
\texorpdfstring{$\{[\phi(t),p(\cdot)]\}$}
    {$\{[\textphi(t),p(\textcdot)]\}$}
}

\section{Example: %
\texorpdfstring{$[\phi(t),p(\cdot)]$}
    {$\{[\textphi(t),p(\textcdot)]\}$}
}


\end{document}

I have several section/subsection headings with math expressions like the above. Is there a way to make a general definition of \phi (or lambda or any other maths notation), so that \phi is a math symbol in the article and a text phi in bookmark?

If I have to do this every time, that means I have to write all section names twice, which was a bit unpleasant.

1 Answers1

7

Most symbols are available in Unicode except for the subscript C:

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}

\usepackage[
  bookmarksnumbered=true,
  psdextra,
]{hyperref}
\usepackage{bookmark}
\hypersetup{
  bookmarksopen=true,
  unicode=true             % non--Latin characters in Acrobat’s bookmarks
}

\begin{document}
\listoffigures  

\section{Math symbols $\sum, \int$}
\section{$\{\phi(t), p(\cdot)\}$}  
\section{$\{\phi(t), p(t)\}$}
\section{$\{[\phi(t + h), \lambda(t + h)]\texorpdfstring_{\_}C\}$}

\end{document}

Result

Then the warnings

Package hyperref Warning: Token not allowed in a PDF string (Unicode):
(hyperref)                removing `math shift' on input line 17.

can be ignored. They can be removed by using \ensuremath{...} instead of $...$.

Option psdextra adds support for many, many math symbols. Package bookmark improves the update behavior (and provides more features).

Character shapes in bookmarks

The bookmarks are displayed with a font, which the PDF viewer chooses, the PDF file only contains a simple string (with encoding PDFDocEncoding or Unicode). The case of \phi is ambiguous, because it could stand for several Unicode code points:

  • φ U+03C6 GREEK SMALL LETTER PHI
  • ϕ U+03D5 GREEK PHI SYMBOL
  • ɸ U+0278 LATIN SMALL LETTER PHI

hyperref maps \phi to \textphi, which uses the text variant U+03C6. It can be redefined to return the math symbol U+03D5:

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}

\usepackage[
  bookmarksnumbered=true,
  psdextra,
]{hyperref}
\usepackage{bookmark}
\hypersetup{
  bookmarksopen=true,
  unicode=true             % non--Latin characters in Acrobat’s bookmarks
}
\pdfstringdefDisableCommands{%
  \def\phi{\unichar{"03D5}}%
}

\begin{document}
\listoffigures

\section{Math symbols $\sum, \int$}
\section{$\{\phi(t), p(\cdot)\}$}
\section{$\{\phi(t), p(t)\}$}
\section{$\{[\phi(t + h), \lambda(t + h)]\texorpdfstring_{\_}C\}$}

\end{document}

Result

Heiko Oberdiek
  • 271,626