Getting Started

This tutorial demonstrates the basic features of Typstry.jl and how to use them.

Strings

Print Julia values in Typst format using show with the text/typst MIME type. This formatting is also used to construct a TypstString.

julia> show(stdout, "text/typst", Typst(π))
$π$

julia> TypstString(π)
typst"$π$"

Formatting may be configured in show using an IOContext and in TypstString using keyword parameters.

julia> show(IOContext(stdout, :mode => code), "text/typst", Typst(π))
3.141592653589793

julia> TypstString(π; mode = code)
typst"3.141592653589793"

Use @typst_str to directly write Typst source text. This also supports formatted interpolation by calling the TypstString constructor.

julia> typst"$ \(pi; mode = math) approx \(pi; mode = code) $"
typst"$ π approx 3.141592653589793 $"

Commands

Easily generate a Typst source file and compile it into a document using render.

julia> render(Any[true 1; 1.2 1 // 2]);

Use the Typst command-line interface by running a TypstCommand created with its constructor or @typst_cmd.

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

julia> run(typst`compile input.typ output.pdf`);