0

This question already has an answer here:

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 Aug 23 '16 at 0:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    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
  • 1
    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 So there is no way the bookmark will displaythe math I want, right? – Stefano Aug 23 '16 at 0:16
  • 1
    @Stefano: Most likely no, since the bookmarks are text-based. – Werner Aug 23 '16 at 0:20
  • @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