cgahr
November 5, 2024, 3:16pm
1
I want to create a box around my figure that fits exactly the size of the figure since I want to visually check, how much of the available space my figure uses.
How would I do that?
#box(
stroke: black,
figure(...)
)
does not create a tight box…
#block(
figure(
box(
width: 200pt,
height: 200pt,
stroke: red
),
caption: lorem(2)
),
stroke: blue
)
Using block
here since box
is for inline objects. If you wish to apply this accross the document, use #show figure: block.with(stroke: black)
cgahr
November 6, 2024, 6:24am
3
sjfhsjfh:
#block(
figure(
box(
width: 200pt,
height: 200pt,
stroke: red
),
caption: lorem(2)
),
stroke: blue
)
Thank you! Sadly, for me this does not work for me. Upon using it, your example creates a box, but is shifted completely to the left, partially outside of the page.
Oh, sorry I forgot it, wrap it in align(center)
should fix this:
#align(center, block(
figure(
box(
width: 200pt,
height: 200pt,
stroke: red
),
caption: lorem(2)
),
stroke: blue
))
You may replace the box with the content you like, the box here is just for demonstration.
cgahr
November 8, 2024, 4:26pm
5
Sadly, this also doesn’t work for me. The blue box does not show, and the caption is wierdly formatted.
hi @cgahr which version of typst you are using? For my it works on typst 0.12; do you test it in clean file, or in your document?