Search code examples
pdfr-markdownquartomermaid

Mermaid in pdf Quarto


I would like to use mermaid diagrams in Quarto pdf. Here is some reproducible code:

---
title: "RenderTest"
format: pdf
---

```{mermaid}
flowchart LR
  A[Hard edge] --> B(Round edge)
  B --> C{Decision}
  C --> D[Result one]
  C --> E[Result two]
```

Output:

ERROR: No inspectable targets

So I get an error. On the Quarto page it says:

For print output formats like pdf or docx, diagram rendering makes use use of the Chrome or Edge web browser to create a high-quality PNG. Quarto can automatically use an existing version of Chrome or Edge on your system, or alternatively if you don’t have either installed, can use a lighter-weight library version of Chrome (see Chrome Install below for details).

So I tried to install this using:

quarto tools install chromium

But I still get the error. So I was wondering if anyone knows how to use mermaid in Quarto pdf?


Solution

  • As discussed here, after installing the latest version of Quarto (Version: 1.3.276), it is possible to use Mermaid in Quarto pdf. Here is the output now of the code above:

    enter image description here

    You could check which version is installed by using quarto check in your terminal. So make sure to install the latest version of Quarto, check this: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.3.276