Articles

Session 1: Getting to know Quarto

Cynthia Huang

Tuesday, July 18, 2023

Scholarly Writing

Article Features

Quarto supports

  • a standardized schema for key details like authors and affiliations that can be expressed once in the source document,

  • cross-referencing of figures, tables, equations etc., and

  • the use of Citation Style Language (CSL) to automate the formatting of citations and bibliographies,

  • outputting to pdf, html, and docx with custom formatting,

Components of an Article

---
title: "Toward a Unified Theory of High-Energy Metaphysics: Silly String Theory"
date: 2008-02-29
author:
  - name: Josiah Carberry
    id: jc
    orcid: 0000-0002-1825-0097
    email: josiah@psychoceramics.org
    affiliation: 
      - name: Brown University
        city: Providence
        state: RI
        url: www.brown.edu
abstract: > 
  The characteristic theme of the works of Stone is 
  the bridge between culture and society. ...
keywords:
  - Metaphysics
  - String Theory
license: "CC BY"
copyright: 
  holder: Josiah Carberry
  year: 2008
citation: 
  container-title: Journal of Psychoceramics
  volume: 1
  issue: 1
  doi: 10.5555/12345678
funding: "The author received no specific funding for this work."
---
  • Metadata: Extended YAML front matter fields
  • Content: markdown text, tables, figures, raw LaTex, citations
  • Code: executed by knitr (R) or jupyter (python)

Metadata

Front Matter

  • Quarto pre-defines useful metadata keys for scholarly writing:
    • authors, affiliations, roles
    • article abstract and keywords
    • acknowledgements and thanks
    • citation, license, copyright, funding
  • but not all formats use every metadata field.

File Includes

The following include-in-* options allow you to include contents of a file (e.g. file.tex) verbatim at certain positions:

Option Position Use Cases
include-in-header

end of the header

before \begin{document} or <body>

Inject commands into the LaTeX preamble
include-before-body

beginning of the document body

after \begin{document} or <body>

Include navigation bars or banners in HTML
include-after-body

end of the document body

before \end{document} or </body>

LaTex Output

There are two ways to produce a LaTex file (.tex) using options specificed in the YAML header:

  1. Option 1: Use the latex format instead of pdf
format:
  latex:
    documentclass: report
    classoption: [twocolumn, landscape]
    lof: true
    lot: true
  1. Option 2: Use the keep-tex option in the pdf format
format:
  pdf:
    documentclass: report
    keep-tex: true

Content

Equations

or just use Visual Mode!

Figures

Markdown:

![Penguins playing with a Quarto ball](images/penguins-quarto-ball.png){fig-align="left" height="200px"}

Output (HTML):

Penguins playing with a Quarto ball

Figures

Markdown:

![Penguins playing with a Quarto ball](images/penguins-quarto-ball.png){fig-align="right" height="200px"}

Output (HTML):

Penguins playing with a Quarto ball

Subfigures

Markdown:

::: {#fig-penguins layout-ncol=2}

![Blue penguin](images/blue-penguin.png){#fig-blue width="250px"}

![Orange penguin](images/orange-penguin.png){#fig-orange width="250px"}

Two penguins

:::

Subfigures

Output (LaTex):

\begin{figure}

\begin{minipage}[t]{0.50\linewidth}

{\centering 

\raisebox{-\height}{

\includegraphics[width=2.60417in,height=\textheight]{images/blue-penguin.png}

}

}

\subcaption{\label{fig-blue}Blue penguin}
\end{minipage}%
%
\begin{minipage}[t]{0.50\linewidth}

{\centering 

\raisebox{-\height}{

\includegraphics[width=2.60417in,height=\textheight]{images/orange-penguin.png}

}

}

\subcaption{\label{fig-sleep}Orange penguin}
\end{minipage}%

\caption{\label{fig-penguins}Two penguins}

\end{figure}

Subfigures

Output (PDF):

LaTex Figure Options

Quarto can some options specific to LaTex output such as figure position and environments

---
title: "Sidenotes"
format:
  pdf:
    fig-pos: 'h'
    include-in-header: 
      text: |
        \usepackage{mdframed}
---

![Elephant](elephant.png){fig-env="mdframed"}

See PDF Reference > Figures for available options

Raw LaTex Commands

Pandoc (and thus Quarto) allows for mixing raw LaTex with markdown when creating PDF documents. For example:

\begin{tabular}{|l|l|}\hline
Age & Frequency \\ \hline
18--25  & 15 \\
26--35  & 33 \\
36--45  & 22 \\ \hline
\end{tabular}

Warning

Note that raw LaTex will not be rendered in HTML format. However, if you have existing LaTex content (e.g. from STATA) that can’t be re-exported or re-written in markdown this is a useful option.

Your Turn: my_first_article.qmd

  • Open my_first_article.qmd inside your last Rproject.
  • Follow the PDF exercise instructions
10:00

Journal Articles

Submit straight from Quarto

Journal Article extensions offer templates to adapt an existing .qmd document

  • according to the styles required for various journals,
  • and create the LaTeX required for submission to multiple journals.

Journal formats

Journal / Publisher Name
Association of Computing Machinery acm
American Chemical Society acs
American Geophysical Union agu
Biophysical journal biophysical-journal
Elsevier Journals* elsevier
American Statistical Association Journals jasa
Journal of Statistical Software jss
Public Library of Science plos

Getting started with a journal article

The quarto use template command can be used to create an article from one these formats, e.g. for Elsevier:

Terminal
quarto use template quarto-journals/elsevier

Our Turn: Journal Article Templates