#Cetz: set default scale and font size

5 messages · Page 1 of 1 (latest)

silk prawn
#

Hi all!
At the moment, every cetz picture I create looks like this:

#figure()[ #set text(size: 20pt) #canvas(length: 1cm, { draw.scale(2) draw.set-style(mark: (fill: black)) draw.rect((0,0), (2,1.5), name: "rect1") draw.line((rel: (-1,0), to: "rect1.left"), "rect1.left", mark: (end: ">"), name: "line1") draw.line("rect1.right", (rel: (1,0), to: "rect1.right"), mark: (end: ">"), name: "line2") draw.content("rect1.center", $G(s)$) draw.content((rel: (-0.25,0), to: "line1.left"), $I(s)$, anchor: "right") draw.content((rel: (0.25,0), to: "line2.right"), $U(s)$, anchor: "left") }) ]

Is it a way to set default text size, black fill and scale for all the pictures? Thanks a lot!

orchid pulsar
#

You could wrap it all in a function

#

something like this

#let cetz-picture(body) = {
  figure({
    set text(size: 20pt)
    canvas({
      draw.scale(2)
      draw.set-style(mark: (fill: black))
      ..body
    })
  })
}
#

then treat cetz-picture as canvas

#
#cetz-picture({
    draw.rect((0,0), (2,1.5), name: "rect1")
    draw.line((rel: (-1,0), to: "rect1.left"), "rect1.left", mark: (end: ">"), name: "line1")
    draw.line("rect1.right", (rel: (1,0), to: "rect1.right"), mark: (end: ">"), name: "line2")
    draw.content("rect1.center", $G(s)$)
    draw.content((rel: (-0.25,0), to: "line1.left"), $I(s)$, anchor: "right")
    draw.content((rel: (0.25,0), to: "line2.right"), $U(s)$, anchor: "left")
})