I'm writing a PDF article using a twocolumn
classoption in Quarto and the PDF produced has all content including the abstract laid out in two columns. I'd like the abstract to be displayed across the length of the page without the columns and the remainder of the body be in the two columns. Can anyone help me with how to format this?
The abstract is specified using the default yaml options.
abstract: example abstract text
Reference image
Tried looking at latex templates and copying code over but haven't had any success.
You can solve this problem following this answer on TeX StackExchange and using Latex Partials
.
Specifically, you need to use the before-body.tex
template partial to write the abstract part inside a twocolumnfalse
latex environment. So create the file before-body.tex and add the following,
before-body.tex
$if(has-frontmatter)$
\frontmatter
$endif$
$if(title)$
\makeatletter
\twocolumn[
\maketitle
\begin{@twocolumnfalse}
\begin{abstract}
% Write your abstract here ----------------------------------------------------
\vspace{1em}
Lorem ipsum dolor sit amet consectetur adipiscing elit, urna consequat felis vehicula
class ultricies mollis dictumst, aenean non a in donec nulla. Phasellus ante
pellentesque erat cum risus consequat imperdiet aliquam, integer placerat et
turpis mi eros nec lobortis taciti, vehicula nisl litora tellus ligula porttitor metus.
Vivamus integer non suscipit taciti mus etiam at primis tempor sagittis sit, euismod
libero facilisi aptent elementum felis blandit cursus gravida sociis erat ante, eleifend
lectus nullam dapibus netus feugiat curae curabitur est ad. Massa curae fringilla
porttitor quam sollicitudin iaculis aptent leo ligula euismod dictumst, orci penatibus
mauris eros etiam praesent erat volutpat posuere hac. Metus fringilla nec ullamcorper odio
aliquam lacinia conubia mauris tempor, etiam ultricies proin quisque lectus sociis id
tristique, integer phasellus taciti pretium adipiscing tortor sagittis ligula.
% abstract completed ----------------------------------------------------------
\end{abstract}
\vspace{3em}
\end{@twocolumnfalse}
]
\makeatother
$endif$
Then to add this template, use the template-partials
yaml option in the qmd file.
---
title: "Abstract in two column layout"
author: StackOverflow
date: "November 2, 2022"
format:
pdf:
classoption: twocolumn
include-in-header:
text: |
\usepackage{lipsum}
template-partials:
- before-body.tex
---
## Quarto
\lipsum
Note that, create the partial file named exactly as before-body.tex
, since per the documentation,
Note that the name of the partial files is important. You choose which portion of the template to replace by providing a partial with that name.
And I have used the latex package lipsum
just to generate Lorem Ipsum text, otherwise it's not related to the problem in question.