There is not always a Typst equivalent for every LaTeX macro. This document provides a guide on how to implement unsupported LaTeX macros in Typst.
\mathscr
macro\mathscr
#let scr(a) = text(
font: "STIX Two Math",
stylistic-set: 01,
)[#math.cal(a)]
$
y = scr(A) x
$
\LaTeX
and \TeX
macro\LaTeX
#let TeX = style(styles => {
set text(font: "New Computer Modern")
let e = measure("E", styles)
let T = "T"
let E = text(1em, baseline: e.height * 0.31, "E")
let X = "X"
box(T + h(-0.15em) + E + h(-0.125em) + X)
})
#let LaTeX = style(styles => {
set text(font: "New Computer Modern")
let a-size = 0.66em
let l = measure("L", styles)
let a = measure(text(a-size, "A"), styles)
let L = "L"
let A = box(scale(x: 105%, text(a-size, baseline: a.height - l.height, "A")))
box(L + h(-a.width * 0.67) + A + h(-a.width * 0.25) + TeX)
})
You can use #LaTeX in text environments.
You can use $#LaTeX$ in math environments as well.
\lfloor
, \rfloor
, \lceil
, and \rceil
macros
In Typst, there are floor
and ceil
functions to make the floor and ceiling symbols, respectively.
\lfloor x \rfloor
floor(x)
\lceil x \rceil
ceil(x)
However, you cannot use a separated left or right version of the symbols. e.g. There is no lfloor
function in Typst.
If you really need them, you may define them directly using their Unicode characters as the following:
#let lfloor = $⌊$;
#let rfloor = $⌋$;
#let lceil = $⌈$;
#let rceil = $⌉$;
$
y = lfloor x rceil
$
op
function to define custom operators
For example, if you want to define a custom operator \myopr
.
\newcommand{\myopr}{\operatorname{myopr}}
#let myopr = op("myopr");
$
y = myopr x
$
The following resources were used to create this document: