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
\linenumbers | Switches line numbers on. |
\nolinenumbers | Switches 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}Compiled with pdfLaTeX from TeX Live 2023. Tools run in this order: pdflatex → pdflatex.
Pitfalls
- Before version 5.0 from 2022, a paragraph that ended with a display equation of
amsmath, such asalign, lost its line numbers. There, wrap the equation in thelinenomathenvironment. Current versions patch theamsmathenvironments themselves. - Lines inside tables, figures and footnotes get no numbers.
- In a two-column document, add the option
switchorcolumnwiseso the numbers of the right column do not land between the columns.
Related pages
- How-to Line numbers in LaTeX
- How-to Cross-references in LaTeX
- Package
amsmath