quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.54k stars 292 forks source link

fig-cap-location margin support for Typst #10123

Open cderv opened 1 week ago

cderv commented 1 week ago
---
format: 
  html: default
  typst: default
---

```{r}
#| label: fig-test
#| fig-cap: TEST
#| fig-cap-location: margin
plot(cars)

I think currently we don't support margin in typst format - article Layout for typst is still to support. 

Though I believe we should have a failsafe and avoid bad error due to this missing support. 

This is what we get currently, 

typst]: Compiling test.typ to test.pdf...error: unknown variable: margin ┌─ \?\C:\Users\chris\Documents\DEV_OTHER\00-TESTS\test-quarto\test.typ:282:10 │ 282 │ position: margin,


because the `fig-cap-location` value is passed asis. We get this typ content for now
````typst

```r
plot(cars)

figure([

box(image("test_files/figure-typst/fig-test-1.svg"))

], caption: figure.caption( position: margin, [ TEST ]), kind: "quarto-float-fig", supplement: "Figure", )

```` Without cross-references, it just does not work without error ````markdown ```{r} #| fig-cap: TEST #| fig-cap-location: margin plot(cars) ``` ```` (it is working for HTML - just ignored for Typst which seems ok for now. A warning could be added in typst format case to explain `fig-cap-location` is ignored) So to sum up - We should probably not error like this and just ignore the configuration for typst so that it renders but with a default - We need to add support it - probably when we'll tackle article layout for typst format.
cderv commented 1 week ago

I saw now your comment, after preparing a PR for the first part of the sum up. No rendering error, and a warning, while using a fallback

cscheid commented 1 day ago

We fixed this in 1.5.

cderv commented 1 day ago

@cscheid FWIW I left this issue opened initially as a reminder to try add support for this layout in typst format.

Maybe this is not considered possible right now, but we are missing Article Layout for typst with margin content like LaTeX, so I thought we could keep it as a reminder