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

ability to intigrate CeTZ diagrams with other Typst elements (like tikzmark) #607

Open maninalift opened 1 month ago

maninalift commented 1 month ago

TiKZ alllows for diagram elements to be integrated with other elements of the page layout through the overlay flag and \tikzmark function. \tikzmarks are essentially like CeTZ anchors, but they can be placed outside of diagrams. The overlaid diagram can then reference these marks. This allow for example placing marks in an equation in order to draw arrows between parts of an equation.

It has to be said that this solution, while good enough for most use cases does not cover every possible use. There are some cases where you may want the diagram to influence the layout of the text as well as the text influencing the layout of the diagram. For example draw an arrow between these two equations and have the text flow around the arrows. However I imagine that such a general layouting ability would not be possible, so I would love for CeTZ to have a feature like \tikzmark.

My apologies if this functionality already exists. I have not been able to find it.

johannes-wolf commented 1 month ago

This is currently not implemented but should be possible. The only thing missing from cetz is an option for elements to not increase the bounding box of the canvas, so that they can go outsides the canvas. Positions in the document can be located using #metadata("cetz-anchor") #label(<outside-label-name>) and must be resolved to cetz anchors either before using them, using some special function - or we build this directly into cetz, maybe by having some anchor name prefix for "outside" anchors.