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
733 stars 34 forks source link

Point (a.k.a. coordinate) support #585

Closed arkadiuszwojcik closed 1 month ago

arkadiuszwojcik commented 1 month ago

In TikZ I offten use \coordinate to define named point that I use as origin for placement of other shapes relatve to that point. Point have no graphical representation, just origin coordinates and name label so it can be reffered by name in other places. I can't see anything similar in CeTZ, (circle with radious 0 would be close to it), hope I didn't miss something. Is it possible to implment such feature? The same can be achieved by stroing coordinates in variables but somhow point object feels better.

fenjalien commented 1 month ago

No CeTZ doesn't have a direct parallel at the moment. The closest thing is the anchor function but that can only be used inside a group, for reasons I can't remember right now. We might've looked into allowing outside of groups but I don't recall.

I think the main reason we haven't added one sooner is because its much easier to define variables in Typst than it is in Latex. So:

let coord = (3, 4)
circle(coord)

Are there any other benefits \coordinate gives over this?

johannes-wolf commented 1 month ago

Anchor is an alternative (in the current scope), but we currently do not allow placing anchors in the root scope; maybe we should @fenjalien?