Educational Statistics and Research Methods (ESRM) Program*
University of Arkansas
2025-02-05
What is Quarto
An open-source scientific and technical publishing system
.rmd
), Quarto uses knitr (the engine translating Markdown text into html/pdf files) to execute R code (.qmd
)..qmd
(on the left), along with its rendered version as HTML (webpage .html
on the right).Installation
You can follow along with the tutorial via the official video - Get Started with Quarto
If you would like to follow along with this tutorial in your own environment, follow the steps outlined below.
Once you open up the .qmd
file, you can use the Render button in the RStudio IDE to render the file and preview the output with a single click or keyboard shortcut (⇧⌘K).
If you prefer to automatically render whenever you save, you can check the Render on Save option on the editor toolbar. The preview will update whenever you re-render the document. Side-by-side preview works for both HTML and PDF outputs.
There two modes of the RStudio editor: visual (on the left) and source (on the right).
Source and Visual
Source mode follows the markdown format.
Visual mode is more similar to Word
Each Quarto document (.qmd
) typically starts with YAML Header t
YAML header contains some setup information (metadata), such as title
, subtitle
, author
, date
, output file format (html, pdf, or slides)
An (optional) YAML header demarcated by three dashes (---
) on either end.
key: value
---
title: "Lecture 07: Quarto Document"
subtitle: "quarto"
author: "Jihong Zhang*, Ph.D"
institute: |
Educational Statistics and Research Methods (ESRM) Program*
University of Arkansas
date: "2025-02-05"
date-modified: "2025-03-18 11:01:48.792006"
sidebar: false
execute:
eval: true
echo: true
warning: false
output-location: default
code-annotations: below
highlight-style: "dracula"
format:
html:
code-tools: true
code-line-numbers: false
code-fold: false
number-offset: 0
uark-revealjs:
scrollable: true
chalkboard: true
embed-resources: false
code-fold: false
number-sections: false
footer: "ESRM 64503 - Lecture 07: Quarto"
slide-number: c/t
tbl-colwidths: auto
output-file: slides-index.html
---
Code chunks contains code that can be output directly into the output file.
R code chunks identified with {r}
with (optional) chunk options, in YAML style, identified by #|
at the beginning of the line.
You can also run each code chunk interactively in the RStudio editor by clicking the icon or keyboard shortcut (⇧⌘↩︎).
# A tibble: 6 × 8
species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g
<fct> <fct> <dbl> <dbl> <int> <int>
1 Adelie Torgersen 39.1 18.7 181 3750
2 Adelie Torgersen 39.5 17.4 186 3800
3 Adelie Torgersen 40.3 18 195 3250
4 Adelie Torgersen NA NA NA NA
5 Adelie Torgersen 36.7 19.3 193 3450
6 Adelie Torgersen 39.3 20.6 190 3650
# ℹ 2 more variables: sex <fct>, year <int>
Documentation of Code Chunk settings is confusing. You can find some illustration in multiple places in quarto.org:
Except YAML Header and Code Chunks, other text contents are displayed with the format of Markdown language
There are two ways of editing quarto file: (1) markdown in Source mode (2) clicking in Visual mode
Quarto uses markdown syntax for text. If using the visual editor, you won’t need to learn much markdown syntax for authoring your document, as you can use the menus and shortcuts to add a header, bold text, insert a table, etc.
##
, **bold**
, etc.Math text
Create a new file called quarto_pdf.qmd
Use the pdf
format to create PDF output. For example:
quarto_pdf.qmd
What: Quarto Extensions are a powerful way to modify or extend the behavior of Quarto, and can be created and distributed by anyone. There are several types of extensions available:
Extension Type | Description |
Shortcodes | Special markdown directives that generate various types of content. For example, you could create shortcodes to embed tweets or videos in a document. |
Filters | A flexible and powerful tool for introducing new global behaviors and/or new markdown rendering behaviors. For example, you could create filters to implement output folding, an image carousel, or just about anything you can imagine! |
Journal Articles | Enable authoring of professional Journal articles using markdown, and produce both LaTeX (PDF) and HTML versions of the articles. |
Custom Formats | Create new output formats by bundling together document options, templates, style sheets, and other content. |
Revealjs Plugins | Extend the capabilities of HTML presentations created with Revealjs. |
Project Types | Create new project project types that bundle together standard content and options, or make it easy to create a website for a custom HTML format. |
Starter Templates | Help users get started with new projects by providing a template and example content. Starter templates aren’t strictly extensions (i.e. they aren’t installed in the _extensions directory) but they are often used with custom formats and project types. |
Metadata | Provide YAML configuration that can be merged into existing Quarto projects. |
The Quarto Extensions GitHub organization provides a set of extensions developed by the core Quarto team. Many of these extensions implement frequently requested features, and all of them provide sound examples of how to implement extensions.
The Quarto Journals GitHub organization contains a set of Journal Article formats developed by the core Quarto team or contributed by third parties.
Finally, most published extensions are hosted on GitHub and therefore have source code available that you can learn from.
my-cv
in the Directory name questionQuarto templates may execute code when documents are rendered. If you do not
trust the authors of the template, we recommend that you do not install or
use the template.
? Do you trust the authors of this template (Y/n) › Yes
? Create a subdirectory for template? (Y/n) › Yes
? Directory name: › my-cv
[✓] Downloading
[✓] Unzipping
The template requires the following changes to extensions:
Quarto-awesomecv-typst [Install] 0.1.0 (format)
? Would you like to continue (Y/n) › Yes
my-cv.qmd
in Source Mode with Rstudio. Type in the following command in Console
panel---
title: "Jihong Zhang's CV"
author:
firstname: Jihong
lastname: Zhang
address: "Rämistrasse 101, CH-8092 Zürich, Switzerland, Zürich"
position: "Research Physicist ・ Professor"
contacts:
- icon: fa envelope
text: ae@example.com
url: "mailto:ae@example.com"
- icon: assets/icon/bi-house-fill.svg
text: example.com
url: https://example.com
- icon: fa brands orcid
text: 0000-0000-0000-0000
url: https://orcid.org/0000-0000-0000-0000
- icon: fa brands github
text: GitHub
url: https://github.com/example
- icon: fa brands linkedin
text: LinkedIn
url: https://linkedin.com/in/example
- icon: fa brands x-twitter
text: twitter
url: https://twitter.com/example
execute:
echo: false
eval: true
warning: false
output: asis
format: awesomecv-typst
---
## Education
section```{r}
library(typstcv)
educ <- data.frame(
title = c("Ph.D. in Education",
"Master of Science"),
location = c("Iowa, U.S.",
"Kansas, U.S."),
date = c("2019", "2015"),
description = c("University of Arkansas", "Fayetteville")
)
resume_entry(educ)
```
Quarto Websites are a convenient way to publish groups of documents. Documents published as part of a website share navigational elements, rendering options, and visual style.
Website navigation can be provided through a global navbar, a sidebar with links, or a combination of both for sites that have multiple levels of content. You can also enable full text search for websites.
Quarto websites can be published to a wide variety of destinations including GitHub Pages, Netlify, Posit Connect, or any other static hosting service or intranet web server. See the documentation on Publishing Websites for additional details.
_quarto.yml
config file that provides website options as well as defaults for HTML documents created within the site.theme: cosmo
to theme: materia
to see how website differDocumentation
See the documentation on Website Navigation and Website Tools for additional details on website configuration. See HTML Documents for details on customizing HTML format options.
If you are using RStudio, Render button (RStudio), automatically preview the website in an embedded window.
As you preview your site, pages will be rendered and updated. However, if you make changes to global options (e.g. _quarto.yml
or included files) you need to fully re-render your site to have all of the changes reflected.
Background Jobs when I render the quarto of today’s lecture
What to publish your website to the Internet?
Summary
.qmd
)ESRM 64503 - Lecture 07: Quarto