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
846 stars 35 forks source link

Allow Outputting Anchors for Tree Nodes #700

Open johannes-wolf opened 1 week ago

johannes-wolf commented 1 week ago

Discussed in https://github.com/cetz-package/cetz/discussions/698

Originally posted by **noahjutz** September 23, 2024 Is it possible to refer to a tree's node's position from outside of a tree? When I try ``` cetz.tree.tree( // ... draw-node: (node, p) => { if node.content.text == "1" {circle((), radius: 0, name: "anchor_1")} else if node.content.text == "2" {circle((), radius: 0, name: "anchor_2")} } ) line("anchor_1", "anchor_2") ``` I get `Assertion failed: Unknown element 'anchor_1' in elements ()`. Motivation: I want to draw arrows between sibling nodes in a tree.
johannes-wolf commented 1 week ago

Forward anchors from the draw-node function to the tree group.