# Three column layout

My boss requires a three column layout for a report:

• Column 1: All headings below sections (subsection, subsubsection, ...). Heading text should break in the first column.
• Column 2: The main text
• Column 3: References, remarks, etc. The content here should be aligned to their corresponding line in the main text

I'm not quite happy with my first draft:

\documentclass[11pt,a4paper,numbers=noenddot]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[left=2cm, right=1cm]{geometry}

\usepackage{paracol}
\setcolumnwidth{10pt,60pt,10pt}
\usepackage{lipsum}

\begin{document}

\begin{paracol}{3}[\section{\underline{SECTION I - The Project Statement}}]
\switchcolumn[0]
\subsection{Subsection1}
\switchcolumn[1]
\sloppy
\lipsum[1]
\switchcolumn[2]
see \texttt{www.example.com/example}

\switchcolumn[1]*
\sloppy
\lipsum[2]
\switchcolumn[2]
see \texttt{Mayer et. al.}
\end{paracol}

\end{document}


Main Problems:

• I determined the column widths by trial and error. If one subsection heading is too long, the layout breaks
• I cannot use \autocite

Edit: I'm used to cite with \autocite and list my references at the end of the document. Is it possible to keed this workflow and list the reference in the third column of the document next to its appearance in the main text, too?

Do you have any suggestions?

• Should other headings also go into the left column or only \subsection, should the headings stay inside the left column or can they stick into the main column if they are wider? Is the right column height aligned to the contents the remarks are about or filled from the top? – Skillmon Jun 23 at 13:37
• I've clarified my question, thanks. – Marvin Noll Jun 23 at 13:52
• @MarvinNoll: In your question you stated problems with the \autoref command. Writing my answer, I did not encounter any problems with this command. Could you please add some information regarding your use of \autoref, please? – leandriis Jun 23 at 14:24
• @ leandriis: I've edited my question. Thanks. – Marvin Noll Jun 23 at 16:36

I'd suggest not using paracol but instead setting up the geometry such that your main body width is a bit smaller, headings are printed into the left margin, and the references, remarks, etc. are put into the right margin via marginnote:

\documentclass[11pt,a4paper,numbers=noenddot]{scrartcl}

\usepackage[english]{babel}
\usepackage{marginnote}
\usepackage{geometry}

% setup the width for the columns
\newlength\leftcolumn
\newlength\rightcolumn
\newlength\leftcolumnsep
\newlength\rightcolumnsep
\setlength\leftcolumn{4cm}
\setlength\rightcolumn{2.5cm}
\setlength\leftcolumnsep{10pt}
\setlength\rightcolumnsep{\leftcolumnsep}
% store the width for all three columns in \textwidth
\setlength\textwidth{18cm}

% reduce the text width by what is needed for the other columns
\makeatletter
\@tempdima\textwidth
\ifdim\@tempdima>0pt
% this is an idiomatic way to set the new width, it assumes the default
% hratio=1:1 of geometry in onesided mode
\geometry
{marginparwidth=\rightcolumn,marginparsep=\rightcolumnsep,width=\@tempdima}
\else
\GenericError
{}{Fatal error: Negative \string\textwidth}
{Make the left and right column smaller}{}%
\stop
\fi
\newcommand\intoleftcolumn[1]
{%
% it is assumed that \intoleftcolumn is always called where a \par can
% appear
%\par
\noindent
\smash{\llap{\parbox[t]{\leftcolumn}{#1}\hskip\leftcolumnsep}}%
}
\newcommand\intorightcolumn[1]
{%
% just use \marginnote for this
\marginnote{#1}%
}
\let\sectionlinesformat@orig\sectionlinesformat
\renewcommand\sectionlinesformat[4]
{%
\ifstr{#1}{section}{\sectionlinesformat@orig{#1}{#2}{#3}{#4}}%
{\intoleftcolumn{\sectionlinesformat@orig{#1}{#2}{#3}{#4}}}%
}
\RedeclareSectionCommand[afterskip=-\baselineskip,runin=false]{subsection}
\RedeclareSectionCommand[afterskip=-\baselineskip,runin=false]{subsubsection}
\makeatother

\usepackage{duckuments} % interesting dummy text

% should be loaded at the end of the preamble
\usepackage[]{hyperref}

\begin{document}
\section{This is a section}
\blindduck
\subsection{This is a subsection\label{sec:sub}}
\blindduck
\subsubsection{This is a subsubsection}
\blindduck
\end{document}


EDIT: Since leandriis pointed out that I got the \sections wrong, this edit does left align them with the left column, they can take up the total width of all three columns (plus the separation):


\documentclass[11pt,a4paper,numbers=noenddot]{scrartcl}

\usepackage[english]{babel}
\usepackage{marginnote}
\usepackage{geometry}

% setup the width for the columns
\newlength\leftcolumn
\newlength\rightcolumn
\newlength\leftcolumnsep
\newlength\rightcolumnsep
\newlength\totalcolumnswidth
\setlength\leftcolumn{4cm}
\setlength\rightcolumn{2.5cm}
\setlength\leftcolumnsep{10pt}
\setlength\rightcolumnsep{\leftcolumnsep}
% width for all three columns (this indirectly sets the main columns width)
\setlength\totalcolumnswidth{18cm}

% reduce the text width by what is needed for the other columns
\makeatletter
\@tempdima\totalcolumnswidth
\ifdim\@tempdima>0pt
% this is an idiomatic way to set the new width, it assumes the default
% hratio=1:1 of geometry in onesided mode
\geometry
{marginparwidth=\rightcolumn,marginparsep=\rightcolumnsep,width=\@tempdima}
\else
\GenericError
{}{Fatal error: Negative \string\textwidth}
{Make the left and right column smaller}{}%
\stop
\fi
\newcommand\intoleftcolumn[1]
{%
% it is assumed that \intoleftcolumn is always called where a \par can
% appear
%\par
\noindent
\smash{\llap{\parbox[t]{\leftcolumn}{#1}\hskip\leftcolumnsep}}%
}
\newcommand\intorightcolumn[1]
{%
% just use \marginnote for this
\marginnote{#1}%
}
\let\sectionlinesformat@orig\sectionlinesformat
\renewcommand\sectionlinesformat[4]
{%
\ifstr{#1}{section}
{%
\noindent\hskip-\leftcolumn\hskip-\leftcolumnsep
\rlap
{%
\parbox[t]{\totalcolumnswidth}
{\sectionlinesformat@orig{#1}{#2}{#3}{#4}}%
}%
}%
{\intoleftcolumn{\sectionlinesformat@orig{#1}{#2}{#3}{#4}}}%
}
\RedeclareSectionCommand[afterskip=-\baselineskip,runin=false]{subsection}
\RedeclareSectionCommand[afterskip=-\baselineskip,runin=false]{subsubsection}
\makeatother

\usepackage{duckuments} % interesting dummy text

% should be loaded at the end of the preamble
\usepackage[]{hyperref}

\begin{document}
\section{This is a section}
\blindduck
\subsection{This is a subsection\label{sec:sub}}
\blindduck
\subsubsection{This is a subsubsection}
\blindduck
\end{document}


• +1 for this great alternative. However, you might want to point out that the section header is now left aligned with the middle column and not with the left column (as it is in the original example). – leandriis Jun 23 at 14:35
• @leandriis oh, I interpreted the first point of the question that way and didn't look at the MWE. Will post an edit. – Skillmon Jun 23 at 17:21

Maybe you are more satisfied with the following layout:

\documentclass[11pt,a4paper,numbers=noenddot]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[left=2cm, right=1cm]{geometry}

\usepackage{paracol}
\setcolumnwidth{3.5cm,9.1cm,5cm}
\setlength{\columnsep}{0.2cm}
\usepackage{lipsum}

\usepackage[bookmarks=false]{hyperref}

\begin{document}

\begin{paracol}{3}[\section{\underline{SECTION I - The Project Statement}}]
\switchcolumn[0]
\subsection{Subsection 1}\label{subsec:first}
\switchcolumn[1]
\sloppy
\lipsum[1]
\switchcolumn[2] {\raggedright
see \texttt{www.example.com/example}}

\switchcolumn[1]*
\sloppy
\lipsum[2]
\switchcolumn[2]{\raggedright
see \texttt{Mayer et. al.} }
\switchcolumn[0]*
\subsection{A longer Subsection with a quite long title}
\switchcolumn[1]
\sloppy
\lipsum[4]
\switchcolumn[2]{\raggedright
\switchcolumn[0]*
\end{paracol}

\end{document}


What I changed in comparison to your original layout: I used a larger width for the first and third column and also explicitly specified the width between the columns.

Why did I decide to change the above mentioned values? Let's have a look at the following MWE that is essentially a shortened version of your code where I have just added some code to generate colored lines. The red lines indicate the textwidth and the blue lines indicate the widths of the columns you chose.

\documentclass[11pt,a4paper,numbers=noenddot]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[left=2cm, right=1cm]{geometry}

\usepackage{paracol}
\setcolumnwidth{10pt,60pt,10pt}

%%%% Colored lines %%%%
\usepackage{showframe}
\renewcommand*\ShowFrameColor{\color{red}}
\setlength{\columnseprule}{0.4pt}
\colseprulecolor{blue}
%%%%               %%%%

\usepackage{lipsum}

\begin{document}

\begin{paracol}{3}[\section{\underline{SECTION I - The Project Statement}}]
\switchcolumn[0]
\subsection{Subsection1}
\switchcolumn[1]
\sloppy
\lipsum[1]
\switchcolumn[2]
see \texttt{www.example.com/example}
\end{paracol}

\end{document}


As you can see from the above example, your left column is too narrow for the text it contains. Only the quite large standard width between columns (\columnsep) prevents the subsection header from overlapping with the text in the middle column. Also the widths of your columns added up are wider than the textwidth:

left col + columnsep + middle col + columnsep + right col > textwidth


To overcome this issue I have recalculated the widths as follows: A standard A4 paper is 21 cm wide. If we substract the left and right margin (2 and 1 cm respectively) that you have set via geometry, we end up with a textwidth of 18 cm that we can use for the column. These 18 cm are split up into three columns as follows with 0.2 cm being the width of the white space between the columns.

3.5 cm  + 0.2 cm + 9.1 cm  + 0.2 cm + 5 cm = 18 cm


If we now add the following block of code into the first MWE, we obtain the following result. From this, we can clearly see that now the columns don't overlap with each other or the margins.

\usepackage{showframe}
\renewcommand*\ShowFrameColor{\color{red}}
\setlength{\columnseprule}{0.4pt}
\colseprulecolor{blue}


Similar to Leandaris' solution, except that I used the url package to break the url and measured the width of the subsection title (presumably the largest one).

The biggest problem was that \raggedright wouldn't confine itself to one column. Note: if you want the first paragraph after the subsection to be indented, add \everypar{} to the column preamble.

\documentclass[11pt,a4paper,numbers=noenddot]{scrartcl}
%\usepackage[utf8]{inputenc}
%\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[left=2cm, right=1cm]{geometry}

\usepackage{paracol}
\globalcounter{section}
\globalcounter{subsection}
\begingroup% compute using local registers
\sbox0{\Large\textbf{{Subsection1}}}%
\dimen0=\dimexpr \textwidth-2\columnsep-\wd0-\marginparwidth\relax
\xdef\columnA{\the\wd0}% save as global macros
\xdef\columnB{\the\dimen0}%
\endgroup

\setcolumnwidth{\columnA,\columnB,\marginparwidth}
\definecolumnpreamble{1}{\sloppy \parindent=\bibindent \rightskip=0pt}% parameters will not reset automatically
\definecolumnpreamble{2}{\parindent=0pt \rightskip=0pt plus 1fil}% \ragggedright

\usepackage{lipsum}
\usepackage{url}

\begin{document}

\begin{paracol}{3}[\section{\underline{SECTION I - The Project Statement}}]
\switchcolumn[0]
\subsection{Subsection1}
\switchcolumn[1]
\lipsum[1]
\switchcolumn[2]
see \url{www.example.com/example}
\switchcolumn[1]*
\lipsum[2]
\switchcolumn[2]
see \texttt{Mayer et.\ al.}% period not end of sentence
\end{paracol}

\end{document}