20

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. – Martin Schröder Jun 10 '11 at 6:54
24

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}
| improve this answer | |
  • 2
    The line numbers appear on the right of the left column in this answer. – Sony Nov 12 '11 at 1:04
  • 4
    For numbering of lines on a per-column basis, add the columnwise option to lineno. – Werner Nov 13 '11 at 21:16
  • 8
    @Sony --- Not so on my machine. Make sure you compile twice so that the warning about line number reference goes away. – Ian Thompson 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? – Ian Thompson Feb 13 '15 at 22:40
14

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

\usepackage[switch,columnwise]{lineno}
| improve this answer | |
  • When I use use these options, the counter is reset at every column. However, I am not using one of the default LaTeX classes. – Antonio Sesto Apr 26 '17 at 9:20
  • It is very fruitful for me thaaaaaaaaaaaaaannx 2019 – Inzo Babaria Jul 17 '19 at 15:02
8

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}

enter image description here

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

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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.