Adding line numbers to a LaTeX document


  1. download the lineno package (http://www.ctan.org/get/macros/latex/contrib/lineno.zip)
  2. unpack it ('unzip lineno.zip') 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
      \RequirePackage{lineno}

    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
      \linenumbers
    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 http://www.ctan.org/tex-archive/macros/latex/contrib/lineno/ulineno.pdf


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


\RequirePackage{lineno}
\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

\begin{document}
\setpagewiselinenumbers
\modulolinenumbers[5]
\linenumbers
....


Notes:


If you have questions about the usage of the lineno package contact cammin_at_fnal.gov.

Last update: 06/30/2008  14:00