Chapter 6 Quarto
Quarto Guide (quick tutorial): https://quarto.org/docs/guide/
Quarto Reference (detailed documentation): https://quarto.org/docs/reference/
Quarto Tutorial: https://jmjung.quarto.pub/m02-advanced-literate-programming/#learning-outcomes
Run Quarto in VS Code: https://quarto.org/docs/tools/vscode/index.html
Quarto is based on Pandoc and uses its variation of markdown as its underlying document syntax. See the full documentation of Pandoc’s Markdown for more in-depth documentation.
| Quarto Command | Keyboard Shortcut |
|---|---|
| Run Current Cell | ⇧ + ⌘ + Enter |
| Run Current Cell and Jump to Next Cell | ⇧ + Enter |
| Run Selected Line(s) | ⌘ + Enter |
| Run All Cells | ⌥ + ⌘ + R |
Host Quarto on GitHub Pages.
To get started, change your project configuration _quarto.yml to use docs as the output-dir.
Then, add a .nojekyll file to the root of your repository that tells GitHub Pages not to do additional processing of your published site using Jekyll (the GitHub default site generation tool):
- Note that
.nojekyll’s location is different than that ofbookdown, which is at/docsfolder.
6.0.1 Only re-render changed files
You can add the following to your _quarto.yml file to only re-render changed files:
When freeze: auto is enabled, Quarto checks for modifications in the source files of your computational documents. If no changes are detected, Quarto will utilize the cached results from previous computations, skipping the re-execution of code chunks.
This significantly speeds up rendering times, especially for large projects with many computational documents. ✅
There are drawbacks: some files may not be updated in time.
- Use
freeze: falseto force re-rendering of all files when you are able to submit your changes. - Use
freeze: autowhen you are editing actively and want to see your changes in time.
Strengths of Quarto:
- hoverable citations and cross-references, easy to read
- easy subplots
Weaknesses of Quarto:
slow compared to
BookdownWorkaround:
- Use
quarto previewin terminal to enable live preview - Set
freeze: autoin_quarto.ymlto only re-render changed files.
- Use
Issues when you want to compile one single page within a package. Changes are not reflected in time unless you render the whole website.
Workaround: Need to exclude from project index, and need file header
yamlto import mathjax settings and themes.Bookdownis reliable. Don’t needyamlin singleRmd, website theme will apply automatically.Not support
rstudioapifunctions. E.g., the following is often used to set working directory to the folder where the current script is located.But it does NOT work in Quarto.