Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

lineno skips the line numbering in this case:

Lorem ipsum dolor sit amet, consectetur adipiscing elit: 

but is fine with

Lorem ipsum dolor sit amet, consectetur adipiscing elit: 


Note that though this sounds a lot like this question. I don't believe the answer is related, since this doesn't use $$. Is the latter somehow more correct?

share|improve this question
try enclosing your math environment by \begin{linenomath} and \end{linenomath} (see documentaion for lineno). – prettygully Feb 7 '12 at 4:18

3 Answers 3

up vote 5 down vote accepted

In essence, this is the same, since align issues $$ before assembling the environment contents. Here is the definition of the align environment in amsmath:

  % <removed \end{align} part for brevity>

So, at \begin{align} is equivalent to


where \start@align is defined to take three parameters and condition appropriately. In the definition of \start@align, I've marked the conditionals, as well as the final $$ for entering display math mode:

    \let\xatlevel@#1% always \z@, \@ne, or \tw@
    \ifnum\maxfields@>\m@ne % <------------------- FALSE
    \else % <------------------------------------- TRUE
    \ifingather@ % <------------------------------ FALSE
    \else % <------------------------------------- TRUE
        \ifmmode % <------------------------------ FALSE
        \else % <--------------------------------- TRUE
            $$% <--------------------------------- enter display math mode

The conclusion? Use an empty line (or paragraph break). The output with or without is the same, except in this case with lineno.

share|improve this answer
I think the solution(s) by Werner and tohecz are very nice but the output in not exactly the same with and without the paragraph break. With it, more blank space is left before the math environment. On the contrary, the solution given at the link by mbudusic seems to reproduce the same behaviour as the equation without space before, but with compatibility with lineno – Federico Rotolo Jul 10 '12 at 12:07
@FedericoRotolo: As your answer is more like a comment, I converted it. – Stefan Kottwitz Jul 10 '12 at 15:44
not only is the space different, a blank line or paragraph break will also permit a page break, which is undesirable. – barbara beeton Sep 11 at 15:32

I've found this answer too. It gives a command that you can use to patch math environments as needed. I figure it does the same thing as presented above, but it doesn't hurt to have several solutions.

I cannot see the difference in line spacing when it is included in preamble or not, but the line numbers that aren't shown before, show up after it is added.

Short summary of the link above: Add the following to your preamble:

  \expandafter\let\csname old#1\expandafter\endcsname\csname #1\endcsname
  \expandafter\let\csname oldend#1\expandafter\endcsname\csname end#1\endcsname
     {\linenomath\csname old#1\endcsname}%
     {\csname oldend#1\endcsname\endlinenomath}}% 
share|improve this answer
Hello! I had also the same question, and this solution seems to work perfectly to me!! – Vicent Jul 25 '14 at 16:13
Because this one doesn't add the extra space above the align environment, this should be first answer. Vote up! – kennyB Nov 11 '14 at 23:28
This result numbers every line but it actually over numbers some lines. It gets like clustered. The best thing is that it does not skip lines. – Masi Sep 11 at 19:49

Put this in your preamble, at the end (after the math package are loaded):

% Make a copy of macros responsible for entering display math mode
% Add the "empty line" command to the macros

It actually adapts the trick that @Werner speaks about, just without the need of changing every display math in your document.

It is worth noting that this solution is ultimately bad; it destroys proper page breaking and proper vertical spacing.

share|improve this answer
This and the answer by Werner are both excellent, his for avoiding this error in the future and yours to avoid manually fixing existing documents. wish I could accept both, thanks. – cboettig Feb 9 '12 at 19:55
I tested this answer more with bigger files. This answer skips some lines. @mbudisic's answer numbers everything but it over numbers some lines, like getting clustered, which is much better situation than leaving some lines unnumbered. – Masi Sep 11 at 19:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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