Compare commits
2 Commits
0adad39a50
...
9f53c7a857
Author | SHA1 | Date |
---|---|---|
orca | 9f53c7a857 | |
orca | a46fb0c26f |
|
@ -1,6 +1,6 @@
|
|||
# math-typst
|
||||
|
||||
A mathematical-oriented template for Typst.
|
||||
A mathematical-oriented template and work environment for Typst.
|
||||
|
||||
## How to use
|
||||
|
||||
|
|
|
@ -85,3 +85,5 @@
|
|||
#example[
|
||||
#lorem(30)
|
||||
]
|
||||
|
||||
#lorem(10)
|
||||
|
|
|
@ -8,15 +8,15 @@
|
|||
#let lang = "fr"
|
||||
|
||||
/* Environments name. */
|
||||
#let outline-title = [Table des matières]
|
||||
#let abstract-title = "Résumé"
|
||||
#let outline-title = [Table des matières]
|
||||
#let abstract-title = "Résumé"
|
||||
|
||||
#let proposition-text = "Propostition"
|
||||
#let lemma-text = "Lemme"
|
||||
#let theorem-text = "Théorème"
|
||||
#let corollary-text = "Corollaire"
|
||||
#let proposition-id = "Propostition"
|
||||
#let lemma-id = "Lemme"
|
||||
#let theorem-id = "Théorème"
|
||||
#let corollary-id = "Corollaire"
|
||||
|
||||
#let definition-text = "Définition"
|
||||
#let remark-text = "Remarque"
|
||||
#let example-text = "Exemple"
|
||||
#let proof-text = "Démonstration"
|
||||
#let definition-id = "Définition"
|
||||
#let remark-id = "Remarque"
|
||||
#let example-id = "Exemple"
|
||||
#let proof-id = "Démonstration"
|
||||
|
|
|
@ -5,10 +5,18 @@
|
|||
|
||||
/* Emphasize a block by placing it in a decorated rectangle. */
|
||||
#let block-emph(body, way: "") = {
|
||||
let outset = 5pt
|
||||
let ash(n) = rgb(0, 0, 0, n)
|
||||
set rect(width: 100%, radius: 1pt, outset: outset)
|
||||
|
||||
if way == "fill" {
|
||||
rect(fill: rgb(0, 0, 0, 10), width: 100%, radius: 1pt)[#body]
|
||||
v(outset)
|
||||
rect(fill: ash(10))[#body]
|
||||
v(outset)
|
||||
} else if way == "outline" {
|
||||
rect(stroke: rgb(0, 0, 0, 18) + 4pt, width: 100%, radius: 1pt)[#body]
|
||||
v(outset)
|
||||
rect(stroke: ash(18) + 5pt)[#body]
|
||||
v(outset)
|
||||
} else {
|
||||
[#body]
|
||||
}
|
||||
|
@ -16,7 +24,6 @@
|
|||
|
||||
/* 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") = {
|
||||
/* We create a counter to be able to index the environment. */
|
||||
let current-counter = counter(id)
|
||||
|
||||
let name = if name == "" {
|
||||
|
@ -35,20 +42,22 @@
|
|||
}
|
||||
}
|
||||
|
||||
#let v-space = v(0.5em)
|
||||
|
||||
// Functions we will directly use.
|
||||
#let proposition(body, name: "") = math-block(name: name, id: proposition-text, body)
|
||||
#let lemma(body, name: "") = math-block(name: name, id: lemma-text, body)
|
||||
#let theorem(body, name: "") = math-block(name: name, id: theorem-text, body)
|
||||
#let corollary(body, name: "") = math-block(name: name, id: corollary-text, body)
|
||||
#let proposition(body, name: "") = math-block(name: name, id: proposition-id, body)
|
||||
#let lemma(body, name: "") = math-block(name: name, id: lemma-id, body)
|
||||
#let theorem(body, name: "") = math-block(name: name, id: theorem-id, body)
|
||||
#let corollary(body, name: "") = math-block(name: name, id: corollary-id, body)
|
||||
|
||||
#let remark(body, name: "") = math-block(name: name, id: remark-text, decoration: "none", body + v(0.5em))
|
||||
#let example(body, name: "") = math-block(name: name, id: example-text, decoration: "none", body + v(0.5em))
|
||||
#let remark(body, name: "") = math-block(name: name, id: remark-id, decoration: "none", body + v-space)
|
||||
#let example(body, name: "") = math-block(name: name, id: example-id, decoration: "none", body + v-space)
|
||||
|
||||
#let definition(body, name: "") = math-block(name: name, id: definition-text, decoration: "outline", emphasis: "italics", body)
|
||||
#let definition(body, name: "") = math-block(name: name, id: definition-id, decoration: "outline", emphasis: "italics", body)
|
||||
|
||||
/* It takes the body of the proof, and formats it by adding the QED
|
||||
symbol at the end, and the _#proof-text._ text at the front. */
|
||||
#let proof(body) = [_#proof-text._ #body #h(1fr) #qed ]
|
||||
symbol at the end, and the _#proof-id._ text at the front. */
|
||||
#let proof(body) = [_#proof-id._ #body #h(1fr) #qed#v-space]
|
||||
|
||||
/* Number the equations starting with the heading hierarchy before them.
|
||||
E.g. if we are looking at the 6th equation in the 4th subheading
|
||||
|
@ -58,8 +67,7 @@
|
|||
if name == "" {
|
||||
math.equation(numbering: numbering-equation, block: true)[#body]
|
||||
} else {
|
||||
// Hacky.
|
||||
let cmd = counter(math.equation).update(n => calc.max(0, n - 1))
|
||||
math.equation(numbering: it => "(" + name + ")", block: true)[#body#place(left, cmd)]
|
||||
math.equation(numbering: it => "(" + name + ")", block: true)[#body#place(right, cmd)]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
set heading(numbering: "1.")
|
||||
|
||||
/* Mathematics. */
|
||||
show sym.lt.eq: $lt.eq.slant$
|
||||
show sym.gt.eq: $gt.eq.slant$
|
||||
|
||||
set math.mat(delim: "[", row-gap: 0.65em, column-gap: 1em)
|
||||
set math.vec(delim: "[", gap: 0.65em)
|
||||
|
||||
|
|
Loading…
Reference in New Issue