5

enter image description here

MWE:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$$
let p^k be the statement that, for some value n=k, A^k=\begin{pmatrix}1&0 \\ k&0 \end{pmatrix} 

$$
\end{document}

It seems that Latex does not allow empty line in mathmode. The above code is perfectly compilable if I get rid of the last empty line. But it results in an error with the empty line. Is there a deeper reason why Latex doesn't just ignore the empty line?

3

1 Answer 1

10

There are two chief reasons for this behaviour:

  1. It makes error recovery technically easier and the error message (hopefully) clearer, because when TeX encounters a missing $ you can be sure that it was at least in the paragraph at whose end the error was thrown. Knuth gives this reason in the TeXbook on page 135:

    \danger Conversely, a blank line or ^|\par| is not permitted in math mode.
    This gives \TeX\ another way to recover from a missing~|$|; such
    errors will be confined to the paragraph in which they occur.
    
  2. The other reason is for consistency (at least in my opinion). If a blank line (which is an implicit \par) were ignored in math mode this would be in contradiction to what happens in text mode where it starts a new paragraph. To prevent this confusion it is sensible to throw an error rather than producing some inconsistent behaviour.

If you are using LuaTeX instead of pdfTeX or XeTeX, you can make the engine ignore this error. Simply add \suppressmathparerror=1 to the preamble.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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