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

In passages, the line numbers are given on the right side of the paragraph. Like this: enter image description here

How could this be implemented in LaTeX?

share|improve this question
up vote 6 down vote accepted

The lineno package is what you are looking for.

As a first approximation to what you want: \usepackage[modulo,right]{lineno}. If you want the numbers to start from 1 on every page, add the option pagewise. Unfortunately, the package isn't perfect and will go a little... odd when there's a lot of mathmode or figures.

You then need to activate it with \linenumbers. Personally, I prefer to use line numbers only in draft mode. So with the ifdraft package, I write \ifdraft{\linenumbers}{} so that when I'm not compiling drafts, I don't see the ugly numbers.

If you want line numbers inside a framed box, for example, you need to put \internallinenumbers at the beginning of the environment. I just checked this works with mdframed...

Here is some example code:

\usepackage{lipsum} % The lipsum package is only used to generate dummy text

The documentation is available here.

share|improve this answer
what if i am using a framed box? – yolo Mar 15 '11 at 14:54
@umar I don't know. The listings package achieves line numbering with framed boxes, but that's for a rather different purpose. – Seamus Mar 15 '11 at 14:56
@umar I found it: \internallinenumbers – Seamus Mar 15 '11 at 14:58
somehow \internallinenumbers does not seem to work for me.... how do I do the paragraphing? Where to put the \internallinenumbers – yolo Mar 16 '11 at 10:51
@umar what are you using to draw frame boxes? It should work if you put it just after the \begin{...} – Seamus Mar 16 '11 at 11:45

Have a look at the lineno package.


Edit package options suggested by Seamus.

share|improve this answer

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.