library(tinytable)
tt(mtcars[1:3, 1:5])
mpg | cyl | disp | hp | drat |
---|---|---|---|---|
21.0 | 6 | 160 | 110 | 3.90 |
21.0 | 6 | 160 | 110 | 3.90 |
22.8 | 4 | 108 | 93 | 3.85 |
quarto-preprint is a Quarto extension for creating PDF documents from markdown content with Typst. It provides one Quarto output format, preprint-typst, that aims to Just Work (Typst doesn’t require LaTeX installations and ships with Quarto), be fast (Typst creates PDF files very quickly), and be 100% Quarto standards compliant (write documents without worrying about formatting & metadata, switch to other Quarto formatd without changing anything but the output format). preprint-typst builds on the standard Quarto Typst template and enables separated author-affiliation formatting, additional (Quarto, Typst, and custom) metadata variables, opinionated typesetting, improved two-column layouts (including full-width floats), appendices, and more. Its intended use cases are worry-free but flexible typesetting of Quarto documents to PDF, especially when users might want to easily switch to other (e.g. journal-specific) formats.
“An article about computational science in a scientific publication is not the scholarship itself, it is merely advertising of the scholarship. The actual scholarship is the complete software development environment and the complete set of instructions which generated the figures.” –Buckheit and Donoho (1995, paraphrasing Jon Claerbout)
Quarto is “An open-source scientific and technical publishing system” (Allaire et al., 2025) for writing reproducible documents that combine computations and prose written in markdown into HTML, PDF, Word, and other outputs. For many R users, Quarto is a successor of R Markdown but with a broader scope and better support for different output formats and computational content in other languages.
quarto-preprint is a Quarto extension that provides one such output format, called preprint-typst. When using this format, Quarto renders your document into PDF using Typst, a modern replacement for LaTeX. preprint-typst builds on the standard Quarto Typst template and enables separated author-affiliation formatting, additional (Quarto, Typst, and custom) metadata variables, opinionated typesetting, improved two-column layouts (including full-width floats), appendices, and more (read below).
This document explains how to install, use and customize the output of Quarto documents created with the preprint-typst format. Example manuscripts using preprint-typst format include:
You can use this Quarto extension in two ways. First, you can add it to an existing project with
quarto add mvuorre/quarto-preprint
The quarto add
command, which you use on the command line and not the R console, creates a _extensions/preprint/
directory in your project. The preprint-typst format is then ready to use in any Quarto document in that project.
Second, you can start a new Quarto project that uses quarto-preprint with quarto-use
:
quarto use template mvuorre/quarto-preprint
You will then answer a series of questions (project name etc.) and end up with a new project directory with a {project-name}.qmd file that provides a starter Quarto document template that uses the preprint-typst format. It also creates a boilerplate _quarto.yml file where you can specify the Quarto project’s metadata, and an example bibliography.bib file.
The output of Quarto documents is configured through YAML front matter metadata. To specify an output format for your document, include (for example) format: preprint-typst
in the front matter. Here is a minimal example YAML front matter that specifies a title, a table of contents, and two output formats:
---
title: A document
# Top-level options apply to all formats,
# such as this table of contents
toc: true
format:
preprint-typst:
# Options under a format apply only to that format
wordcount: true
html:
title-block-banner: true
---
Document content goes here...
Note that many front matter variables can be specified for all output formats (such as toc
above) or for only some of them (like wordcount
above). To learn more about Quarto’s front matter options, see Quarto’s guide to writing scholarly documents, and Quarto’s Typst format documentation.
preprint-typst aims to include all standard Quarto front matter options for scholarly writing. In addition to standard Quarto YAML variables, preprint-typst supports additional fields and Typst variables, such as author notes and paragraph formatting. Below, we list available YAML configuration options roughly organized by their specificity to different Quarto output formats.
These work across all Quarto output formats (HTML, PDF, Word, etc.)
title
(string) - Document title [Documentation: Quarto]
title: "My Paper"
author
(string/array) - Author details with name, affiliation, email, etc. [Quarto]affiliations
(array) - Author affiliations with id, name, department [Quarto]subtitle
(string) - Document subtitle [Quarto]
subtitle: "A Study"
abstract
(string) - Document abstract [Quarto]
abstract: "This study..."
categories
(array) - Keywords/categories for the document [Quarto]
categories: ["science", "study"]
date
(string) - Publication date [Quarto]
date: "2024-01-01"
toc
(boolean) - Include table of contents [Quarto]
toc: true
toc-title
(string) - Customize TOC title [Quarto]
toc-title: "Contents"
toc-depth
(integer) - Number of heading levels in TOC [Quarto]
toc-depth: 2
number-sections
(boolean) - Number section headings [Quarto]
number-sections: true
bibliography
(string/array) - Bibliography file [Quarto]
bibliography: "bibliography.bib"
csl
(string) - Citation Style Language file or URL [Quarto]
csl: https://www.zotero.org/styles/apa
or csl: apa.csl
citeproc
(boolean; Tip 1) - Use Pandoc citation processing [Quarto]
citeproc: true
Typst has its own citation processing system, but by default preprint-typst turns it off by using citeproc: true
to allow better bibliography customization and use of Quarto’s #refs
div. In your document, include
# References
::: {#refs} :::
to display the bibliography section anywhere in the document. Read more at Quarto’s citations documentation.
fontsize
(string) - Base font size for document text [Quarto]
fontsize: "11pt"
mainfont
(string) - Main document font [Quarto]
mainfont: "Libertinus Serif"
monofont
(string) - Font family for code [Quarto]
monofont: "Monacy"
linkcolor
(string) - Color for hyperlinks [Quarto, Typst]
linkcolor: "blue"
or linkcolor: "#0066cc"
font-paths
(array) - Additional font search directories [Quarto]
font-paths: ["myfonts"]
fig-format
(string) - Figure output format [Quarto]
fig-format: "svg"
or fig-format: "png"
These work in Quarto’s Typst output formats but may not work in HTML, Word, etc.
papersize
(string) - Page size specification [Quarto]
papersize: a4
margin
(object/string) - Page margins [Quarto]
margin: {x: 2.8cm, y: 2.6cm}
columns
(integer) - Number of content columns [Quarto]
columns: 2
page-numbering
(string) - Page numbering pattern [Typst]
page-numbering: "1"
or page-numbering: "i"
section-numbering
(string) - Section numbering pattern [Quarto]
section-numbering: "1.1.a"
or section-numbering: "1.A.a"
These are native Typst variables exposed through the extension
line-number
(boolean) - Enable line numbers [Typst]
line-number: true
leading
(string) - Line height/spacing between lines [Typst]
leading: "0.5em"
spacing
(string) - Vertical spacing between paragraphs [Typst]
spacing: "0.6em"
first-line-indent
(string) - Indentation for paragraph first lines [Typst]
first-line-indent: "1.8em"
all
(boolean) - Whether to indent all paragraphs (including first in section) [Typst]
all: false
col-gutter
(string) - Horizontal spacing between columns [Typst]
col-gutter: "4.2%"
or col-gutter: "2em"
toc-indent
(string) - TOC indentation [Typst]
toc-indent: "1.5em"
These are custom features specific to this extension
running-head
(string) - Short title text displayed in page headers
running-head: "Short Title"
authornote
(string) - Text appearing after corresponding author information
authornote: "Author affiliations and contact"
wordcount
(boolean) - Display word count below abstract
wordcount: true
theme-jou
(boolean) - Apply journal theme with 2-column layout and compact spacing
theme-jou: true
functions
(array) - Enable Typst functions in divs [typst-function]
functions: ["place", "appendix"]
When starting a new project that uses the quarto-preprint template (quarto use template mvuorre/quarto-preprint
), the template Quarto file already includes some useful variables and their values. See Quarto’s Typst documentation for standard options and Typst documentation for styling details.
Below, we highlight some useful Quarto content features to show how they work with the preprint-typst output format.
Listing 1 shows an example R (R Core Team, 2025) code snippet for creating tables (Table 1) with the tinytable R package (Arel-Bundock, 2025).
library(tinytable)
tt(mtcars[1:3, 1:5])
mpg | cyl | disp | hp | drat |
---|---|---|---|---|
21.0 | 6 | 160 | 110 | 3.90 |
21.0 | 6 | 160 | 110 | 3.90 |
22.8 | 4 | 108 | 93 | 3.85 |
Figures are centered by default.
Figure 1 is a figure.
You can also include page-wide figures (or any other content) in documents that have more than one column. See Figure 2 for an example. First, include
functions: place
in the document’s YAML. Then, wrap your figure in a Quarto div like this:
::: {.place arguments='auto, scope: "parent", float: true'}
Everything here will span the whole page.
:::
The above uses the Typst’s place()
function through the typst-function Quarto extension to place the div’s content in "parent"
scope (the document page is the column’s parent) and must specify that Typst should treat the content as a float. auto
indicates where the figure should be on the page, and can be either auto
, bottom
, or top
. (Note auto
and bottom
can make the figure appear below footnotes.)
LaTeX math notation is automatically converted to Typst and as such works just fine either inline (\(y_i = \alpha + \beta x_i + \epsilon_i\)) or in display mode (Equation 1).
\[ f(x \mid \mu, \sigma^2) = \frac{1}{\sqrt{2\pi \sigma^2}} \exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right) \tag{1}\]
Send your comments, bug reports, and pull requests to https://github.com/mvuorre/quarto-preprint. If you’re reporting a bug, please include a reproducible example / full details of what you’re trying to do, how, and what goes wrong.
To include and appendix (Tip 2), place it at the end of the document and wrap all its content in an .appendix
Quarto div:
::: {.appendix}# Appendix: Computational details
Here we describe the computational details of our approach... :::
Appendices are an experimental feature. They are provided through a custom Typst function using the typst-function
Quarto extension, and their implementation and functionality may change as Quarto’s Typst integration matures.
Quarto documents require citations in a separate .bib file. The vscode-zotero VS Code plugin helps with inserting in-text citations and managing the .bib file. The plugin works in all VS Code based editors, including Positron.
Run quarto typst fonts
in your terminal (not R console) to list all available fonts.
Appendices have appropriate float references like Figure 3, Table 2, Listing 2.
sqrt(1 + 1)
## [1] 1.414214
Equations (Equation 2) work too but their numbering continues from main document.
\[ f(x \mid \mu, \sigma^2) = \frac{1}{\sqrt{2\pi \sigma^2}} \exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right) \tag{2}\]