Home

Awesome

fletcher

Manual Version Development version Repo

fletcher (noun) a maker of arrows

A Typst package for drawing diagrams with arrows, built on top of CeTZ. See the manual for documentation.

#import "@preview/fletcher:0.5.2" as fletcher: diagram, node, edge
<picture> <source media="(prefers-color-scheme: dark)" srcset="docs/readme-examples/first-isomorphism-theorem-dark.svg"> <img src="docs/readme-examples/first-isomorphism-theorem-light.svg"> </picture>
#diagram(cell-size: 15mm, $
  G edge(f, ->) edge("d", pi, ->>) & im(f) \
  G slash ker(f) edge("ur", tilde(f), "hook-->")
$)
<picture> <source media="(prefers-color-scheme: dark)" srcset="docs/readme-examples/flowchart-trap-dark.svg"> <img src="docs/readme-examples/flowchart-trap-light.svg"> </picture>
// https://xkcd.com/1195/
#import fletcher.shapes: diamond
#set text(font: "Comic Neue", weight: 600)

#diagram(
  node-stroke: 1pt,
  edge-stroke: 1pt,
  node((0,0), [Start], corner-radius: 2pt, extrude: (0, 3)),
  edge("-|>"),
  node((0,1), align(center)[
    Hey, wait,\ this flowchart\ is a trap!
  ], shape: diamond),
  edge("d,r,u,l", "-|>", [Yes], label-pos: 0.1)
)
<picture> <source media="(prefers-color-scheme: dark)" srcset="docs/readme-examples/state-machine-dark.svg"> <img src="docs/readme-examples/state-machine-light.svg"> </picture>
#set text(10pt)
#diagram(
  node-stroke: .1em,
  node-fill: gradient.radial(blue.lighten(80%), blue, center: (30%, 20%), radius: 80%),
  spacing: 4em,
  edge((-1,0), "r", "-|>", `open(path)`, label-pos: 0, label-side: center),
  node((0,0), `reading`, radius: 2em),
  edge(`read()`, "-|>"),
  node((1,0), `eof`, radius: 2em),
  edge(`close()`, "-|>"),
  node((2,0), `closed`, radius: 2em, extrude: (-2.5, 0)),
  edge((0,0), (0,0), `read()`, "--|>", bend: 130deg),
  edge((0,0), (2,0), `close()`, "-|>", bend: -40deg),
)
<picture> <source media="(prefers-color-scheme: dark)" srcset="docs/readme-examples/feynman-diagram-dark.svg"> <img src="docs/readme-examples/feynman-diagram-light.svg"> </picture>
#diagram($
  e^- edge("rd", "-<|-") & & & edge("ld", "-|>-") e^+ \
  & edge(gamma, "wave") \
  e^+ edge("ru", "-|>-") & & & edge("lu", "-<|-") e^- \
$)

More examples

Pull requests are most welcome!

<table> <tr> <td style="background: white;"> <a href="docs/gallery/commutative.typ"> <center> <img src="docs/gallery/commutative.svg" width="100%"/> </center> </a> </td> <td style="background: white;"> <a href="docs/gallery/algebra-cube.typ"> <center> <img src="docs/gallery/algebra-cube.svg" width="100%"/> </center> </a> </td> </tr> <tr> <td style="background: white;"> <a href="docs/gallery/ml-architecture.typ"> <center> <img src="docs/gallery/ml-architecture.svg" width="100%"/> </center> </a> </td> <td style="background: white;"> <a href="docs/gallery/io-flowchart.typ"> <center> <img src="docs/gallery/io-flowchart.svg" width="100%"/> </center> </a> </td> </tr> <tr> <td style="background: white;"> <a href="docs/gallery/digraph.typ"> <center> <img src="docs/gallery/digraph.svg" width="100%"/> </center> </a> </td> <td style="background: white;"> <a href="docs/gallery/node-groups.typ"> <center> <img src="docs/gallery/node-groups.svg" width="100%"/> </center> </a> </td> </tr> <tr> <td style="background: white;"> <a href="docs/gallery/uml-diagram.typ"> <center> <img src="docs/gallery/uml-diagram.svg" width="100%"/> </center> </a> </td> </tr> </table>

Change log

0.5.2

0.5.1

0.5.0

0.4.5

0.4.4

0.4.3

0.4.2

0.4.1

0.4.0

0.3.0

0.2.0

Star History

<a href="https://star-history.com/#jollywatt/typst-fletcher&Date"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=jollywatt/typst-fletcher&type=Date&theme=dark" /> <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=jollywatt/typst-fletcher&type=Date" /> <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=jollywatt/typst-fletcher&type=Date" /> </picture> </a>