The lineno package

Prints line numbers in the margin of the text with \linenumbers, as journals ask for in manuscripts under review.

Loading the package

\usepackage{lineno}

LaTeX has no line numbering of its own. lineno numbers every line of the running text, either through the whole document or starting at 1 on each page, and lets you refer to a line with \linelabel and \ref.

Numbering is switched on with \linenumbers and applies to complete paragraphs. A paragraph gets numbers when numbering is active at its end.

Main commands

\linenumbersSwitches line numbers on.
\nolinenumbersSwitches them off again.
\modulolinenumbers[5]Prints only every fifth number.
\linelabel{ln:result}Marks a line; \ref{ln:result} prints its number.
\resetlinenumber[1]Sets the number of the next line.
\usepackage[pagewise]{lineno}Numbering starts at 1 on every page; needs a second run.
\usepackage[right]{lineno}Numbers in the right margin; switch puts them in the outer margin of a two-sided document.

Complete example

\documentclass{article}
\usepackage{lineno}
\linenumbers
\modulolinenumbers[2]
\begin{document}
The first paragraph of the manuscript gets line numbers in the left
margin. Only every second number is printed. The\linelabel{ln:key} key
statement stands in line~\ref{ln:key}.

A second paragraph continues the numbering.

\nolinenumbers
This paragraph has no line numbers.
\end{document}
Result
The compiled example

Open in the editor

Compiled with pdfLaTeX from TeX Live 2023. Tools run in this order: pdflatex → pdflatex.

Pitfalls

Related pages