[knitr] Consider defaulting to svglite when svg device is used on R (e.g. as default in `format: typst)`

Open
#11,712 2 comments 1 reaction 1 assignee View on GitHub

@cderv is already working on this.

Since Dec 19, 2024.

Assessment

This issue has not been assessed yet.

Description

early-in-release engines-knitr enhancement figures typst

See discussion at https://github.com/quarto-dev/quarto-cli/discussions/11680

format: typst sets fig-format: svg as default.

In R, this leads to set dev = 'svg' for knitr, and this will use the grDevices::svg().

It seems this R device on MacOS will require to use X11 and so have XQuartz installed, which is not the case by default on OSX environment.

To currently this means thant using Typst in Quarto to produce PDF requires X11 on mac when the document / project uses R. It does not seem ideal.

Other option in R ecosystem is svglite https://github.com/r-lib/svglite

We could consider using it as default for Quarto with R by setting dev = 'svglite' when fig-format: 'svg'. Or doing it only when svglite 📦 is available on the environment.

Currently only way to set it is doing

knitr:
  opts_chunk:
    dev: svglite

as fig-format: svglite is not an option, because fig-format is supposed to be engine agnostic.

This could also be handled at the knitr level by default to svglite if available. Or having a better fallback mechanism for dev = 'svg' to detect it is not working.

Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from quarto-dev/quarto-cli

All issues in quarto-dev/quarto-cli

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.