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

How could this be implemented in LaTeX?
In passages, the line numbers are given on the right side of the paragraph. Like this:

How could this be implemented in LaTeX?
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:
\documentclass[12pt]{article}
\usepackage{lipsum} % The lipsum package is only used to generate dummy text
\usepackage[right,modulo]{lineno}
\usepackage{mdframed}
\begin{document}
\begin{mdframed}
\internallinenumbers
\lipsum[1]
\end{mdframed}
\end{document}
The documentation is available here.
Have a look at the lineno package.
\documentclass{article}
\usepackage{lipsum}
\usepackage[modulo,right]{lineno}
\begin{document}
\linenumbers
\lipsum
\end{document}
Edit package options suggested by Seamus.
listingspackage achieves line numbering with framed boxes, but that's for a rather different purpose. – Seamus Mar 15 '11 at 14:56\internallinenumbers– Seamus Mar 15 '11 at 14:58\begin{...}– Seamus Mar 16 '11 at 11:45\usepackage[style=2]{mdframed}and\begin{mdframed}– yolo Mar 16 '11 at 11:54[15] [16] Underfull \hbox (badness 10000) in paragraph at lines 473--478- can you show me your document code? – yolo Mar 16 '11 at 12:06style=2option formdframed. It accepts 0,1 or 3... Do the numbers look alright? Are you sure this problem is due to line numbering? – Seamus Mar 16 '11 at 13:02