Compare commits

...

2 Commits

Author SHA1 Message Date
orca 15786007fc
Code refactoring. 2024-02-01 02:13:56 +01:00
orca 23d963609c
Imporved modularity of math-block. 2024-02-01 01:04:30 +01:00
1 changed files with 11 additions and 11 deletions

View File

@ -3,6 +3,9 @@
// We need the name of our environments.
#import "constants.typ": *
/* Hides a command in text. */
#let hide-cmd(cmd) = [#place(right, cmd)]
/* Emphasize a block by placing it in a decorated rectangle. */
#let block-emph(body, way: "") = {
let outset = 5pt
@ -25,20 +28,17 @@
/* The `name` named variable allows us to give a name to be displayed instead of the numbers. */
#let math-block(body, name: "", id: "", emphasis: "bold", decoration: "fill") = {
let current-counter = counter(id)
let cmd = current-counter.step()
let name = if name == "" {
current-counter.step()
counter(heading).display() + current-counter.display()
} else {
"(" + name + ")"
}
let number = counter(heading).display() + current-counter.display()
let name = if name == "" { [] } else { [ (#name)] }
if emphasis == "bold" {
block-emph(way: decoration)[*#id #name.* #body]
return if emphasis == "bold" {
block-emph(way: decoration)[#hide-cmd(cmd)*#id #number#name.* #body]
} else if emphasis == "italics" {
block-emph(way: decoration)[_#id #name._ #body]
block-emph(way: decoration)[#hide-cmd(cmd)_#id #number#name._ #body]
} else {
block-emph(way: decoration)[#id #name. #body]
block-emph(way: decoration)[#hide-cmd(cmd)#id #number#name. #body]
}
}
@ -68,6 +68,6 @@
math.equation(numbering: numbering-equation, block: true)[#body]
} else {
let cmd = counter(math.equation).update(n => calc.max(0, n - 1))
math.equation(numbering: it => "(" + name + ")", block: true)[#body#place(right, cmd)]
math.equation(numbering: it => "(" + name + ")", block: true)[#body#hide-cmd(cmd)]
}
}