I'm writing my assignments in latex. Everything works cool, but time to time, when i press F1, a lot of errors occur. Like everything should be wrong even if I pressed F1 2 minutes ago. When I save the file with a new name in a new file, everything works again, as i should. Does anybody know where could be this weird problem of a random "rebellion" of LaTeX?

Example of one error

 ! Missing $ inserted.
<inserted text>
l.7 ... {1.2}_Historie e-knih}{10}{subsection.1.2}
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
! Extra }, or forgotten $.
<argument> ...}{\numberline {1.2}_Historie e-knih}
l.7 ... {1.2}_Historie e-knih}{10}{subsection.1.2}
I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.

Example of errors

  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Feb 1, 2018 at 9:02
  • Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question.
    – Werner
    Feb 2, 2018 at 17:20

1 Answer 1


That looks like you have an unescaped underscore in a section title. Underscores are not valid in text mode, pdflatex will assume you meant to be in math mode and then get confused when you don't seem to be exiting math mode.

This problem only occurs on the second run since it's not in your .tex source file, but in the .aux or .toc file, which are generated by the first run. When you save with a different file name, you generate new aux etc. files, which is why the problem seems to go away.

It's also possible that not all of the commands you use in your section title are what is called robust, which boils down to you can't have them in footnotes, section titles, etc. Try prepending \protect to those, that might help. (You will still need to delete the aux and toc files and compile twice.)

  • Thank you a lot! I deleted the underscores from titles, which I used just for my propre orientation and one more symbol caused harm to compiling - &, I just typed \ before, and voilá, it works. Thank you :)
    – Lenka Tom
    Jan 31, 2018 at 16:47

You must log in to answer this question.

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