cetz-package / cetz

CeTZ: ein Typst Zeichenpaket - A library for drawing stuff with Typst.
https://cetz-package.github.io
GNU Lesser General Public License v3.0
819 stars 35 forks source link

Padding for content() blocks #53

Closed samuzora closed 1 year ago

samuzora commented 1 year ago

Hi! Given that the more common use case for content blocks is labelling, a default padding for content blocks would make sense, so as to prevent the content block from overlapping the shape itself (example previews below)

In the default position content("arc.right", [$l$], anchor: "left"), the $l$ is too close to the arc.

Here, I adjusted it with content((rel: (0.5em, 0), to: "arc.right"), [$l$], anchor: "left") and it looks great.

A padding would make the anchors of the label a sufficient distance away from the text itself.

I think a syntax like content(..., padding: <boolean or length>) would make sense, with the default padding being 0.5em.

If it sounds fine, I'm open to making a PR to add it.

Thanks! 😄

fenjalien commented 1 year ago

I don't see why not although this could be easily resolved by wrapping the content in a box with padding...

johannes-wolf commented 1 year ago

I think this is useful to have. But should we make the default padding configurable? A default padding could be a bit unexpected. Tikz has none, I think.

samuzora commented 1 year ago

I don't see why not although this could be easily resolved by wrapping the content in a box with padding...

True, it's just a shorthand for a common use case :)

I think this is useful to have. But should we make the default padding configurable? A default padding could be a bit unexpected. Tikz has none, I think.

Oh sure, I can see why it might break some stuff.

I could move it to ctx, and set via padding(length: 0em).

johannes-wolf commented 1 year ago

@samuzora Sounds good to me! I wrote a comment on PR for one small change. :-)

johannes-wolf commented 1 year ago

Merged.