Typstry.jl

Introduction

Typstry.jl is the interface to convert the computational power of Julia into beautifully formatted Typst documents.

What is Typst?

Typst is an open-source and relatively new typesetting system (written in Rust 🦀🚀), designed to improve upon the performance and usability of LaTeX. See also the Typst repository and documentation for examples and how to get started.

Installation

julia> using Pkg: add

julia> add("Typstry")

julia> using Typstry

Showcase

julia> show(stdout, "text/typst", Typst([1 // 2 1; 1.0 [Any[1 // 2 1; 1.0 nothing]]]))
$mat(
  1 / 2, 1;
  1.0, mat(
    1 / 2, 1;
    1.0, #none
  )
)$

julia> TypstString(1 // 2; block = true)
typst"$ 1 / 2 $"

julia> typst"$ 1 / \(1 + 2im; mode = math) $"
typst"$ 1 / (1 + 2i) $"

julia> TypstCommand(["help"])
typst`help`

julia> typst`compile input.typ output.pdf`
typst`compile input.typ output.pdf`

julia> render(1:4)

Features

Strings

  • Print Julia values in Typst format
    • Specify Julia settings and Typst parameters
    • Implement formatting for custom types
  • Construct Typst strings
    • Interpolate formatted values

Commands

  • Construct Typst commands
  • Render documents using the Typst compiler
    • Display in IJulia.jl, Pluto.jl, and QuartoRunner.jl notebooks
    • Use the JuliaMono typeface

Planned

  • Default auto::Mode?
    • Automatically determine the Typst syntactic context
    • Use a jll package
  • Implement Typst formatting for more types
    • Base
      • AbstractDict
      • AbstractIrrational
      • AbstractSet
      • Enum
        • Mode
      • Expr
      • Symbol
    • Package extensions
      • Standard Library
        • LinearAlgebra.jl
        • DataFrames.jl
    • Partial Julia to Typst transpilation
      • (@typst $a * b) ==
        TypstString(:($a * b)) ==
        TypstString(TypstFunction(*, a, :b)) ==
        typst"$ 2b $"

Similar Packages

Typst

Typst and LaTeX

LaTeX