Fletcher (noun) a maker of arrows
A Typst package for drawing diagrams with arrows, built on top of CeTZ.
#import "@preview/fletcher:0.4.0" as fletcher: node, edge
#fletcher.diagram(cell-size: 15mm, $
G edge(f, ->) edge("d", pi, ->>) & im(f) \
G slash ker(f) edge("ur", tilde(f), "hook-->")
$)
#fletcher.diagram(
node-fill: rgb("aafa"),
node-outset: 2pt,
axes: (ltr, btt),
node((0,0), `typst`),
node((1,0), "A"),
node((2.5,0), "B", stroke: c + 2pt),
node((2,1), "C", extrude: (+1, -1)),
for i in range(3) {
edge((0,0), (1,0), bend: (i - 1)*25deg)
},
edge((1,0), (2,1), "..}>", corner: right),
edge((1,0), (2.5,0), "-||-|>", bend: -0deg),
),
Todo
- [x] Mathematical arrow styles
- [x] Also allow
&-delimited equations for specifying nodes - [ ] Support CeTZ arrowheads
- [ ] Support arbitrary node shapes drawn with CeTZ
- [ ] Allow referring to node coordinates by their content?
- [ ] Support loops connecting a node to itself
- [x] More ergonomic syntax to avoid repeating coordinates?
Change log
0.4.0
- Add ability to specify diagrams in math-mode, using
&to separate nodes. - Allow implicit and relative edge coordinates, e.g.,
edge("d")becomesedge(prev-node, (0, 1)). - Add ability to place marks anywhere along an edge. Shorthands now accept an optional middle mark, for example
|->-|andhook-/->>. - Add “hanging tail” correction to marks on curved edges. Marks now rotate a bit to fit more comfortably along tightly curving arcs.
- Add more arrowheads for the sake of it:
}>,<{,/,\,x,X,*(solid dot),@(solid circle). - Add
axesoption todiagram()to control the direction of each axis in the diagram’s coordinate system. - Add
width,heightandradiusoptions tonode()for explicit control over size. - Add
corner-radiusoption tonode(). - Add
strokeoption toedge()replacingthicknessandpaintoptions. - Add
edge-strokeoption todiagram()replacingedge-thickness.
0.3.0
- Make round-style arrow heads better approximate the default math font.
- Add solid arrow heads with shorthand
<|-,-|>and double-bar||-,-||. - Add an
extrudeoption tonode()which duplicates and extrudes the node’s stroke, enabling double stroke effects.
0.2.0
- Experimental support for customising arrowheads.
- Add right-angled edges with
edge(..., corner: left/right).