0

I get a compilation warning whenever I use $...$ signs in headings and subheadings. Is there any way to remove these errors?

The code that I use is given below:

\subsection{Solving $\widetilde{(Ric_\phi^m)}_{I\infty}=0$}

I am attaching the error messages below. These disappear when I remove the $...$ signs in the subheading

enter image description here

David Carlisle
  • 757,742
freebird
  • 3
  • 2
  • 2
    Welcome to TeX.SE! Please show us a short compilable TeX code resulting in your error ... – Mensch Nov 18 '21 at 19:37
  • 1
    What the error say? Post it please, with your code. – mmr Nov 18 '21 at 19:51
  • 1
    the error will not be from $ but from the commands that you have between them, since you have neither shown your input nor the error message that you got it is hard to help but my guess would be that you have an old latex and you need to use \protect in front of some commands such as \sqrt – David Carlisle Nov 18 '21 at 20:15
  • I have now added the code and error messages. @mmr – freebird Nov 18 '21 at 20:32
  • 1
    they are warnings not errors (orange not red in the Overleaf GUI) If you removed the $ from the heading while leaving the commands you would get errors and no sensible output at all, so as noted above these warnings come from the commands used not the $ They just warn you that hyperref can not automatically make the plain text version of the heading for the pdf bookmark if the bookmark is OK you can ignore the warning or see the hyperref manual for commands to supply the bookmark text explicitly. – David Carlisle Nov 18 '21 at 20:40
  • 2
    The error you report is related to an attempt by hyperref to create a bookmark. It is undoubtedly related to the fact that \widetilde is not recognized in this context. What you need to do is translate the math expression to a \texorpdfstring{$...$}{<text equivalent>}. There are other questions here that might give useful information. – barbara beeton Nov 18 '21 at 20:51
  • @barbarabeeton- That solved my problem. I don't really understand why this solution works, though. – freebird Nov 18 '21 at 21:16
  • 2
    to make a bookmark (the links in the left sidebar in most pdf viewers) latex needs to make plain text with no typesetting commands, it doesn't know what to do with widetilde so it simply drops most of the commands in the definition, if you use \texorpdfstring{$abc$}{zzz} latex does not attempt the conversion at all, it typesets $abc$ in the main document and uses the supplied text zzz in the bookmark – David Carlisle Nov 18 '21 at 22:37

1 Answers1

3

The error you report is related to an attempt by hyperref to create a bookmark (the links in the left sidebar in most PDF viewers). It is undoubtedly related to the fact that hyperref doesn't recognize \widetilde and thus can't put it into a bookmark.

What you need to do is translate the math expression to a \textorpdfstring{$...$}{<text equivalent>}.

To borrow David Carlisle's very nice explanation, here's what's necessary to make a bookmark. LaTeX needs to make plain text with no typesetting commands. It doesn't know what to do with \widetilde so it drops most of the commands in that math string, and complains. If you use \texorpdfstring{$\xxx$}{zzz}, LaTeX doesn't bother to attempt the conversion. It simply typesets $\xxx$ in the main document and puts zzz in the bookmark.