Hi! I started learning Typst yesterday and I’m currently in the process of translating some LaTeX code to Typst and was wondering how I can elegantly (and typographically beautiful) write type inference (i.e. natural deduction, gentzen, sequent calculus) diagrams.
In LaTeX I use
\begin{mathpar}
\inferrule*[right=Var]
{x : \tau \in \Gamma}
{\Gamma \vdash x : \tau}
\inferrule*[right=Abs]
{\Gamma, x : \tau_1 \vdash e : \tau_2}
{\Gamma \vdash \lambda x : \tau_1.\ e : \tau_1 \to \tau_2}
\inferrule*[right=App]
{\Gamma \vdash e_1 : \tau_1 \to \tau_2 \\
\Gamma \vdash e_2 : \tau_1}
{\Gamma \vdash e_1\ e_2 : \tau_2}
\end{mathpar}
Which results in the following:
In Typst the only thing I could come up with is using stacks (or grids) to manually align curryst prooftrees (which is a bit overkill for these diagrams I think):
#align(center, stack(dir: ttb, spacing: 2em, stack(dir: ltr, spacing: 15%,
proof-tree(
rule(
name: smallcaps("Var"),
$Gamma tack x : tau$,
$x : tau in Gamma$
)
),
proof-tree(
rule(
name: smallcaps("Abs"),
$Gamma tack lambda x : tau_1.e : tau_1 arrow tau_2$,
$Gamma, x : tau_1 tack e : tau_2$
)
)
),
proof-tree(
rule(
name: smallcaps("App"),
$Gamma tack e_1 " " e_2 : tau_2$,
$Gamma tack e_1 : tau_1 arrow tau_2$,
$Gamma tack e_2 : tau_1$
)
)
))
I particularly don’t like how I have to manually adjust the spacing (compared to mathpar), especially if I had a lot more than three diagrams.
Is there any better way to do this? Is there something similar “magical” to mathpar
in Typst?