# Math in subsection title and incorrect PDF sections' sidebar [duplicate]

I have a subsection named \subsection{$Rp_{\widehat{Y},*}(\mathcal{P})$ has property bla and bla}. I would like to keep this as title of my subsection, but it creates problems.

My code is the following.

\documentclass[a4paper,12pt,oneside]{article}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{amsmath,amscd}
\usepackage[english,italian]{babel}
\usepackage{latexsym}
\usepackage{graphicx,subfigure}
\usepackage[a4paper,top=30mm,bottom=30mm,left=30mm,right=30mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\usepackage{hyperref}
\usepackage{accents}
\usepackage[babel]{csquotes}
\usepackage[maxnames=99,style=alphabetic,backend=bibtex]{biblatex}

\begin{document}

\subsection{$Rp_{\widehat{Y},*}(\mathcal{P})$ has property bla and bla}

\end{document}


If I keep it like this, it compiles giving multiple warnings about "Token not allowed in a PDF string". In this case the main problem is that the sidebar index of sections of the outcome PDF carries "RpY"0362Y,*P bla and bla" instead of the correct title with the math.

Furthermore, if I replace \widehat by \hat, it gives the error "Tex capacity exceeded", and it does not compile.

If I replace \subsection{$Rp_{\widehat{Y},*}(\mathcal{P})$ has property bla and bla} (or the version with \hat) with \subsection[just text]{$Rp_{\widehat{Y},*}(\mathcal{P})$ has property bla and bla} then I get no error. On the other hand, I still don't get what I want in the sidebar, since I would really like the math to be there as well.

How can I have the PDF compiling correctly and carrying the right math on the sidebar as well?

## marked as duplicate by Werner math-mode StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Aug 23 '16 at 0:10

• You are limited in terms of what you can add to the bookmarks of a PDF, just because it's not (La)TeX. You should use \texorpdfstring{<tex>}{<pdfstring>} to distinguish between what you want in the document - <tex> - and what you want in the bookmark/index - <pdfstring>. – Werner Aug 23 '16 at 0:10
• i know there has been at least one similar question, but i can't find it. first of all, insert \protect before the commands \widehat and \mathcal; this may not be absolutely necessary, but it's not going to hurt. second, math isn't really supported in bookmarks; you need to specify a \texorpdfstring to accommodate that; some useful information is given in this answer. – barbara beeton Aug 23 '16 at 0:10
• @Werner Also, how does the use of \texorpdfstring differ from the use of \subsection[put the words here]{put the title here}? Thank you! – Stefano Aug 23 '16 at 0:20