2

Its a question which surely has been asked multiple times. But so far I couldn't find a simple solution.

I'm trying to set up a simple twocolumn document using scrartcl class which contains images, sections, footnotes etc. Unfortunately, if sections or/and images are inserted, the alignment of the baseline of the text on both sides is lost.

I tried some things like adding \raggedbottom and using headings=normal as class option. I know there are some tricks to reach that goal, but I need the code to be as simple as possible. Because the template should be used with a simple markup format like Markdown and then exported to PDF through Latex and pandoc, I want to avoid the case to manually add correcting macros at specific points in the text.

Since I'm running a little bit out of time and cannot spend many hours skiming through the definitions, I hope someone with more experience concerning twocolumn styles has an idea.

Heres my MWE:

\documentclass[twocolumn,headings=normal]{scrartcl}

% layout %
\usepackage[top=2.5cm,bottom=3cm]{geometry}
\usepackage[bottom]{footmisc}
\raggedbottom

% font %
\usepackage{garamondlibre}

% images %
\usepackage{graphicx}

% test %
\usepackage{blindtext}
\title{A Title}
\author{lukeflo}
\begin{document}
\maketitle

\section{Section}

\blindtext[1]\footnote{A footnote text.}

\begin{figure}[htb]
  \centering
  \includegraphics[]{example-image-duck}
  \caption{A caption}
\end{figure}


\blindtext[1]

\subsection{Hallo}

\blindtext[1]\footnote{Another one}

\blindtext[1]

\subsection{haha}

\blindtext[1]\footnote{Sed}

\blindtext[1]

\blindtext[8]
\end{document}

If there is already a solution which I overlooked, sorry for the duplicate ;)

Edit 1:

Just tried @cabohah 's solutions. Both work fine so far, but can sometimes still produce little deviations from the baseline alignment. Lists with nosep option work too. Furthermore, I added an extra baselineskip to the calculation of \box_set_ht:Nn \image_box, so there is more space between top of the image and textbody:

\documentclass[twocolumn]{scrartcl}

% layout %
\usepackage[top=2.5cm,bottom=3cm,heightrounded,footnotesep=\baselineskip]{geometry}% heightrounded is
                                % needed to not need glue for the text area
\usepackage{microtype}

% footnotes %
\usepackage[bottom]{footmisc}
\deffootnote[2em]{0pt}{2em}{\textsuperscript{\thefootnotemark}\ }
\raggedbottom

% lists %
\usepackage{enumitem}
\setlist{nosep}

% font %
\usepackage{garamondlibre}
\RedeclareSectionCommands[beforeskip=2\baselineskip,afterindent=false,afterskip=1\baselineskip,font={\normalsize}]{section,subsection,subsubsection}
\setkomafont{disposition}{\normalsize\rmfamily}
\addtokomafont{section}{\scshape\bfseries}
\addtokomafont{subsection}{\bfseries}
\addtokomafont{subsubsection}{\itshape}
\addtokomafont{caption}{\sffamily}
\addtokomafont{captionlabel}{\sffamily\bfseries}

% images %
\usepackage{graphicx}
\ExplSyntaxOn
\box_new:N \image_box
\int_new:N \image_height_int
\NewDocumentCommand\includeimage { O{}m }
  {
    \hbox_set:Nn \image_box { \includegraphics[#1]{#2} }
    \int_set:Nn \image_height_int { \box_ht:N \image_box / \baselineskip }% hope this calculation is correct
    \box_set_ht:Nn \image_box { \image_height_int \baselineskip - \dp\strutbox + 1\baselineskip }% hope this calculation is correct
    \mbox{\box_use:N \image_box}
  }
\ExplSyntaxOff

% test %
\usepackage{blindtext}
\title{A Title}
\author{lukeflo}

\newlength{\imageheight}


\setlength{\intextsep}{\baselineskip}
\setlength{\abovecaptionskip}{\baselineskip}
\setlength{\belowcaptionskip}{0pt}

\begin{document}
\maketitle

\section{Section}

\blindtext[1]\footnote{\blindtext}

\begin{itemize}
\item An item
\item Another item
\end{itemize}

\begin{figure}[htb]
  \centering
  \includeimage[width=\columnwidth]{example-image-duck}
  \caption{A caption}
\end{figure}


\blindtext[1]

\subsection{Hallo}

\blindtext[1]\footnote{Another one}

\blindtext[1]

\subsection{haha}

\blindtext[1]\footnote{Sed}

\blindtext[1]\footnote{\blindtext}

\begin{figure}[htb]
  \centering
  \includeimage[width=\columnwidth]{example-image-duck}
  \caption{A caption}
\end{figure}

\blindtext[8]

\end{document}

Just have to check how to integrate the new includeimage command into my export workflow, but thats not part of this question.

0

1 Answer 1

2

IMHO, grid-setting works best, if you change all vertical distances to a (integer) multiple of \baselineskip and all font sizes to \normalsize. But for graphics, you would still need to adjust the graphics height (or align the graphics inside a box of height N * \baselineskip).

Just as an example:

\documentclass[twocolumn,headings=normal]{scrartcl}

% layout %
\usepackage[top=2.5cm,bottom=3cm,heightrounded]{geometry}% heightrounded is
                                % needed to not need glue for the text area
\usepackage[bottom]{footmisc}
\raggedbottom

% font %
\usepackage{garamondlibre}

% images %
\usepackage{graphicx}

% test %
\usepackage{blindtext}
\title{A Title}
\author{lukeflo}

\newlength{\imageheight}

\RedeclareSectionCommands[beforeskip=2\baselineskip,afterindent=false,afterskip=1\baselineskip,font=\normalsize]{section,subsection,subsubsection}

\setlength{\intextsep}{\baselineskip}
\setlength{\abovecaptionskip}{\baselineskip}
\setlength{\belowcaptionskip}{0pt}

\begin{document}
\maketitle

\section{Section}

\blindtext[1]\footnote{A footnote text.}

\begin{figure}[htb]
  \centering
  \includegraphics[height=\dimeval{9\baselineskip-\dp\strutbox}]{example-image-duck}
  \caption{A caption}
\end{figure}


\blindtext[1]

\subsection{Hallo}

\blindtext[1]\footnote{Another one}

\blindtext[1]

\subsection{haha}

\blindtext[1]\footnote{Sed}

\blindtext[1]

\begin{figure}[htb]
  \centering
  \includegraphics[height=\dimeval{9\baselineskip-\dp\strutbox}]{example-image-duck}
  \caption{A caption}
\end{figure}

\blindtext[8]

\end{document}

two pages of the document with grid-setting

or without scaling the images, but putting them into a box with rounded height:

\documentclass[twocolumn,headings=normal]{scrartcl}

% layout %
\usepackage[top=2.5cm,bottom=3cm,heightrounded]{geometry}% heightrounded is
                                % needed to not need glue for the text area
\usepackage[bottom]{footmisc}
\raggedbottom

% font %
\usepackage{garamondlibre}

% images %
\usepackage{graphicx}

% test %
\usepackage{blindtext}
\title{A Title}
\author{lukeflo}

\ExplSyntaxOn
\box_new:N \image_box
\int_new:N \image_height_int
\NewDocumentCommand\includeimage { O{}m }
  {
    \hbox_set:Nn \image_box { \includegraphics[#1]{#2} }
    \int_set:Nn \image_height_int { \box_ht:N \image_box / \baselineskip }% hope this calculation is correct
    \box_set_ht:Nn \image_box { \image_height_int \baselineskip - \dp\strutbox }% hope this calculation is correct
    \mbox{\box_use:N \image_box}
  }
\ExplSyntaxOff
  
\RedeclareSectionCommands[beforeskip=2\baselineskip,afterindent=false,afterskip=1\baselineskip,font=\normalsize]{section,subsection,subsubsection}

\setlength{\intextsep}{\baselineskip}
\setlength{\abovecaptionskip}{\baselineskip}
\setlength{\belowcaptionskip}{0pt}

\begin{document}
\maketitle

\section{Section}

\blindtext[1]\footnote{A footnote text.}

\begin{figure}[htb]
  \centering
  \includeimage{example-image-duck}
  \caption{A caption}
\end{figure}


\blindtext[1]

\subsection{Hallo}

\blindtext[1]\footnote{Another one}

\blindtext[1]

\subsection{haha}

\blindtext[1]\footnote{Sed}

\blindtext[1]

\begin{figure}[htb]
  \centering
  \includeimage[width=.5\columnwidth]{example-image-duck}% just to have an example with a smaller image
  \caption{A caption}
\end{figure}

\blindtext[8]

\end{document}

box instead of scale

Without such changes, grid-setting is hard, because IMHO LaTeX's twocolumn mode is not really made for grid-setting. The glue in the default of several distances is only used to justify the whole column not several code-points like floats or headings inside the column.

Nevertheless, as answers to similar questions like Text in two columns on the same level proof, it can be achieved even without such rigorous layout changes, but usually with lots of (mostly manually added) adjustment commands and lots of extra LaTeX runs.

4
  • That looks very promising, thank you. I will try it out ASAP. Since lot of manually added adjustments are no proper solution, it seems that those rigorous layout changes are necessary.
    – lukeflo
    May 15 at 17:47
  • 1
    @lukeflo You should still expect the need of several additional changes, e.g., for lists or even with multi-line captions. Some of them can be solved using additional (implicit or explicit) boxes. Some can be solved changing other length. But for some you may still need manual corrections. Sometimes one of the grid-setting packages may be useful, sometimes not. Sorry, but AFAIK there isn't something like a simple option to do it all.
    – cabohah
    2 days ago
  • No need to be sorry, since I guess its not your fault ;)
    – lukeflo
    2 days ago
  • To be honest, I'm a little but surprised. I'm using Latex for years, but until now mostly without two column layout. Nevertheless, two column is wide spread in different scientific fields. Thus, I thought there would be a well maintained solution to vertically aligned baselines in such documents. But maybe especially positioning of images might be tricky in this case. Maybe a seldom situation where a program with direct feedback like InDesign or Scribus might be superior. At least the lists maybe could be "fixed" with simple nosep to stay in "single-baselineskip-mode"
    – lukeflo
    2 days ago

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .