Closed SillyFreak closed 6 months ago
Hi @SillyFreak ,
Yes this is kind of the intended behaviour. The example should not have a size that is dependent on the parent container because how would scaling then work? Do you have a use-case where you would want to have an example with a width that is a ratio in this scenario?
I basically stumbled upon it because I had a function returning a 100% width table and wanted to add an example; I wound up using #show: block.with(width: 15cm)
to give it a fixed width, but that code is for now also part of the example. I'd say failing on scale-preview == auto
is (apart from the error message) correct, but if the scale is given, shouldn't this be able to work? Maybe I'm missing a detail.
I see, mmh.
Well even for a fixed scale factor, a width of 100%
seems conceptionally a bit problematic.
No, I think we can make it work.
Here's a minimal example with three modules given as inline code:
The first module contains a
func-a
, and its documentation has an example. The width is2em
(plus some border) - no problem.However, the second module (commented out) has a rectangle with
width: 100%
. This leads to a division by zero, it seems:The third module circumvents this: the division only happens if
scale-preview == auto
, so I setscale-preview: 100%
. However, this seems to give the example content a "viewport" width of zero:width: preview-size.width * (scale-preview / 100%)
.So in total: examples can't have a width that is a ratio, as measuring that leads to either dividing by or multiplying with zero.