I am trying to put all my style and ctheorem
customisations in a separate template file. I want to call a single #show all
in my document. The code below works, except that I can’t seem to call two functions within #all()
that both take and return #doc
. As per my comments within the code, the theorems are formatting perfectly, but the styles are not applying. I am new and don’t (yet) properly understand how Typst is processing everything. Also, if I call styles first and then theorems, styles work but theorems get a bit messed up. So, I infer that you can’t do work on #doc
twice like this. Is there another way to keep styles and theorems separate in the template and call them both together from a single function?
So, my document starts like this and then gets straight into the content. Nice.
#import "template.typ": *
#show: all
The template starts like this currently.
#import "@preview/ctheorems:1.1.2": *
#let styles(doc) = [
#set page(margin: 2cm)
#set par(justify: true)
#set heading(numbering: "1.1")
#doc
]
#let theorems(doc) = [
#show: thmrules
#doc
]
#let all(doc) = [
//#show: thmrules // WHEN SET DIRECTLY HERE, THE STYLES() WORK
#theorems(doc) // WHEN SET IN THIS FUNCTION, THE STYLES() DON'T WORK
#styles(doc)
#doc
]
#let theorem = thmbox(
"theorem",
"Theorem",
base_level: 1,
namefmt: name => strong(sym.paren.l + name + sym.paren.r),
bodyfmt: body => emph(body),
separator: strong("."),
inset: 8pt,
radius: 4pt,
fill: rgb("#BBDEFB")
)