sahasatvik / typst-theorems

An implementation of numbered theorem environments in typst
MIT License
208 stars 12 forks source link

Support latest Typst version #34

Closed jeanas closed 1 week ago

jeanas commented 2 months ago

Using current Typst master at commit typst/typst@d84a7e423b53e9b5740720270b132da60c8a3fea, the example document from https://typst.app/universe/package/ctheorems/ yields warnings:

warning: `state.display` is deprecated
    ┌─ @preview/ctheorems:1.1.2/lib.typ:167:2
    │
167 │   thm-qed-done.display()
    │   ^^^^^^^^^^^^^^^^^^^^^^
    │
    = hint: use `state.get` in a `context` expression instead

warning: `locate` with callback function is deprecated
   ┌─ @preview/ctheorems:1.1.2/lib.typ:37:15
   │  
37 │         result = locate(loc => {
   │ ╭────────────────^
38 │ │         return thmcounters.update(thmpair => {
39 │ │           let counters = thmpair.at("counters")
40 │ │           // Manually update heading counter
   · │
76 │ │         })
77 │ │       })
   │ ╰────────^
   │  
   = hint: use a `context` expression instead

warning: `state.display` is deprecated
   ┌─ @preview/ctheorems:1.1.2/lib.typ:79:15
   │  
79 │         number = thmcounters.display(x => {
   │ ╭────────────────^
80 │ │         return global_numbering(numbering, ..x.at("latest"))
81 │ │       })
   │ ╰────────^
   │  
   = hint: use `state.get` in a `context` expression instead

warning: `locate` with callback function is deprecated
    ┌─ @preview/ctheorems:1.1.2/lib.typ:203:2
    │  
203 │ ╭   locate(loc => {
204 │ │     if thm-qed-done.at(loc) == false {
205 │ │       h(1fr)
206 │ │       thm-qed-show
207 │ │     }
208 │ │   })
    │ ╰────^
    │  
    = hint: use a `context` expression instead

warning: calling `query` with a location is deprecated
    ┌─ @preview/ctheorems:1.1.2/lib.typ:240:15
    │
240 │     let thms = query(selector(<meta:thmenvcounter>).after(loc), loc)
    │                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    │
    = hint: try removing the location argument

Also, the text inside theorems gets centered, which is unwanted:

image

quachpas commented 2 months ago

Hi @jeanas, I think the authors are preparing for a v2.0.0 release compatible with the current typst master. See https://github.com/sahasatvik/typst-theorems/tree/v2.0.0

jbirnick commented 1 week ago

In the meantime before this is fixed, I'm gonna shamelessly advertise my new package great-theorems ;)

You can achieve basically all the same things as ctheorems, the main difference is that I separate counters and theorems strictly, and put counters into a separate package which is usable on its own. This allows you to e.g. have figures and theorems use the same counter (which can depend on the heading counter).

For the counter functionality you can use one of the two packages rich-counters or headcount.