I've been happily using the multicol
package to layout a set of documents that are generated for multiple output formats from the same source. By necessity this moves same code from the document source to a style file. For example I need to be able to make the choice to prepend a title or not from the style package. Instead of:
\begin{document}
\maketitle
I need to be able to run the equivalent of:
\AtBeginDocument{\maketitle}
\begin{document}
This seems simple enough, but multicol
wreaks havoc on breaking mdframed
boxes and apparently there is no way to fix that. So I've been trying to adapt to using the twocolumn
layout mode instead. This fixes the box breaking issues, but introduces new ones. First up I tried adding the option to my geometry
package, which I was already using. This had the odd effect of putting my title inside a column, which is not what I was after:
\documentclass{scrartcl}
\usepackage[twocolumn]{geometry}
\usepackage{lipsum}
\title{Title}
\author{Me}
\AtBeginDocument{\maketitle}
\begin{document}
\lipsum[1-3]
\end{document}
So I tried using the option of the document class instead.
\documentclass[twocolumn]{scrartcl}
\usepackage{geometry}
\usepackage{lipsum}
\title{Title}
\author{Me}
\AtBeginDocument{\maketitle}
\begin{document}
\lipsum[1-3]
\end{document}
This produces an error:
! LaTeX Error: Missing \begin{document}.See the LaTeX manual or LaTeX Companion for explanation.Type H for immediate help.... \begin{document}
Strangely, running \maketitle
manually solves this error:
\documentclass[twocolumn]{scrartcl}
\usepackage{geometry}
\usepackage{lipsum}
\title{Title}
\author{Me}
\AtBeginDocument{}
\begin{document}
\maketitle
\lipsum[1-3]
\end{document}
And in this version my title spans the columns like I want it to, but of course I can't properly control in which editions there should be a title in the first place, which makes it useless to me.
How can I either ① set the columns with geometry
but have the title span both columns or ② set them with the document class options but still be able to use \AtBeginDocument
?
\AtBeginDocument
still does code not meant for typesetting, before `\begin{document}.