# Lineno for 2 column

How to add line number to a 2 column document where the line number must appear on the left for the left column and on the right for the right column. The lineno package does not seem to provide this option.

• This is one of the things that's HARD - if not impossible - in LaTeX, while it probably just works in ConTeXt. Jun 10 '11 at 6:54

Use the switch option for the lineno package.

\documentclass[twocolumn]{article}
\usepackage[switch]{lineno}
\usepackage{lipsum} %Creates example text
\begin{document}
\linenumbers
\lipsum[1-20]
\end{document}

• The line numbers appear on the right of the left column in this answer.
– Sony
Nov 12 '11 at 1:04
• For numbering of lines on a per-column basis, add the columnwise option to lineno. Nov 13 '11 at 21:16
• @Sony --- Not so on my machine. Make sure you compile twice so that the warning about line number reference goes away. Nov 22 '11 at 16:14
• This didn't work for me either. Neither did adding the 'columnwise' option as per @Werner
– DKS
Feb 13 '15 at 10:24
• @DKS --- What TeX distribution are you using? Feb 13 '15 at 22:40

Simply add [columnwise] in the options of the package:

\usepackage[switch,columnwise]{lineno}

• When I use use these options, the counter is reset at every column. However, I am not using one of the default LaTeX classes. Apr 26 '17 at 9:20
• It is very fruitful for me thaaaaaaaaaaaaaannx 2019 Jul 17 '19 at 15:02

The following is a partial solution.

\documentclass{article}
\usepackage{multicol}
\usepackage{lineno}
\usepackage{lipsum}
\begin{document}
\begin{multicols}{2}
\linenumbers
\lipsum[1-1]
\columnbreak
\rightlinenumbers
\lipsum[1-1]
\end{multicols}
\end{document}


• Using lineno with the switch option, you need to compile at least twice. Your solution works in a different context just as well. Nov 13 '11 at 21:15
• Does someone know how to make it work with the IEEEtran class? Dec 1 '16 at 23:55

I don't know if I've just developed a fortunate hack, or if this is how the package is supposed to be used, but I also had the issue that Ian Thompson's answer did not produce running numbering but columnwise numbering.

I got outer-margin two-column running numbering with the following code:

\documentclass[twocolumn]{article}
\usepackage[switch]{lineno}
\usepackage{lipsum} %Creates example text
\begin{document}
\runningpagewiselinenumbers
\linenumbers
\lipsum[1-20]
\end{document}


Note that this needs to be compiled twice for the line numbering to be displayed correctly:

pdflatex docname.tex
pdflatex docname.tex