17 Doing more with Quarto
This book is a curated collection of what we think are the most useful parts of Quarto for most people. However, there is much more to Quarto! In this chapter, we briefly cover some of the things we omitted from the book and why or when they might be useful to you.
We start with Quarto extensions, an ecosystem of additional features you can pull into your Quarto documents and projects. We then cover formats and project types beyond those we covered in the book. Finally, we will briefly cover other ways you can add interactivity to Quarto documents.
17.1 Quarto extensions
Quarto extensions are packages of components that you add to a project to get functionality Quarto doesn’t have built in.
Suppose you want to include icons from Font Awesome in your document. Quarto doesn’t have a built-in way to do this, but the fontawesome extension adds one. To add the extension, run quarto add at the root of your project:
Terminal
quarto add quarto-ext/fontawesomeIn this case, the argument quarto-ext/fontawesome is a GitHub repository: the fontawesome repository in the quarto-ext organization, the organization in which the Quarto team publishes its own extensions. Quarto asks you to confirm that you trust the authors of the extension, then downloads it.
This extension contributes a new shortcode, fa. To use it, you call the shortcode in your document like any other shortcode (Section 12.17):
report.qmd
{{< fa train >}} Train routes When you render, Quarto replaces the shortcode with the Font Awesome train icon.
You use quarto add to add an extension to an existing project. When you do, Quarto copies the extension source into the _extensions/ folder in your project. Other extensions, such as journal article templates, are designed as a starting point for a new project rather than an addition to an existing one. For these, use quarto use template instead of quarto add: it creates a new directory with the extension installed (in _extensions) and an example document to edit.
In either case, treat _extensions/ as part of your project’s source and commit it to version control. To manage extensions you’ve added to a project, use quarto list extensions, quarto update and quarto remove.
A good place to explore community contributed extensions is the Quarto extensions listing. Navigate to the extension’s documentation to understand what it does, how to add it, and any additional options you may need to configure to activate it.
Many extensions include Lua code that Quarto runs when you render. Only add extensions from authors you trust.
You can learn how to build your own extensions in Creating Extensions in the Quarto documentation.
17.2 Other formats
In this book, we focused on three formats: HTML (Chapter 9), PDF via Typst (Chapter 10), and Revealjs presentations (Chapter 11). You can render to many more. Most of what you’ve learned about writing, code cells, and options carries over to every format, but each format supports a different subset of features, so expect some things to look different or be missing when you switch.
17.2.1 Microsoft Word: docx
You can render to Word with format: docx. Word output relies heavily on Pandoc’s conversion, with fewer Quarto-specific additions than HTML or Typst. Quarto handles callouts, cross-references and figure layouts, but many other features render in a simpler form.
Your control over appearance in docx is also limited. You style Word output with a reference document: a Word file whose paragraph styles you customize. Only certain elements, and certain properties of those elements are customizable, and there is no mechanism for changes beyond these. There is currently no brand.yml support.
A common reason to prefer Word output is to get feedback from non-Quarto authors via track changes. Unfortunately, there is no easy backward path from an edited .docx to your .qmd source. You’ll need to copy any changes back to your .qmd source by hand.
You can learn more in Word Basics and Word Templates in the Quarto documentation. PowerPoint slides, format: pptx, work in a similar way and have similar limitations; see PowerPoint.
17.2.2 Markdown: gfm, hugo-md and docusaurus-md
Markdown formats render your document to a plain .md file, with your code executed and its output included as Markdown and image files. Use them when another system turns Markdown into the final product, and you want that Markdown to include computational results:
gfmproduces GitHub Flavored Markdown, for example, for aREADME.mdthat GitHub displays on a repository’s home pagehugo-mdproduces Markdown for a Hugo websitedocusaurus-mdproduces Markdown for a Docusaurus documentation site
In each case, the other system is in charge of the final output, so Quarto’s HTML features, like themes and navigation, don’t apply. You can learn more in GitHub (GFM), Hugo and Docusaurus in the Quarto documentation.
17.2.3 PDF via LaTeX: pdf and beamer
In Chapter 10, we explained why we use Typst to create PDFs. The alternative, format: pdf, creates a PDF via LaTeX instead. LaTeX is the better path when your target venue provides its own LaTeX template, as many journals do, or when you already rely on LaTeX packages, for example, for advanced math. Many of the journal article extensions (Section 17.1) use LaTeX. To use LaTeX, you need a TeX distribution. Quarto recommends TinyTeX, which you can install with the command quarto install tinytex.
Similar to Typst, you can keep the intermediate file, .tex for LaTeX, by setting keep-tex: true. The .tex file can be compiled outside of Quarto, so it’s often what a publisher asks for. Be aware that any edits you make to the .tex file will be overwritten the next time you render, so make your changes in the .qmd file instead.
For slides, format: beamer uses LaTeX to create PDF presentations. You can learn more in PDF Basics and Beamer in the Quarto documentation.
17.2.4 Dashboards: dashboard
A dashboard arranges content, like plots, tables, and key numbers, into a single full-screen page, rather than a long scrolling document. Use format: dashboard when your readers want to take in results at a glance.
A dashboard is a single .qmd file or Jupyter notebook where you arrange content, often computational plots and tables, as cards. Cards are arranged into rows and columns by using a simple syntax that relies on markdown headings.
A dashboard is static by default, so you can publish it anywhere you can publish HTML. For a dashboard that responds to reader input, you can add Shiny or Observable (Section 17.5). You can learn more in Dashboards in the Quarto documentation.
17.2.5 Any Pandoc format
Quarto can render to any format Pandoc supports, including OpenDocument (odt), EPUB (epub), JATS XML (jats, but see Section 17.4), Jupyter notebooks (ipynb) and many wiki formats. These formats get less attention from Quarto than the ones we’ve discussed, so Quarto-specific features like callouts and cross-references may be simpler or missing. You can find the full list in All Formats in the Quarto documentation.
17.3 Quarto books
A book project combines many Quarto documents, one per chapter, into a single book. Use a book when your content is long and meant to be read in order, for example, a book, a thesis, course notes, or a long report. This book is a Quarto book, and you can browse its source on GitHub.
A book project works much like a website project (Chapter 14), but adds features specific to books:
- Chapters are numbered, and you can group them into parts and appendices
- Cross-references work across chapters
- Citations from every chapter are collected into a single bibliography
When you render to HTML, you get a website with sidebar navigation in chapter order. When you render to PDF via Typst or LaTeX, or to EPUB or Word, you get a single file containing every chapter.
You can learn more in Books in the Quarto documentation.
17.4 Quarto manuscripts
A manuscript project is designed for publishing a scholarly article alongside the computations behind it. The output is a website: the article itself is the main page, with links to other formats, such as a PDF in a journal’s style, a Word version for reviewers, and JATS XML for submission, as well as links to the notebooks that produced the results. Readers can view each notebook as HTML or download its source. You can also embed outputs from those notebooks into the article, so your analysis can live in notebooks while the article focuses on the narrative.
JATS (Journal Article Tag Suite) is the XML standard that many publishers and archives, like PubMed Central, use to store and exchange articles. When you list jats as one of your manuscript’s formats, Quarto also produces a MECA (Manuscript Exchange Common Approach) bundle, a zip file that packages your article and its supporting files, including your notebooks, into a single file suitable for sending to a publisher. In the JATS output, your notebooks are included as sub-articles, so the computations travel with the article rather than only being linked from it.
Use a manuscript when you want readers, reviewers, or publishers to be able to dig into your code and results, not just read your article. If all you need is an article in a journal’s format, you don’t need a manuscript project; a single document with a journal format extension (Section 17.1) is enough.
You can learn more in Manuscripts in the Quarto documentation, and about the MECA bundle in Using Manuscripts.
17.5 Interactivity
In Chapter 9, you saw how widgets from R and Python packages add interactivity to HTML documents. Each widget is self-contained: a reader can explore the output, but can’t change what your code computes. If you want reader input, like a slider or a dropdown, to drive your outputs, Quarto has two built-in options: Shiny and Observable.
17.5.1 Shiny
Shiny is a framework for building interactive web applications in R or Python. When you set server: shiny in a document header, your document becomes a Shiny app: the document provides the layout and narrative, code cells define inputs and outputs, and a live R or Python process updates the outputs as readers change the inputs. Shiny is a good choice when the interactivity you want requires code to rerun, such as refitting a model with reader-chosen settings.
However, a Shiny document isn’t static HTML. It needs a server running R or Python, like Posit Connect or shinyapps.io, so you can’t publish it to static hosts like GitHub Pages. You also need to keep track of which code cells run when you render and which run for each reader. If you already have a standalone Shiny app, or the app is the main event, it’s often simpler to deploy the app on its own and embed it in your document with an <iframe> in a raw HTML block (?sec-html-raw-html).
Shinylive runs Shiny apps entirely in the reader’s browser, using WebAssembly builds of R (webR) and Python (Pyodide). With the shinylive extension (Section 17.1), you write a complete app in a {shinylive-r} or {shinylive-python} code cell, and Quarto embeds it in your page. Because no server is involved, you can publish the result anywhere you can publish HTML.
The downsides are that apps can take a while to load, not every package is available in the browser, and readers can see all your code and data. You can learn how to use Shinylive in Quarto in the shinylive extension documentation, and more about Shinylive itself for Python and R.
You can learn more about using Shiny with Quarto in the Quarto documentation.
17.5.2 Observable
Observable JS (OJS) is a flavor of JavaScript designed for exploring and visualizing data. You can write OJS in Quarto documents inside {ojs} code cells. The code runs in the reader’s browser, not when you render. OJS cells are reactive: when a reader changes an input, every cell that depends on it reruns. Because nothing runs on a server, you can publish a document with OJS anywhere you can publish HTML.
You can learn more in Observable JS in the Quarto documentation.
17.6 Wrapping up
You’ve reached the end of the book. We hope you now have both the practical skills to write, compute and publish with Quarto, and enough understanding of how Quarto works to tackle the features we didn’t cover. Most of them build on ideas you already know: Markdown for content, code cells for computation, options to control output, and projects to tie documents together.
To keep learning and get help:
- The Quarto documentation is the definitive reference. Use the Guide to learn about a feature, and the Reference to look up every option for a format.
- The Quarto blog announces new releases and features.
- GitHub Discussions is the place to ask questions. You’ll get better answers if you include a small, complete example, and Chapter 16 can help you narrow a problem down to one.
Happy writing, coding, and publishing!