# line numbers displayed in latex (both-sided)

Is there a possibility to get (in an onecolumn article) line numbers on both sides (left and right) displayed? I used the lineno-package for a one-sided numeration, but I fail to use it for left and right simultaneously.

\documentclass{article}
\usepackage[left]{lineno}
\usepackage{blindtext}

\begin{document}
\linenumbers
\blindtext
\end{document}


You could update the way the left (default) option works. That is, update \makeLineNumbersLeft and re-issue \leftlinenumbers:

\documentclass{article}
\usepackage{lineno}

\makeatletter
\def\makeLineNumberLeft{%
\linenumberfont\llap{\hb@xt@\linenumberwidth{\LineNumber\hss}\hskip\linenumbersep}% left line number
\hskip\columnwidth% skip over column of text
\rlap{\hskip\linenumbersep\hb@xt@\linenumberwidth{\hss\LineNumber}}\hss}% right line number
\leftlinenumbers% Re-issue [left] option
\makeatother

\usepackage{blindtext}

\begin{document}
\linenumbers

\blindtext
\end{document}


This approach will not work across page boundaries (which is why I upvoted Werner's answer). But since I did it, I'll present it. I set up \lrlineno[start no]{text}.

Basically, I print it out in white, with left line numbers, then do a \vspace to the beginning of the block, and reprint it out in black, using right line numbers.

\documentclass{article}
\usepackage[left]{lineno}
\usepackage{xcolor}
\usepackage{blindtext}
\newlength\tmplen
\newcommand\lrlineno[2][1]{%
\linenumbers%
\setcounter{linenumber}{#1}%
\leftlinenumbers%
\color{white}#2\color{black}%
\par%
\setcounter{linenumber}{#1}%
\setbox0=\vbox{#2}%
\setlength\tmplen{\dimexpr\dp0+\ht0+\the\dp\strutbox}%
\vspace*{-\tmplen}%
\rightlinenumbers%
#2%
\par%
\nolinenumbers%
}
\begin{document}

Testing left-right line numbers, beginning at 3

\lrlineno[3]{\blindtext}

Test is complete.
\end{document}


## Solution

Well, by default the standard classes: article, letter and report use the option oneside meanwhile book uses twoside. We need to add that option in the class before. If you want numbers in both margins you can use switch instead of left in your document.

\documentclass[twoside]{article}
\usepackage[switch]{lineno}
\usepackage{blindtext}
\usepackage{lipsum}

\begin{document}
\linenumbers
\blindtext

\section{First Attempt}
\lipsum

\section{Another stuff}
\lipsum

\end{document}


You don't need to do something more complicated. The package lineno is able to do what you want. Try the code above and see. If you want to get numbers in bot margins in the same page, would be able, but check the package documentation for that.