8

the error

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.

  • It is not Error, just a Warning. Probably you are using math mode in some title section or something and the package hyperref is 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
  • 1
    Could you provide a MWE? It's a bit hard to figure out the issue. From looking at the screenshot it looks like an invalid character – user1729210 Apr 08 '20 at 14:24
  • 1
    You'll need to look at the actual log file instead of what overleaf shows you. One of the things that happens at the start of the document is executing the contents of the aux file. It is very likely thst hyperref is doing some processing at that point either via the aux or one of the other files hyperref uses. I agree with @Sigur that this is likely to come from a section/chapter etc that contains math which cannot directly be converted into unicode. With out more code we cannot help. I would expect there to be at least one more in the document (at the problematic header) – daleif Apr 08 '20 at 14:39
  • Thanks a lot. But I have no idea about how to look at the actual log file to solve the warning, can you teach me something@daleif – zhenjiang wu Apr 08 '20 at 14:51
  • I don't use overleaf, sorry. But start by looking at your headers to see if you have math in them. The warning comes from hyperref generation pdf bookmarks to mimic your table of contents, but pdf bookmarks cannot contain anything but unicode so most math constructions need to be stripped away. Find the headers with math and the look up what the \texorpdfstring command does. – daleif Apr 08 '20 at 16:51
  • (I'm on support staff at Overleaf.) You'd see the same warning whether you use Overleaf or a TeX distribution on your own PC, though it may be presented differently depending on the editor you use. To inspect the full log file, you can download it: https://www.overleaf.com/learn/how-to/View_generated_files or click the "View Raw Logs" button. But as others mentioned, this warning almost always comes from math in headers, so we can't solve it without seeing your code. Look at your headings for math content. You may want to comment sections or move \end{document} to narrow the search space. – Paul Gessler Apr 08 '20 at 17:17
  • Thank you@PaulGessler, but I'm still confused. The line with the error was only written as \begin{document} and there was no math content, why it reported error. – zhenjiang wu Apr 09 '20 at 02:12
  • As others have mentioned: it’s only a warning, not an error. And we can’t say what’s causing it without seeing your code. If you don’t want to post your code here on TeX StackExchange, you can send us your project’s URL to support@overleaf.com and we can take a look. – Paul Gessler Apr 09 '20 at 02:17
  • Thank you@PaulGessler @Sigur. My pretty new to overleaf, and I wonder may I submit my project with this warning? – zhenjiang wu Apr 09 '20 at 02:25

2 Answers2

10

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.

egreg
  • 1,121,712
Peng Qi
  • 101
6

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 
  • I also couldn't get the latter solution to work, getting the same error. But using \def\({} \def\){} in \pdfstringdefDisableCommands helped 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