Universe

Alchemist is a typst package to draw skeletal formulae. It is based on the chemfig package. The main goal of alchemist is not to reproduce one-to-one chemfig. Instead, it aims to provide an interface to achieve the same results in Typst.

#skeletize({
  molecule(name: "A", "A")
  single()
  molecule("B")
  branch({
    single(angle: 1)
    molecule(
      "W",
      links: (
        "A": double(stroke: red),
      ),
    )
    single()
    molecule(name: "X", "X")
  })
  branch({
    single(angle: -1)
    molecule("Y")
    single()
    molecule(
      name: "Z",
      "Z",
      links: (
        "X": single(stroke: black + 3pt),
      ),
    )
  })
  single()
  molecule(
    "C",
    links: (
      "X": cram-filled-left(fill: blue),
      "Z": single(),
    ),
  )
})

links

Alchemist uses cetz to draw the molecules. This means that you can draw cetz shapes in the same canvas as the molecules. Like this:

#skeletize({
  import cetz.draw: *
  double(absolute: 30deg, name: "l1")
  single(absolute: -30deg, name: "l2")
  molecule("X", name: "X")
  hobby(
    "l1.50%",
    ("l1.start", 0.5, 90deg, "l1.end"),
    "l1.start",
    stroke: (paint: red, dash: "dashed"),
    mark: (end: ">"),
  )
  hobby(
    (to: "X.north", rel: (0, 1pt)),
    ("l2.end", 0.4, -90deg, "l2.start"),
    "l2.50%",
    mark: (end: ">"),
  )
})

cetz

Usage

To start using alchemist, just use the following code:

#import "@preview/alchemist:0.1.2": *

#skeletize({
  // Your molecule here
})

For more information, check the manual.

Changelog

0.1.2

  • Added default values for link style properties.
  • Updated cetz to version 0.3.1.
  • Added a tip-lenght argument to dashed cram links.

0.1.1

  • Exposed the draw-skeleton function. This allows to draw in a cetz canvas directly.
  • Fixed multiples bugs that causes overdraws of links.

0.1.0

  • Initial release