#place CeTZ in document

5 messages · Page 1 of 1 (latest)

crude sparrow
#

How can I place a CeTZ diagram so that it is resized to the page / margins automatically (similar to #image)?

#import "@preview/cetz:0.2.2"

#set page(
width: 138mm,
height: 215mm,
margin: (top: 22mm, bottom: 33mm, rest: 20mm),
)

#figure(caption: "A")[
#cetz.canvas({
import cetz.draw: *
circle((0,0), radius: 6)
})
]

coral sparrow
#

You can use the length parameter of canvas to set the canvas size relative to the page width:

#cetz.canvas(length: 100%, { ... /* 1 coordinate unit is the width of the page */ })

If you want smaller integer, use scale(...) to scale the coordinate system to your needs, e.g.: scale(1/10).

#

You can put your code between triple backticks in Discord to format it as such.

#

?r t=l

#import "@preview/cetz:0.2.2"
#set page(
  width: 138mm,
  height: 215mm,
  margin: (top: 22mm, bottom: 33mm, rest: 20mm),
)

#figure(caption: "A")[
    #cetz.canvas(length: 100%, {
      import cetz.draw: *
      scale(1/10)
      circle((0,0), radius: 5)
    })
  ]