0

I have a large LaTeX document that was compiling without warnings in Ubuntu 22.04. Now I had to move to Fedora 40 and, when I try to compile it, it produces hundreds of ! Missing $ inserted., ! Missing } inserted., ! Missing \endgroup inserted., etc. I did not change anything in the LaTeX document, I am just trying to get it to compile exactly as it was before I start working again. The problem is that the LaTeX code seems to be right everywhere where these errors arise, for example the first one is

! Missing $ inserted.
<inserted text> 
                $
l.474 ...temperature of about $-20\UNIT{{^\circ}C}
                                                  $.
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.

and my LaTeX there is

an operating temperature of about $-20\UNIT{{^\circ}C}$. 

How can I debug what is the problem? I read that it could be something in the .bib files as well, but how can I track it? My complete code has 13 .tex files and 2 .bib files, plus hundreds of images.

2
  • 1
    The argument of \UNIT might be in text mode - but just a guess without seeing a small reproducible example so we can see how the macro is defined or where it comes from. Commented Sep 8 at 21:47
  • you can make a small one line latex document \documentclass{article}\begin{document} an operating temperature of about $-20\UNIT{{^\circ}C}$. \end{document} and add the definition of \UNIT (which is probably \mbox) and observe the same error I woudl guess, in which case remove UNIT or use \UNIT{$^{\circ}$} Commented Sep 8 at 22:34

1 Answer 1

4

The error message you show highlights the error position, there is no reason to suppose it is related to your bib file or images so you can easily cut your document down to a simpler example such as

\documentclass{article}
\newcommand\UNIT{\mbox}
\begin{document}
an operating temperature of about $-20\UNIT{{^\circ}C}$. 
\end{document}

which produces

This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./aa822.tex
LaTeX2e <2024-06-01> patch level 2
L3 programming layer <2024-08-16>
(/usr/local/texlive/2024/texmf-dist/tex/latex/base/article.cls
Document Class: article 2024/02/08 v1.4n Standard LaTeX document class
(/usr/local/texlive/2024/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)
No file aa822.aux.
! Missing $ inserted.
<inserted text> 
                $
l.4 ...g temperature of about $-20\UNIT{{^\circ}C}
                                                  $.
? 

\UNIT is text mode so you need \textdegree not ^\circ

enter image description here

\documentclass{article}
\newcommand\UNIT{\mbox}
\begin{document}
an operating temperature of about $-20\UNIT{\textdegree C}$. 
\end{document}

However you should consider not using \UNIT (which might not have exactly the definition I guessed in your real document) and instead use the siunitx package which provides an extensive set of commands for formatting units.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .