There are also issues in general with scale, reflow, and figure captions:
If reflow is false, the size is correct but the caption not. If it's true, the reverse happens.
Using box gives the correct result.
#import"@preview/rivet:0.3.0":config,schema#letsch=schema.render(schema.load((structures:(main:(bits:16,ranges:("3":(name:"E")),),),),),config:config.config(margins:(0,0,0,0),default-font-family:"DejaVu Sans Mono",italic-font-family:"Libertinus Serif",),)#letwidth=300pt#showfigure.caption:setalign(left)#figure(scale(x:width,y:auto,reflow:false,sch),caption:[`scale`,noreflow],)#figure(scale(x:width,y:auto,reflow:true,sch),caption:[`scale`,reflow],)#figure(box(width:width,sch),caption:[`box`],)#figure(scale(x:width,y:auto,reflow:true)[#import"@preview/cetz:0.4.2"#cetz.canvas({importcetz.draw:*circle((0,0))line((0,0),(2,1))})],caption:[CeTZ],)
There are also issues in general with `scale`, `reflow`, and `figure` captions:
If `reflow` is `false`, the size is correct but the caption not. If it's `true`, the reverse happens.
Using `box` gives the correct result.
```typst
#import "@preview/rivet:0.3.0": config, schema
#let sch = schema.render(
schema.load(
(
structures: (
main: (
bits: 16,
ranges: ("3": (name: "E")),
),
),
),
),
config: config.config(
margins: (0, 0, 0, 0),
default-font-family: "DejaVu Sans Mono",
italic-font-family: "Libertinus Serif",
),
)
#let width = 300pt
#show figure.caption: set align(left)
#figure(
scale(x: width, y: auto, reflow: false, sch),
caption: [`scale`, no reflow],
)
#figure(
scale(x: width, y: auto, reflow: true, sch),
caption: [`scale`, reflow],
)
#figure(
box(width: width, sch),
caption: [`box`],
)
#figure(
scale(x: width, y: auto, reflow: true)[
#import "@preview/cetz:0.4.2"
#cetz.canvas({
import cetz.draw: *
circle((0, 0))
line((0, 0), (2, 1))
})
],
caption: [CeTZ],
)
```

I've replaced that if-else with just cnvs, compiled the examples as PNG, and doing a diff shows that they are the same...
It doesn't solve the issue btw.
I've been looking and... why do you have this logic in the renderer?
https://git.kb28.ch/HEL/rivet-typst/src/commit/3e74ad15ee68885b0ac729786418de9a3d6e36e7/src/renderer.typ#L535-L563
I've replaced that `if`-`else` with just `cnvs`, compiled the examples as PNG, and doing a `diff` shows that they are the same...
It doesn't solve the issue btw.
The else case allows rescaling the diagram to a fixed width. I included it here so that users wouldn't have to implement it in their document if they needed a particular diagram to fit in the page without restructuring it
The `else` case allows rescaling the diagram to a fixed width. I included it here so that users wouldn't have to implement it in their document if they needed a particular diagram to fit in the page without restructuring it
Ok, I was confused because in config.config you can specify width (and height), but it gets overwritten by the one in schema.render.
I've seen the TODO -> remove comments... we should remove that.
Ok, I was confused because in `config.config` you can specify `width` (and `height`), but it gets overwritten by the one in `schema.render`.
I've seen the `TODO -> remove` comments... we should remove that.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This makes the compiler crash:
I don't think it's CeTZ, because this works:
I've tested both Typst 0.13.1 and 0.14.0, and it gives the same result.
There are also issues in general with
scale,reflow, andfigurecaptions:If
reflowisfalse, the size is correct but the caption not. If it'strue, the reverse happens.Using
boxgives the correct result.I've been looking and... why do you have this logic in the renderer?
I've replaced that
if-elsewith justcnvs, compiled the examples as PNG, and doing adiffshows that they are the same...It doesn't solve the issue btw.
The
elsecase allows rescaling the diagram to a fixed width. I included it here so that users wouldn't have to implement it in their document if they needed a particular diagram to fit in the page without restructuring itOk, I was confused because in
config.configyou can specifywidth(andheight), but it gets overwritten by the one inschema.render.I've seen the
TODO -> removecomments... we should remove that.