a

alchemist

@preview

A package to render skeletal formulas using CeTZ

v0.2.0
MIT
1 downloads

Package Information

Last Updated
Minimum Typst Version
0.14.0
Categories
visualizationpaper
Disciplines
educationchemistrybiology

1. Get the package

Download the package using the TPIX CLI:

tpix get @preview/alchemist:0.2.0

2. Import in your Typst file

Add this to your .typ file:

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

Version History

0.2.00.14.0
ea87d7e4f13a...
0.1.90.13.1
641e05b6058d...
0.1.80.13.1
4fd837452202...
0.1.70.13.1
0ce75f98bd02...
0.1.60.13.1
5bcd433a4c78...
0.1.50.13.1
d5c1da996027...
0.1.40.11.0
501a72a77c0b...
0.1.30.11.0
a8cbcc179675...
0.1.20.11.0
84c44bba07a6...
0.1.100.13.1
7c7559805ec1...
0.1.10.11.0
919918baeb89...
0.1.00.11.0
286c754ab7c1...

Typst Package
MIT License
User Manual

alchemist

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({
  fragment(name: "A", "A")
  single()
  fragment("B")
  branch({
    single(angle: 1)
    fragment(
      "W",
      links: (
        "A": double(stroke: red),
      ),
    )
    single()
    fragment(name: "X", "X")
  })
  branch({
    single(angle: -1)
    fragment("Y")
    single()
    fragment(
      name: "Z",
      "Z",
      links: (
        "X": single(stroke: black + 3pt),
      ),
    )
  })
  single()
  fragment(
    "C",
    links: (
      "X": cram-filled-left(fill: blue),
      "Z": single(),
    ),
  )
})

example image of a molecule

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")
  fragment("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: ">"),
  )
})

example of a cetz integration

Usage

To start using alchemist, just use the following code:

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

#skeletize({
  // Your molecule here
})

For more information, check the manual.

Tests

The test suite is managed with tytanic.

Changelog

0.2.0

  • Updated cetz to version 0.5.2
  • Updated to compiler 0.14.0
  • Rename plus link to plus-link to avoid confusion with the plus typst symbol
  • Adds a way to specify stoke of individual lines in double and triple links #31
  • Fix bugs with touying bindings and hide function
  • Fix a bounding box compute issue #32
  • It is now allowed to draw empty fragments. This is useful to carbocations/carboanions or add charges without drawing the carbon atom.
  • Remove the molecule alias for fragment

0.1.10

  • Added touying bindings in lib.typ to support automatic integration
  • Added a way to ignore charges in the links connection of a fragment with the ignore-charge parameter
  • Fix #27
  • Fix #23

0.1.9

  • Updated cetz to version 0.4.2
  • Exposed name in lib.typ to be used by other packages
  • Adds a touying support

0.1.8

  • Fixed bugs introduced in 0.1.7

0.1.7

  • Updated cetz to version 0.4.1
  • Added default values for color and font for fragment elements
  • Added a skeletize-config function to create a skeletize function with a specific configuration
  • Fixed a bug with cetz anchors not being correctly translated
  • Added an over argument to links to allow hiding overlapped links

0.1.6

  • Fixed the parenthesis height to work with the new typst version
  • Renamed molecule into fragment
  • Added support for charges and apostrophes in the string of a molecule
  • Fixed the parenthesis auto positioning and alignment
  • Added a new operator element and a new parameter in parenthesis to write resonance formulae

0.1.5

  • Update to compiler 0.13.1 and Cetz 0.3.4

0.1.4

  • Added the possibility to create Lewis formulae
  • Added parenthesis element to create groups and polymer

0.1.3

  • Added the possibility to add exponent in the string of a molecule.

0.1.2

  • Added default values for link style properties.
  • Updated cetz to version 0.3.1.
  • Added a tip-length 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