Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cderv opened this issue Dec 19, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request figures knitr needs-discussion Issues that require a team-wide discussion before proceeding further typst
Milestone

Comments

@cderv
Copy link
Collaborator

cderv commented Dec 19, 2024

See discussion at #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.

@cderv cderv self-assigned this Dec 19, 2024
@cderv cderv added this to the Future milestone Dec 19, 2024
@cderv cderv added the needs-discussion Issues that require a team-wide discussion before proceeding further label Dec 19, 2024
@mcanouil mcanouil added the enhancement New feature or request label Dec 19, 2024
@cscheid
Copy link
Collaborator

cscheid commented Dec 19, 2024

I believe we considered svglite in the past but decided against it because of some incompatibility between some SVGs it generated and Typst's SVG feature-set. If we're going to move to something non-standard, we need to make sure it's a sufficiently better experience.

@cderv
Copy link
Collaborator Author

cderv commented Dec 19, 2024

but decided against it because of some incompatibility between some SVGs it generated and Typst's SVG feature-set.

I thought this was fixed with newest typst we added in 1.6. Maybe still some unsupported feature.

If we're going to move to something non-standard, we need to make sure it's a sufficiently better experience.

I am considering also making knitr fallback mechanism to work from dev = "svg" to dev = "svglite" if the former is seen as non working. Not done by default in knitr but configuring some option we could make it happen. See #11680 (reply in thread)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request figures knitr needs-discussion Issues that require a team-wide discussion before proceeding further typst
Projects
None yet
Development

No branches or pull requests

3 participants