Why blank lines between equation makes error? there are a lot of commands in latex and almost for all of them these blank lines are not important, but why in this case is important and is there any similar function?
1 Answers
An excerpt from page 135 of the TeXbook:
... [A] blank line or
\paris 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.
Knuth provides the following example to motivate this syntax rule:
For example, suppose you were to write
The smallest $n such that $2^n>1000$ is~10.TeX doesn't know that you forgot a
$after the firstn, because it doesn't understand English; so it finds a "formula" between the first two$signs:after which it thinks that
2is part of the text. But then the^reveals an inconsistency; TeX will automatically insert a$before the^, and you will get an error message. In this way the computer has gotten back into synch, and the rest of the document can be typeset as if nothing had happened.
So, while it may seem like a nuisance at first not be be allowed to have blank lines in (inline or display) math mode, there's actually a very good reason for this syntax rule: It helps confine the error to the paragraph in which it occurs and lets you compile the rest of the document (assuming you want to do so).
Of course, if we could absolutely guarantee that we'd never ever have any missing $ symbols in our inputs, the prohibition against blank lines wouldn't be needed to begin with. However, which of us is fully able and willing to provide such a guarantee?
- 506,678

\long\def(or\newcommand) can have a blank line, while those defined using only\def(or\newcommand*) can't accept blank lines as an argument. – Werner Jun 17 '16 at 06:30\parand in almost all contexts this has some effect which may or may not be important, depending where it is used. – David Carlisle Jun 17 '16 at 06:47%in column 1. This looks almost like a blank line, but is not considered one by LaTeX. – Steven B. Segletes Jun 17 '16 at 10:43alignenvironment and "raw" math mode) – user202729 Oct 09 '22 at 05:14