summaryrefslogtreecommitdiff
path: root/tests/typ/meta/figure.typ
blob: 3537bbe14ba700f8a7379032e2e21e0a0b8b3733 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Test figures.

---
#set page(width: 150pt)
#set figure(numbering: "I")

We can clearly see that @fig-cylinder and
@tab-complex are relevant in this context.

#figure(
  table(columns: 2)[a][b],
  caption: [The basic table.],
) <tab-basic>

#figure(
  pad(y: -11pt, image("/cylinder.svg", height: 3cm)),
  caption: [The basic shapes.],
  numbering: "I",
) <fig-cylinder>

#figure(
  table(columns: 3)[a][b][c][d][e][f],
  caption: [The complex table.],
) <tab-complex>

---

// Testing figures with and without caption
#figure(
  table(
    columns: 2,
    [First cylinder],
    image("/cylinder.svg", height: 3cm),
  )
) <fig-image-in-table-no-caption>

#figure(
  table(
    columns: 2,
    [Second cylinder],
    image("/cylinder.svg", height: 3cm),
  ),
  caption: "A table containing images."
) <fig-image-in-table>

---

// Testing show rules with figures with a simple theorem display
#show figure.where(kind: "theorem"): it => {
  let name = none
  if not it.caption == none {
    name = [ #emph(it.caption)]
  } else {
    name = []
  }

  let title = none
  if not it.numbering == none {
    title = it.supplement
    if not it.numbering == none {
      title += " " +  it.counter.display(it.numbering)
    }
  }
  title = strong(title)
  pad(
    top: 0em, bottom: 0em,
    block(
      fill: green.lighten(90%),
      stroke: 1pt + green,
      inset: 10pt,
      width: 100%,
      radius: 5pt,
      breakable: false,
      [#title#name#h(0.1em):#h(0.2em)#it.body#v(0.5em)]
    )
  )
}

#figure(
  $a^2 + b^2 = c^2$,
  supplement: "Theorem",
  kind: "theorem",
  caption: "Pythagoras' theorem.",
  numbering: "1",
) <fig-formula>

#figure(
  $a^2 + b^2 = c^2$,
  supplement: "Theorem",
  kind: "theorem",
  caption: "Another Pythagoras' theorem.",
  numbering: none,
) <fig-formula>

#figure(
  caption: [Hello world in #emph[rust].],
)[
  #show raw: set align(left)
  ```rust
  fn main() {
    println!("Hello, world!");
  }
  ```
]