27

I am new to LaTeX and I am using it to write a report with several chapters (main page in which I include the other pages). I got this error:

C:\Users\hussam\Desktop\thèse\latex\thèse\thèse.brf

! Missing $ inserted.

<inserted text> 

                $

l.52

without any other information.

thèse.brf is a totally white page. I looked at line 52 of all my documents but couldn't find any problem.

  • 19
    Using accented characters in file names is very dangerous. – egreg Apr 21 '12 at 12:36
  • i assume this thèse.brf is being input? what encoding is the file in, and what packages do you have loaded? my guess is latex is confused by your file name into thinking that it contains something dedicated to maths (like ^, _ or the like. fwiw, i agree with @egreg: remember that tex dates from the days when ascii was an exciting new standard, and it's notorious for being confused by non-ascii characters; we could really do with a minimal example (a stripped-down version of your document that still fails) – wasteofspace Apr 22 '12 at 13:47
  • Found the simplest solution. Just put a single $ sign on both sides of the line. – Dipanshu Gupta Jul 5 '16 at 14:23
29

I had the same problem and solved it by correctly escaping ^, _, and |. Looks like LaTeX sets both $s itself if you seem to have forgotten them. Everything that may intend being a math formula causes this error.

  • 3
    I had to escape the _ in my .bib file, so it's not just the .tex file you have to worry about. – pd12 Sep 9 '16 at 7:21
  • I had to escape the & in my .bib file. Including \usepackage{url} can be helpful to avoid this. – user2723494 Mar 3 at 1:07
12

This error usually appears because you used a $ somewhere previously that needs to be matched by an ending $. You haven't given us very much to work with, but here are some troubleshooting steps.

  • Look at the lines before line 52. Are there any $ that you see that maybe need to be matched with something?

  • If you hit ENTER in your console, will your file keep compiling? If so, keep hitting ENTER (or type Q) until it finishes, and then look at the output if possible. If you've been typing math, do you see a whole bunch of italicized stuff that has funny spacing? If so, that's a sign that LaTeX thinks you're still in math mode (so it's typesetting your text as math), so around there is where you should look for your missing $.

4

I had this problem too, and it wasn't anywhere near the line number given in the logs.

Building on Leah's answer, if you press Q, then look in the logs, you'll see the message:

I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.

So on the next run, try pressing 2 at the error prompt, which tells latex to ignore the problem, and continue, instead of trying to fix it. In doing so, it'll print out the last bit of text it read (near the problem), and that should give you a clue where the problem is (you might need to do this a couple of times).

Turns out my problem was on line 366 of my .bib file, and no-where near line 20 as reported. It was caused by a ~ in a url that hadn't been converted by the zotero exporter. Deleting that line removed the error.

4

I have been struggling with a similar error. For debugging it's sometimes helpful to have a look before the actual error message to see numbers in brackets such as [2] telling you which page is compiling at that stage. Nevertheless, hit Enter (several times). If the document gets compiled and you can open the document, have a closer look at the page which was indicated before. Sometimes you can spot some text that is not rendered correctly which is the error. You can then fix the corresponding passage.

Here another important hint: Remember to also check the bibliography entries in the bibliography which on those page are referred to. Although the entries themselves are not on that page, the error message would point you to the page where the reference is rendered. (In my case, I could spot an underscore that I did not escape with \_ in the .bib file. The underscore itself was not on the page that was rendered but the reference to the corresponding entry in the bibliography -- this was a bit tricky.)

2

In LaTeX, $ is a special symbol. When two $'s are placed around an equation, this tells LaTeX that this information is math, and not just regular text, e.g.:

$4+3=7$

When typing $, or the dollar sign, in a document in LaTeX, such as “I have $3.”, you must place a \ before, for e.g.:

I have \$3.

You probably tried to type a dollar sign in the document, but LaTeX believed you wanted math mode, so it is looking for the closing $.

1

Consider given code:

\begin{align*}
    $ {\bar S} &= \emptyset $ \\
    $ {\bar \emptyset} &= S $
\end{align*}

In the following snippet, I have used $ to make it look more mathematical. Also, focus that each $ symbol have been separated apart from others but still given code will give the exact error you faced.

Therefore, to recover from such problems, a better advice is do not use $ along with align.

Below code compiles smoothly,

\begin{align*}
     {\bar S} &= \emptyset  \\
     {\bar \emptyset} &= S
\end{align*}
  • This solution removes the error in your code example but it perhaps misses the point: in TeX, $...$ is used for mathematics mode and if you want to insert the dollar sign symbol you have to use \$. Unfortunately, it is not at all clear that the OP's error is caused by something like this...and we can't tell since they did not provide a minimal working example. – Andrew Jun 7 '17 at 2:17

protected by Community Jul 6 '17 at 16:33

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.