Fix: Missing $ inserted

Something that only makes sense inside math mode appeared in running text. pdfLaTeX offers to enter math mode for you — almost always the wrong help.

What the log looks like

! Missing $ inserted.
<inserted text>
                $
l.3 The sample size was n_1 = 42 subjects,
                                        which is outside math mode...

Why it happens

Ordinary text is typeset as text. The characters _, ^ and bare math like n = 42 belong to math mode, which starts and ends with $. The two classic triggers:

  1. An underscore or caret in text. Writing n_1 in a sentence — the underscore is math-only. Use $n_1$, or \_ for a literal underscore in a filename.
  2. An unbalanced dollar sign. One $ opens math mode and everything after it is parsed as math until the next $ — often far away from the real mistake.

The fix

Wrap the math content in dollar signs:

The sample size was $n_1 = 42$ subjects.

For displayed equations use \[ ... \] or the equation environment instead of loose dollars.

Reproduce it now

The example puts a bare subscript in a sentence. Compile it, read the error, add the dollars, compile again.

Open the repro in the editor →