# Math environments: Allow empty lines?

Compiling the following document will raise the errors

Paragraph ended before \align was complete


and

Displaymath should end with  because par-breaks are not allowed in math environments/displaymath. \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align} Empty are not allowed. \end{align}
Empty lines

are not allowed
$$\end{document}  While editing however, I frequently accidentially compile after hitting enter (creating a new line) and before adding any content, hence I am searching for a method to allow paragraph breaks in math mode, ideally ignoring them. Just for comparison, if I needed only display-math without AMS environments, a viable solution would be \documentclass{article} \usepackage{amsmath} \usepackage{xcolor} \begin{document} \everydisplay{\def\par{\mathbf{\color{red}-forgotten-par-}}}$$
Empty\,lines

are\,now\,allowed

but\,you\,get\,a\,reminder
$$\end{document}  Is there some solution that works across all common math environments? • If a well understand you want to enforce line breaks (newline) inside math mode ? – SAM Jul 1 '16 at 15:21 • Don't use $$ in LaTeX to begin with. See Why is $…$ preferable to $$? – egreg Jul 1 '16 at 15:31 • – egreg Jul 1 '16 at 15:34 • @SAM No, I really only want to avoid compilation failure when I start a new (source code) line in math mode and haven't typed anything yet. – kdb Jul 4 '16 at 8:53 • @egrep I mostly used $$ only to demonstrate, that the "problem" occurs across multiple macros. Thanks for the link though; Using almost exclusively AMS environments, I never heard of that. – kdb Jul 4 '16 at 8:55

I wouldn't recommend it, but if luatex is an option, it allows both these errors to be disabled without making any changes to the macros.

\suppressmathparerror = 1
\suppresslongerror = 1
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
Empty

are not allowed.
\end{align}
$$Empty lines are not allowed$$
\end{document}


This is an answer for first version of the question.

You are seeking problems. Partial solution, working for , but not amsmath-based environments is below. Check it, please and never use it. \documentclass{article} \usepackage{amsmath} \begin{document} \let\normalpar=\par \def\par{\ifmmode \else\normalpar \fi} \begin{align} Empty % are not allowed. \end{align}
Empty lines

are not allowed

\end{document}

• Isn't this worse than using \everydisplay? – kdb Jul 4 '16 at 8:57
• @kdb It is an answer for the first version, when OP wrote nothing about \everydisplay. And the main thesis is never use it. The right way is changing customaries. – Przemysław Scherwentke Jul 4 '16 at 12:35