typst / templates

Templates that are directly maintained by the Typst team.
MIT No Attribution
204 stars 20 forks source link

ams template: references to theorem labels don't include the heading #8

Open WannesMalfait opened 1 year ago

WannesMalfait commented 1 year ago

The heading number is included in the theorem itself, but not when you reference it. The numbering should be consistent.

Example based on main.typ in the ams template:

#theorem[
  The square of any real number is non-negative.
]<thm:sq-positive>

#proof[
  Any real number $x$ satisfies $x > 0$, $x = 0$, or $x < 0$. If $x = 0$,
  then $x^2 = 0 >= 0$. If $x > 0$ then as a positive time a positive is
  positive we have $x^2 = x x > 0$. If $x < 0$ then $−x > 0$ and so by
  what we have just done $x^2 = (−x)^2 > 0$. So in all cases $x^2 ≥ 0$.
]

= Introduction

#theorem[
    For any right-angled triangle with legs $a,b$ and hypotenuse $c$:
    $
    a^2 + b^2 = c^2
    $
]
<thm:pythagoras>

This is a new section.
We now use @thm:sq-positive
and @thm:pythagoras

image

YDX-2147483647 commented 1 year ago

Update: Sorry, this is not a full solution. I'm working on it…

I have the same issue with table.

Maybe we should change the following lines…

https://github.com/typst/templates/blob/7cec678fb6a6782361c79f3ac87c41a8a2b4a0a2/ams/template.typ#L151-L154

…to…

      smallcaps(it.supplement)
      if it.numbering != none {
        [ #it.counter.display(it.numbering)]
      }

Relevant

The example of modifying the appearance in Figure Function – Typst Documentation.

#show figure: it => align(center)[
  #it.caption |
  #emph[
    #it.supplement
    #it.counter.display(it.numbering)
  ]
  #v(10pt, weak: true)
  #it.body
]
YDX-2147483647 commented 1 year ago

I apologize to you… It's hard than I thought.

  1. 10 is the first step, and is done.

  2. Now the theorem counter does not even count the heading — it's only displayed.

    https://github.com/typst/templates/blob/7cec678fb6a6782361c79f3ac87c41a8a2b4a0a2/ams/template.typ#L168-L169

    The counter is reset when a new chapter starts.

    https://github.com/typst/templates/blob/7cec678fb6a6782361c79f3ac87c41a8a2b4a0a2/ams/template.typ#L115

    To fix that, we should turn it into a multi-level counter. It's possible, but I don't know how to start…