Line numbers on different margins in two-sided document

I'm using the lineno package to print line numbers in my two-sided document, but they are always printed in the left margin.

\documentclass[twoside]{book}

\usepackage{lineno}
\usepackage{lipsum}

\begin{document}

\linenumbers
\lipsum

\end{document}


If I load lineno with the option right

\usepackage[right]{lineno}


they all are printed in the right margin

What I would like to do is to print line numbers in the right margin in odd pages and in the left margin in even pages, but I haven't been able to find an option to achieve this.

Does anyone know a workaround?

You are looking for the switch option:

\documentclass[twoside]{book}
\usepackage[switch]{lineno}
\usepackage{lipsum}
\begin{document}
\linenumbers
\lipsum[1-30]
\end{document}


• Was it so simple...? I tried with manual \switchlinenumbers with no luck! Thank you. BTW: you can suggest this answer in this thread as well: tex.stackexchange.com/q/146587/31910 – Sterry Nov 24 '13 at 11:10
• @Sterry. You're welcome. I answered also the other thread. – Fran Nov 24 '13 at 17:57
• Upvoted there, too. – Sterry Nov 24 '13 at 19:30