1

The answer to the following question suggested by @IanThompson with left and right column numbers works sufficiently when we use \documentclass[twocolumn]{article}

However I am using a different document class - that being {scrartcl} and cannot get the left column to have line numbers to the left and vice versa for the right coulmn.

Here is some generic code, to work with:

\documentclass[10pt,a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[margin=2.5cm]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{multicol}
\usepackage{hyperref}
%\usepackage[switch, columnwise]{lineno}
\usepackage{lineno} 
\usepackage{setspace}
\usepackage{lipsum}
\title{Correct formatting line numbers}
\author{Contributions from the world wide web}

\begin{document}
    \maketitle
    \doublespacing

\begin{abstract}
    \begin{linenumbers}
        \lipsum[1-1]
    \end{linenumbers}

\end{abstract}

\begin{multicols}{2}

    \begin{linenumbers}

        \section{Introduction}      
        \lipsum[1-3]

        \end{linenumbers}
    \end{multicols}
\end{document}

As suggested in the linked question at the top of the page, playing around with columnwise in \usepackage[switch, columnwise]{lineno} does not produce the desired output

lukeg
  • 211
  • You are referring to a question/answer but i cannot see any. I think what you describe is also going on for the standard classes, so not KOMA specific. – Johannes_B Jan 10 '16 at 10:05
  • Do you simply want to write a twocolumn article? If so, just use twocolumn globally and kick out multicol. – Johannes_B Jan 10 '16 at 10:05
  • no I am wanting to mix up one and two column parts, thats why I am using scrartcl – lukeg Jan 10 '16 at 10:27
  • sorry, the hyperlink did upload.... but now it is – lukeg Jan 10 '16 at 10:29
  • You want a twocolumn article with a onecolumn abstract, right? For me, this seems to be an XY-problem, so it would be good to know what you want to achieve and not fixing the thought to be solution. – Johannes_B Jan 10 '16 at 10:35
  • http://latex-community.org/forum/viewtopic.php?f=47&t=26999 – Johannes_B Jan 10 '16 at 10:39
  • Its for a journal paper, the finished document mostly has two columns of text, a combination of tables formatted into (or below) a columns of data, as well as tables spanning across the two columns (ie. \end{multicols}-create table-\begin{multicols}...). Do that explain it enough? – lukeg Jan 10 '16 at 10:41

1 Answers1

2

You can use this new command on this German forum, which is placed inside of the multicols environment. Outside, you can use the regular command for the line numbers.

It requires you to load the colaction option for multicol.

Output

enter image description here

Code

\documentclass[10pt,a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[margin=2.5cm]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage[colaction]{multicol}
\usepackage{hyperref}
\usepackage{lineno} 
\usepackage{setspace}
\usepackage{lipsum}
\title{Correct formatting line numbers}
\author{Contributions from the world wide web}

\newcommand\multicollinenumbers{%
 \linenumbers
 \def\makeLineNumber{\docolaction{\makeLineNumberLeft}{}{\makeLineNumberRight}}}


\begin{document}
\maketitle
\doublespacing

\begin{abstract}
\begin{linenumbers}
    \lipsum[1-1]
\end{linenumbers}

\end{abstract}

\begin{multicols}{2}
\multicollinenumbers

\section{Introduction}      
\lipsum[1-3]

\end{multicols}
\bigskip
\begin{linenumbers}
\lipsum[2-3]
\end{linenumbers}
\end{document}
Alenanno
  • 37,338
  • Thanks for the suggestion and the code must work as your image indicates, however my version of texstudio gives me the following error Unknown option "colaction" for package "multicol".\def.. Any suggestions how to overcome the problem – lukeg Jan 11 '16 at 20:51
  • @lukeg Is your Tex Live (and all packages) up to date? – Alenanno Jan 11 '16 at 20:59
  • This is a great help. However, [pagewise] does not work, to reset the line number from 1 on each page. – Dr.PB Mar 04 '20 at 04:50