Skip to content

Commit 2c2e1ef

Browse files
authored
Merge pull request #1830 from quarto-dev/sync-1829-to-prerelease
2 parents ce742fd + c37a5ef commit 2c2e1ef

File tree

3 files changed

+88
-1
lines changed

3 files changed

+88
-1
lines changed

docs/authoring/diagrams.qmd

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,18 @@ format:
200200

201201
Valid values for `mermaid-format` include `js`, `png`, and `svg`,
202202

203+
::: callout-warning
204+
## SVG Format Limitations with PDF Output through LaTeX
205+
206+
When rendering to LaTeX-based formats, `mermaid-format: svg` requires additional tooling and may have rendering issues:
207+
208+
- **Requires installation:** `rsvg-convert` or `inkscape` must be available in your system PATH for Quarto to convert SVG to PDF to include in LaTeX.
209+
- **Potential rendering issues:** Text clipping in diagrams with multi-line labels
210+
- **Recommended:** Keep default `mermaid-format: png` for PDF output with LaTeX.
211+
212+
For more details, including installation instructions and Inkscape configuration, see [SVG Images](/docs/output-formats/pdf-basics.qmd#svg-images).
213+
:::
214+
203215
## Mermaid Themes {#mermaid-theming}
204216

205217
{{< include _mermaid-theming.qmd >}}

docs/output-formats/pdf-basics.qmd

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,71 @@ With fonts with appropriate support, Greek symbols render correctly in headings,
214214
![Greek symbols in a rendered PDF](images/pdf-unicode-greek.png){.border fig-alt="Screenshot of at PDF displaying the Greek symbol alpha in a heading, main text and code cell."}
215215

216216

217-
217+
## SVG Images {#svg-images}
218+
219+
### Using `rsvg-convert` to convert to PDF
220+
221+
Quarto supports rendering of PDF documents that include SVG files, automatically converting them to PDF images if `rsvg-convert` is available on the system path during rendering.
222+
223+
You can learn more about installing `librsvg`{spellcheck="false"} (which provides `rsvg-convert`{spellcheck="false"}), see <https://wiki.gnome.org/Projects/LibRsvg>. To install on specific platforms:
224+
225+
- On MacOS, use Homebrew: `brew install librsvg`{spellcheck="false"}
226+
- On Linux, tarballs available at: <https://download.gnome.org/sources/librsvg/>
227+
- On Windows, install using chocolatey: `choco install rsvg-convert`{spellcheck="false"} or using Scoop:
228+
229+
````powershell
230+
# scoop bucket add r-bucket https://github.com/cderv/r-bucket.git
231+
scoop install rsvg-convert
232+
````
233+
234+
### Alternative: Using Inkscape
235+
236+
If you prefer to use Inkscape instead of `rsvg-convert`, you can disable the default conversion by setting `use-rsvg-convert: false`. This will use the [SVG LaTeX package](https://ctan.org/pkg/svg) to include the svg using `\includesvg{}` which uses Inkscape to convert to PDF. This requires some configuration to opt-in:
237+
238+
```yaml
239+
format:
240+
pdf:
241+
use-rsvg-convert: false
242+
pdf-engine-opts: ["-shell-escape"]
243+
```
244+
245+
Note that this configuration requires:
246+
247+
- Inkscape to be installed and available on your system PATH
248+
- The `-shell-escape` option for your LaTeX engine to allow execution of external programs
249+
- The SVG LaTeX package (automatically included by Quarto)
250+
251+
### Platform Considerations
252+
253+
The availability and ease of installation for SVG conversion tools varies by platform:
254+
255+
- **Linux/macOS:** `rsvg-convert` is typically available through package managers (`librsvg` package). This is the recommended approach for these platforms.
256+
- **Windows:** Installing `rsvg-convert` is more challenging. While it can be installed via Scoop (as shown above), most Windows users should consider using PNG format for diagrams rather than SVG.
257+
- **Inkscape:** Available cross-platform but requires the `-shell-escape` configuration. Consider using this only when you specifically need Inkscape's rendering capabilities.
258+
259+
For diagram formats, PNG is generally recommended for best compatibility and ease of use. See the @nte-svg-diagram below for more details.
260+
261+
::: {#nte-svg-diagram .callout-note}
262+
## SVG Format for Diagrams
263+
264+
When using Mermaid or Graphviz diagrams in PDF documents, the default PNG format is recommended. While SVG output is possible with `mermaid-format: svg`, it requires external tooling:
265+
266+
- `rsvg-convert` (default) - See [installation instructions](#svg-images) above
267+
- Inkscape (alternative) - Requires `use-rsvg-convert: false` and `-shell-escape` configuration
268+
269+
SVG format may also have rendering issues such as text clipping in diagrams with multi-line labels. For most users, PNG format provides better compatibility and ease of use. See [Diagrams](/docs/authoring/diagrams.qmd#mermaid-formats) for more information.
270+
:::
271+
272+
## Remote Images
273+
274+
You can reference remote images directly using URLs:
275+
276+
```markdown
277+
![Penguins](https://example.com/images/penguins.png)
278+
```
279+
280+
Images are automatically downloaded during rendering and embedded in the PDF.
281+
218282
## Citations
219283
220284
{{< include _pdf-citations.md >}}

docs/prerelease/1.3/pdf.qmd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ title: PDF Format Improvements
33
search: true
44
---
55

6+
::: callout-note
7+
## Content Moved
8+
9+
The SVG and Remote Images content from this page has been migrated to the main documentation:
10+
11+
- [SVG Images](/docs/output-formats/pdf-basics.qmd#svg-images)
12+
- [Remote Images](/docs/output-formats/pdf-basics.qmd#remote-images)
13+
14+
This page is retained for historical reference.
15+
:::
16+
617
{{< include /docs/_require-1.3.qmd >}}
718

819
## SVG Images

0 commit comments

Comments
 (0)