TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It's often convenient to add line numbers to a page automatically and the lineno package generally does the trick. But I've had two problems with it

  1. It doesn't seem to align the line numbers with the actual text lines - linenumbers drift between lines and occasionally skip lines as well as a consequence.

  2. Sequences of equations get skipped. Now I've seen this work properly in other PDFs and so was wondering if there's some magic option I'm missing.

All I do is include the package and then turn line numbering on.

share|improve this question
Take a look at ulineno.pdf from ctan.org/tex-archive/macros/latex/contrib/lineno (the user's manual). It explains why lineno has trouble with equations and paragraphs containing equations, and also some work-arounds. – Willie Wong Aug 2 '10 at 2:52
@Willie: you should post this as an answer so we can upvote it :) – Will Robertson Aug 2 '10 at 3:49
In case it helps, I had the same question and I found this answer specially useful: tex.stackexchange.com/a/55297/8283 – Vicent Jul 25 '14 at 16:15
up vote 16 down vote accepted

(This is a copy of the comment I posted above. Now an answer due to Will Robertson's suggestion.)

This addresses, partially, problem 2 described in the question. I've never seen problem 1 happen myself; then again, I haven't used lineno that much.

Take a look at ulineno.pdf from http://www.ctan.org/tex-archive/macros/latex/contrib/lineno/ (the user's manual). It explains why lineno has trouble with equations and paragraphs containing equations, and also some work-arounds.

Basically, the line number can only be computed after LaTeX finished typesetting the text. The package does this after every paragraph (this having something to do with LaTeX's internal workflow). However, when a paragraph is punctuated by equations, the portions before each equation environment is processed before the equation is processed. So when the package tries to number the lines for one of such paragraphs, it only knows about the last block of text not interrupted by an equation environment before the paragraph break.

To deal with this the package defines a wrapper to be put around the math environments so that it flushes the numbering before entering the math environment, numbers the equation when leaving the environment, and resumes as usual afterwards. So the work around described in the manual is to enclose the equation environments in this wrapper.

Now, to make life slightly simpler, you can also pass an option to lineno to automatically redefine the math environments to include the wrapper. But this will likely not work with document classes that defines their own math environments (such as AMS-LaTeX's align).

share|improve this answer

Just add a space line between paragraph and the equation. This will solve line numbering problem.

share|improve this answer
Welcome to TeX.SX. Could you please elaborate with an example? This would help future readers a lot. – Claudio Fiandrino May 6 at 18:47
It is also stated in (tex.stackexchange.com/q/43648/104963) – R. Gholizadeh R. May 6 at 19:13

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.