Skip to content

Commit a95c829

Browse files
committed
Add some comments to math numbering
1 parent 6c31702 commit a95c829

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

src/snippets/math/numbering.md

+30-11
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,46 @@
1-
# Numbering
1+
# Math Numbering
22
## Number by current heading
33

44
> See also built-in numbering in [math package section](../../packages/math.md#theorems)
55
66
```typ
7-
/// author: laurmaedje
7+
/// original author: laurmaedje
88
#set heading(numbering: "1.")
99
1010
// reset counter at each chapter
11+
// if you want to change the number of displayed
12+
// section numbers, change the level there
1113
#show heading.where(level:1): it => {
1214
counter(math.equation).update(0)
1315
it
1416
}
1517
1618
#set math.equation(numbering: n => {
17-
let h1 = counter(heading).get().first()
18-
numbering("(1.1)", h1, n)
19+
numbering("(1.1)", counter(heading).get().first(), n)
20+
// if you want change the number of number of displayed
21+
// section numbers, modify it this way:
22+
/*
23+
let count = counter(heading).get()
24+
let h1 = count.first()
25+
let h2 = count.at(1, default: 0)
26+
numbering("(1.1.1)", h1, h2, n)
27+
*/
1928
})
2029
30+
2131
= Section
2232
== Subsection
2333
24-
$ 5 + 3 = 8 $
34+
$ 5 + 3 = 8 $ <a>
2535
$ 5 + 3 = 8 $
2636
2737
= New Section
2838
== Subsection
2939
$ 5 + 3 = 8 $
3040
== Subsection
31-
$ 5 + 3 = 8 $
41+
$ 5 + 3 = 8 $ <b>
42+
43+
Mentioning @a and @b.
3244
```
3345

3446
## Number only labeled equations
@@ -38,7 +50,10 @@ $ 5 + 3 = 8 $
3850
#show math.equation:it => {
3951
if it.fields().keys().contains("label"){
4052
math.equation(block: true, numbering: "(1)", it)
41-
// change your numbering style in `numbering`
53+
// Don't forget to change your numbering style in `numbering`
54+
// to the one you actually want to use.
55+
//
56+
// Note that you don't need to #set the numbering now.
4257
} else {
4358
it
4459
}
@@ -54,8 +69,10 @@ $ dif/(dif x)(A(t)+B(x))=dif/(dif x)A(t)+dif/(dif x)B(t) $ <ep-3>
5469
```typ
5570
// author: gijsleb
5671
#show math.equation:it => {
57-
if it.has("label"){
58-
math.equation(block:true, numbering: "(1)", it)
72+
if it.has("label") {
73+
// Don't forget to change your numbering style in `numbering`
74+
// to the one you actually want to use.
75+
math.equation(block: true, numbering: "(1)", it)
5976
} else {
6077
it
6178
}
@@ -65,6 +82,8 @@ $ dif/(dif x)(A(t)+B(x))=dif/(dif x)A(t)+dif/(dif x)B(t) $ <ep-3>
6582
let el = it.element
6683
if el != none and el.func() == math.equation {
6784
link(el.location(), numbering(
85+
// don't forget to change the numbering according to the one
86+
// you are actually using (e.g. section numbering)
6887
"(1)",
6988
counter(math.equation).at(el.location()).at(0) + 1
7089
))
@@ -73,9 +92,9 @@ $ dif/(dif x)(A(t)+B(x))=dif/(dif x)A(t)+dif/(dif x)B(t) $ <ep-3>
7392
}
7493
}
7594
76-
$ sum_x^2 $
95+
$ sum_x^2 $
7796
$ dif/(dif x)(A(t)+B(x))=dif/(dif x)A(t)+dif/(dif x)B(t) $ <ep-2>
78-
$ sum_x^2 $
97+
$ sum_x^2 $
7998
$ dif/(dif x)(A(t)+B(x))=dif/(dif x)A(t)+dif/(dif x)B(t) $ <ep-3>
8099
In @ep-2 and @ep-3 we see equations
81100
```

0 commit comments

Comments
 (0)