Quarto: A multi-purpose tool for research documentation and dissemination

Quarto: A multi-purpose tool for research documentation and dissemination

By Bella Ratmelia, Librarian, Data Services

If you are an avid user of R or Python, chances are you have heard of or even used Quarto before. But if you have not, allow me to introduce this very handy tool!

A quick heads up: while Quarto also supports Python and Julia, the focus in this article will be on its use with R and RStudio.

What is Quarto?

Quarto is a multi-language document developed by Posit. It enables you to weave together content and executable code into a finished document, creating a cohesive document that houses your code snippets, math formulas using LaTeX, visualizations, citations, and text—all in one place! Conveniently, Quarto comes pre-installed with the latest version of RStudio, which saves you from installing additional packages.

Quarto can also be rendered to either HTML, Word, or PDF. It also supports rendering to presentation formats like RevealJS or PowerPoint. Personally, for presentation, I lean towards RevealJS; it's much more lightweight compared to PowerPoint and lends itself well to online publishing (more on this shortly).

Weaving all contents together

Quarto documents will have a . qmd extension and can be edited in either the source or visual editor. The screenshot below shows the visual editor on the left pane, and the rendered HTML result on the right.

NA
Figure 1. Quarto document and the rendered HTML side-by-side

Text contents via Markdown

The text in a Quarto document is crafted using Markdown, specifically RMarkdown. Markdown is a very lightweight markup language used to create formatted text (bolded text, italicized text, headings, and the like) using plain text. Markdown files, easily identified by the .md extension, can seamlessly be rendered into HTML pages when the need arises.

Rmarkdown is essentially an iteration of Markdown that also incorporates code chunks to integrate R codes with the textual contents. Quarto is the latest iteration, the next-generation version of Rmarkdown that offers more customization options.

R (or Python) Code Chunks

One of Quarto's standout features is the embedded code, or “code chunks”. These chunks allow you to insert and execute code directly within the Quarto document, and get the results displayed beneath each chunk. (If you are a python user, this might remind you of Jupyter notebook!).

Additionally, you can control whether these code chunks should be displayed or hidden in your rendered HTML or Word document. This flexibility is very useful because you may not want to show your code all the time, e.g. you may want to hide the code chunk that’s loading the libraries you need for your codes.

NA
Figure 2. Code Chunks in Quarto

The code chunks itself has many other settings; you can choose to hide the errors or warning, to not display the output, or even label them for cross-referencing or linking within different sections of your Quarto document.

Math formulas with LaTeX typesetting

Other than code chunks, you can also include LaTeX typesetting to display math formulas in your Quarto document, as shown in Figure 3 below.

LaTeX is a document preparation system for high-quality typesetting often used for technical and scientific documents. Though in the context of Quarto, it is primarily used for its advanced mathematical formulas typesetting feature. You can either display it inline within your text, or as a standalone display.

Citation

If you are using Zotero to manage your references and have it installed in your laptop/pc, RStudio will automatically detect and “connect” to it upon installation. This enables you to easily cite your references that you’ve collected in your Zotero libraries. Upon insertion, citations within the document are catalogued in a separate bibliography file. Quarto then utilizes this file to automatically generate a reference list at the end of the document—though you have the flexibility to customize this placement.

By default, Quarto will cite your references in Chicago Manual Style. To change the style (to APA, IEEE, ASA, or others), simply download the Citation Style Language (CSL) file from the CSL Project repository and customize it in your Quarto document.

NA
Figure 3. TeX Display Math and Citation in Quarto

Conversion and Publishing Options

If you want to publish your rendered quarto document or presentations online, you can publish it in Quarto Pub. It's a free publishing platform tailored for Quarto, perfect for blogs, course websites, or personal projects. A word of caution: contents put in quarto pub will be publicly visible. Alternatively, you can explore GitHub Pages or Netlify apps. GitHub Pages is free, while Netlify operates on a freemium model.

If simplicity is your main priority, i.e. you don’t need a complex editing permissions and you just want a quick and easy way to share or present your research insights, then Quarto Pub is worth considering! I personally found the whole publishing process in Quarto Pub more streamlined compared to GitHub Pages, likely because Quarto Pub is specifically designed for Quarto documents. You can find a step-by-step guide on the Quarto documentation page: Quarto Pub Guide.

More Resources

  • Quarto examples gallery
  • Get started with Quarto by Mine Çetinkaya-Rundel
  • Quarto for Academics by Mine Çetinkaya-Rundel

If you prefer a hands-on approach, SMU Libraries host a series of bite-size workshops conducted by Assoc Prof. Kam Tin Seong from SCIS that delve into using R and Quarto for various purposes. Check them out here!