I am trying to generalize the following process using global functions.
I try to match the math output in typst to that in the problem sets I am proving. Since all Matrices are uppercase and bold, all vectors are bold and all vector spaces are script I find myself writing a list of repeating code for every proof. I also do not want to add this to a global show rule, since a symbol in one proof might be a vector another and in the next just a scalar.
#proof()[
#show math.equation: eq => {
show "A": math.upright(math.bold($A$))
show "x": math.bold($x$)
show "b": math.bold($b$)
show "v": math.bold($v$)
show "L": $scr(L)$
eq
}
Can I write global function which works on an array of strings and automatically sets a specific show rule? I would call the function within a proof.
e.g. #matrix((“A”, “X”, “Y”)) or #vector((“x”, “y”, “z”))
#let proof-preset(body) = {
show math.equation: eq => {
show "A": math.upright(math.bold($A$))
show "x": math.bold($x$)
show "b": math.bold($b$)
show "v": math.bold($v$)
show "L": $scr(L)$
eq
}
body
}
Or are you looking for generalization for the conversion of the math characters?
Like so?
#let all-scr(strings: (), body) = {
show math.equation: body => strings.fold(body, (it, string) => {
show string: math.scr
it
})
body
}
#show: all-scr.with(strings: ("a", "X")) // only a and X, not b
$"a" "b" "X"$