diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-05-22 20:50:15 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-05-22 20:56:30 +0200 |
| commit | f4fd6855e7fb833a2125d2e81aa3b9f548b18170 (patch) | |
| tree | 6e3675ca8c4b9f9fae05a598e753e3a410d2cce2 /tests | |
| parent | 183997d5fe76cf0b41fd26bfa29d166071d239eb (diff) | |
Fix and simplify reference supplements
- Fixes #873 by properly handling `none` supplement for`ref`.
- Fixes #523 by adding a `supplement` parameter to `math.equation`
- In the future, we can remove supplement functions in favor of show-set rules with fine-grained selectors. Currently, this is not possible because show-set + synthesis doesn't play well together
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ref/meta/ref.png | bin | 137626 -> 39979 bytes | |||
| -rw-r--r-- | tests/typ/meta/ref.typ | 100 |
2 files changed, 13 insertions, 87 deletions
diff --git a/tests/ref/meta/ref.png b/tests/ref/meta/ref.png Binary files differindex c904fc99..d3896948 100644 --- a/tests/ref/meta/ref.png +++ b/tests/ref/meta/ref.png diff --git a/tests/typ/meta/ref.typ b/tests/typ/meta/ref.typ index 2bed2125..a62e6cce 100644 --- a/tests/typ/meta/ref.typ +++ b/tests/typ/meta/ref.typ @@ -21,102 +21,28 @@ As seen in @intro, we proceed. @foo --- +#set heading(numbering: "1.", supplement: [Chapter]) +#set math.equation(numbering: "(1)", supplement: [Eq.]) -#show ref: it => { - if it.element != none and it.element.func() == figure { - let element = it.element - "[" - element.supplement - "-" - str(element.counter.at(element.location()).at(0)) - "]" - // it - } else { - it - } -} - += Intro #figure( - image("/cylinder.svg", height: 3cm), - caption: [A sylinder.], + image("/cylinder.svg", height: 1cm), + caption: [A cylinder.], supplement: "Fig", ) <fig1> #figure( - image("/tiger.jpg", height: 3cm), + image("/tiger.jpg", height: 1cm), caption: [A tiger.], - supplement: "Figg", + supplement: "Tig", ) <fig2> -#figure( - $ A = 1 $, - kind: "equation", - supplement: "Equa", - -) <eq1> -@fig1 - -@fig2 - -@eq1 - ---- -#set heading(numbering: (..nums) => { - nums.pos().map(str).join(".") - }, supplement: [Chapt]) - -#show ref: it => { - if it.element != none and it.element.func() == heading { - let element = it.element - "[" - emph(element.supplement) - "-" - numbering(element.numbering, ..counter(heading).at(element.location())) - "]" - } else { - it - } -} - -= Introduction <intro> - -= Summary <sum> - -== Subsection <sub> - -@intro - -@sum - -@sub - ---- - -#show ref: it => { - if it.element != none { - if it.element.func() == text { - let element = it.element - "[" - element - "]" - } else if it.element.func() == underline { - let element = it.element - "{" - element - "}" - } else { - it - } - } else { - it - } -} +$ A = 1 $ <eq1> -@txt +#set math.equation(supplement: none) +$ A = 1 $ <eq2> -Ref something unreferable <txt> +@fig1, @fig2, @eq1, (@eq2) -@under -#underline[ -Some underline text. -] <under> +#set ref(supplement: none) +@fig1, @fig2, @eq1, @eq2 |
