alternative text to be displayed in the PDF viewer's table of content

I use the hyperref and the bookmark package. Hence the table of content (toc) of the document gets also displayed in the side bar of the PDF reader, when viewing the generated document.

My problem is now that I have mathematical expressions in the headlines of some sections, which then are of course not properly displayed in the toc at the side bar of the PDF viewer. For instance the entry

in the documents table of content gets displayed as

in the side bar of the PDF viewer. I know that it is not possible to have the correct mathematical expression written there, but I would for instance like to have X_VIII instead of XVIII.

Another problem i have is that in some headers I added a \vspace{8pt}, and sadly the 8pt is then displayed in the side bar of the PDF viewer:

Therefore my question: Is there a way to manually specify the text to appear in the side bar of the PDF to each section/subsection, etc.?

-

Apart from that \vspace should not be used in section titles (they also go into the table of contents and the headers), it can be disabled using \pdfstringdefDisableCommands in the bookmarks.

The mathematical expression is more difficult. Switching to Unicode for the bookmarks helps, because PDFDocEncoding is quite limited. But there are no subscripts for capital letters V and I, only lowercase letters and I could not found an uppercase \mathcal{X}, only

U+1D4E7: MATHEMATICAL BOLD SCRIPT CAPITAL X


That looks at least close. A different representation for the bookmarks can be provided by \texorpdfstring inside the bookmarks:

\documentclass{article}
\usepackage[pdfencoding=auto,psdextra]{hyperref}[2012/08/13]
\usepackage{bookmark}
\bookmarksetup{
numbered,
open
}
\usepackage{amstext}% or amsmath

% disable \vspace in bookmarks
\pdfstringdefDisableCommands{%
\renewcommand*{\vspace}[1]{}%
}

\begin{document}

\tableofcontents

\section[Introduction]{Introduction\vspace{8pt}}
\section{Second section}
\subsection{First subsection}
\subsection{Second subsection}
\subsection{The state space
\texorpdfstring{$\mathcal{X}_{\text{VIII}}$}{%
\unichar{"1D4E7}\vinferior\iinferior\iinferior\iinferior/%
X\textunderscore VIII%
}%
}

\end{document}


If \vinferior or \iinferior are not used, then also an older hyperref will do. Option psdextra in the newer hyperref allows the abbreviation \vinferior and \iinferior instead of \textvinferior and \textiinferior.

-
Thanks for your great help! The disabeling of the \vspace in the bookmarks worked just fine, thx. I however do not seem to have the state of the art version of the hypereff package, since it does not know the psdextra option. So I didn't bring this to work yet and first have to find out how to upgrade the package. I will reply again if I have managed this. Or can you maybe tell me how I do that? (I am on a Mac and have MacTex 2011 and Texive-2011 installed.) – Britzel Sep 17 '12 at 15:07
The second version replacement string X\textunderscore VIII also works for older hyperref versions. – Heiko Oberdiek Sep 17 '12 at 15:14
Without the \texorpdfstring command it is displayed the right way in the viewer, but also displayed with an underscore in the toc itself, which shouldn't be. With the \texorpdfstring command I get an error. The used codeline is \addcontentsline{toc}{subsection}{\numberline{2.3}{\sf \hspace{-34.5pt}The state space \texorpdfstring{$\mathcal X$\textunderscore VIII}}}. Probably I am doing something wrong here. – Britzel Sep 17 '12 at 17:15
\texorpdfstring has two arguments, see the example in the answer. It is also explained in the manual of hyperref. – Heiko Oberdiek Sep 17 '12 at 17:42
Sorry, I was cross eyed! It works fine now :). Thanks a lot! – Britzel Sep 17 '12 at 21:55