Hello. When I use overleaf to write my paper, I encountered this error as shown in picture. Does anyone can help me? Thanks a lot in advance.
2 Answers
I found a discussion here (https://groups.google.com/forum/#!topic/comp.text.tex/SdbZxJ7zX38) that can answer your question.
Yes it is allowed to use math in the section titles. That message is a warning in case you think that the math symbols will show up in the PDF bookmarks. Adobe specified that bookmark text has to be limited to a particular encoding "PDFDocEncoding" that does not support unusual symbols of any kind, including math symbols. Therefore Acrobat Reader will not show your math symbols in the bookmarks, regardless of anything that hyperref can do. In the main text the math formulas will view fine.
In brief,
- It will look fine in the main text.
- The bookmark won't have that symbol or character you want.
- The warning can be avoided as suggested in Hyperref - Token not allowed
The PDF bookmarks are a different thing than the table of contents. The bookmarks are not typeset by TeX: they simply are strings of characters, so no math or general
formatting instructions are allowed.The easiest method to avoid the warnings is to use
\texorpdfstring:\subsection{The classes \texorpdfstring{$\mathcal{L}(\gamma)$}{Lg}}where in the second argument you put the best approximation possible; after all the bookmarks are only a guide for consulting the document.
To suppress hyperref warnings about removing math shift tokens in section headings, I'm using:
\makeatletter
\pdfstringdefDisableCommands{\let\HyPsd@CatcodeWarning\@gobble}
\makeatother
The \texorpdfstring workaround wasn't available in my case, because the section headings were produced by the kramdown LaTeX converter from Markdown headings, and kramdown allows LaTeX commands only inside its math blocks.
Kramdown converts the Markdown heading # Title with $$math$$
to \section{Title with $math$}. Trying to redefine $#1$ (following Can I redefine the dollar) instead of suppressing the warnings:
\makeatletter
\pdfstringdefDisableCommands{\catcode`\$=\active\gdef$#1${\detokenize{#1}}
}
\makeatother
gave me an error:
! Missing control sequence inserted.
<inserted text>
\inaccessible
- 61
-
I also couldn't get the latter solution to work, getting the same error. But using
\def\({} \def\){}in\pdfstringdefDisableCommandshelped me because I had control over the use of$in headings. Perhaps there is a working way to redefine$into\(for you? – mfg Sep 03 '23 at 07:57

hyperrefis warning you that the math in the link could not be exactly as you expect. Don't worry for a while. – Sigur Apr 08 '20 at 14:23\texorpdfstringcommand does. – daleif Apr 08 '20 at 16:51\end{document}to narrow the search space. – Paul Gessler Apr 08 '20 at 17:17