Replies: 4 comments
-
Is this answered in #689? Using Typst'
|
Beta Was this translation helpful? Give feedback.
-
I think you just hardcoded the size of the container in that Using Adding |
Beta Was this translation helpful? Give feedback.
-
Ah, it's the Here's what I now have: #let diagram(canvas) = {
context {
let canvas-size = measure(canvas)
[canvas width=#canvas-size.width]
layout(size => {
[parent width=#size.width]
scale(origin: left, size.width/canvas-size.width * 100%, canvas)
})
}
}
#diagram(cetz.canvas(
{
import cetz.draw: *
content((-5,0), [left])
content((5,0), [right])
}
)) The remaining annoyances are that just simple |
Beta Was this translation helpful? Give feedback.
-
You can also try the first option (without |
Beta Was this translation helpful? Give feedback.
-
If I've understood correctly, cetz canvas "interior coordinate" bounds are always the bounds of whatever is drawn there, and setting a unit value for the canvas
length
argument sets the physical on-page size of whatever1
means inside the canvas; actual size comes indirectly from multiplying this unit size bylength
.To get a fixed size out of cetz, it seems I need to say
length: 100%/canvas_interior_width
. And I can't seem to be able to figure out the canvas interior width programmatically -- my leftmost and rightmost content are text labels, and I don't directly control their size!Trying to pull of some measure-then-rescale trick with
#layout(size => let m = measure(my-canvas))
leads tocannot expand into infinite width
error from cetz canvas.This makes it incredibly hard to consistently set diagrams to be e.g. 80% of the column width.
Is there any way to make this better?
Beta Was this translation helpful? Give feedback.
All reactions