quarto-dev / quarto-dev/quarto-cli

Vector graphics (htmlwidget) in typst, similar to default pdf

Open
#7,716 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug description

I wish it was possible to render vector-based plots with typst, similar to the crisp quality produced with default pdf. The webshot-solution for typst is far from ready-to-go and requires several tweaks with fig-dpi, and occasionally also fig-width. I have tried with fig-format: svg and prefer-html: true in vain.
This is a particularly annoyance with htmlwidget-based graphics such as ggiraph, where the resulting default webshot2 is of low resolution. Sure, one can adjust with fig-dpi: 450, but that also explodes the physical size of the figure on the page (should probably be a separate issue, but connects with the above).

Steps to reproduce
---
format:
  pdf: default # replace with typst to see difference
---


```{r}
#| label: 'fig-a'
#| fig-cap: 'Good resolution, but non-selectable text'
  ggplot2::ggplot(mtcars, mapping = ggplot2::aes(x=mpg, y=disp)) +
  ggplot2::geom_point()
```


```{r}
#| label: 'fig-b'
#| fig-cap: 'Even worse using webshot'
fig1 <-
  ggplot2::ggplot(mtcars, mapping = ggplot2::aes(x=mpg, y=disp)) +
  ggiraph::geom_point_interactive()

ggiraph::girafe(ggobj = fig1)
```

Expected behavior

image
Notice that text is selectable, when rendering with pdf: default

Actual behavior

Notice that text is not selectable:
image

Even worse when htmlwidget:
image

Setting fig-dpi: 196 to improve on the ggiraph-plot blows up the size
image

Your environment
  • IDE: RStudio 2023.12.0 Build 170
  • Windows 11
Quarto check output
Quarto 1.4.510
[>] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.9: OK
      Dart Sass version 1.69.5: OK
      Deno version 1.37.2: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
      Version: 1.4.510
      Path: C:\Program Files\Quarto\bin
      CodePage: 1252

[>] Checking tools....................OK
      TinyTeX: v2023.09
      Chromium: (not installed)

[>] Checking LaTeX....................OK
      Using: TinyTex
      Path: C:\Users\py128\AppData\Roaming\TinyTeX\bin\windows\
      Version: 2023

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....OK
      Version: 3.11.4
      Path: C:/Users/py128/AppData/Local/Programs/Python/Python311/python.exe
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with py -m pip install jupyter

[>] Checking R installation...........OK
      Version: 4.3.1
      Path: C:/PROGRA~1/R/R-43~1.1
      LibPaths:
        - C:/Users/py128/AppData/Local/R/win-library
        - C:/Program Files/R/R-4.3.1/library
      knitr: 1.44
      rmarkdown: 2.25

[>] Checking Knitr engine render......OK

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.

Research direction

Start by reproducing the issue with the supplied Quarto document, comparing the default PDF and Typst outputs, including the ggiraph htmlwidget example. Investigate the Typst figure-rendering path and determine what would be required for vector output with selectable text and without changing the physical figure size; done means both examples render crisply in Typst.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
cli
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.