TransWikia.com

Why Is empty line not allowed in mathematics mode?

TeX - LaTeX Asked by jxhyc on January 30, 2021

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?

One Answer

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.

Answered by Henri Menke on January 30, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP