Adding line numbers to a LaTeX document

  1. download the lineno package (
  2. unpack it ('unzip') and from the subdirectory lineno/ copy all files *.sty into the directory with your LaTeX main document
  3. in the LaTeX preamble include the line

    before the \documentclass{...} command.

    (Note: this rather unusual way of including a package is necessary due to incompatibilities between the lineno package and revtex. If you are not using revtex to prepare your document you can also use the standard way: \usepackage{lineno})
  4. line numbers can be activated by adding the line
    after \begin{document}
The package has several options, for instance printing only every 5th line number, or starting to count at 1 for each page, etc. A users guide is available at

Example for D0 PRL template with line numbers printed every 5 lines and starting at 1 for each page:

\documentclass[aps,prl,twocolumn,showpacs,groupedaddress]{revtex4}  % for review and submission
\usepackage{graphicx}  % needed for figures
\usepackage{dcolumn}   % needed for some tables
\usepackage{bm}        % for math
\usepackage{amssymb}   % for math



If you have questions about the usage of the lineno package contact

Last update: 06/30/2008  14:00