[Tex/LaTex] Why doesn’t lineno number a paragraph when it is followed by an indented equation

amsmathequationsline-numbering

While searching for the source of missing line numbers, I realized that paragraphs followed immediately by an equation have no line number, but this is fixed when a space is included,

e.g. the following document has no line numbers:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{lineno}
\linenumbers
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit: 
$$1+1=2$$ 
\end{document}

But this one does:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{lineno}
\linenumbers
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit: 

$$1+1=2$$ 
\end{document}

The only difference is the space above the equation.

  • Why is this the case (and is there a simple workaround)?

  • Is it incorrect to include an indented equation in a paragraph, or is this just a 'feature' of lineno?

Best Answer

$$...$$ is obsolete, see Why is \[ ... \] preferable to $$ ... $$?. If you use the correct LaTeX displayed math environment, the numbering works without the empty line:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{lineno}
\linenumbers
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit: 
\[1+1=2\] 
\end{document}

enter image description here