typst-hs icon indicating copy to clipboard operation
typst-hs copied to clipboard

Error when importing from ctheorems:1.1.2

Open KaarelKurik opened this issue 2 years ago • 3 comments

A Typst document test.typ containing only the import statement #import "@preview/ctheorems:1.1.2": * will fail with pandoc 3.1.12.2, giving the message:

"test.typ" (line 1, column 2):
"/home/kaarel/.cache/typst/packages/preview/ctheorems/1.1.2/lib.typ" (line 223, column 18):
unexpected '>'
expecting operator

test.typ compiles with Typst version 0.10.0.

KaarelKurik avatar Mar 14 '24 01:03 KaarelKurik

Here's the place where it fails:

  show figure.where(kind: "thmenv"): it => it.body

  show ref: it => {
    if it.element == none {
      return it

It fails on the second show. I'm not sure yet why.

jgm avatar Mar 14 '24 02:03 jgm

The changes in #43 seem to have fixed this to the point where the package's code can be parsed. I now get a different error:

...Library/Caches/typst/packages/preview/ctheorems/1.1.2/lib.typ" (line 165, column 2):
Content does not have a method "update" or FieldAccess requires a dictionary

This is on:

// Show the qed symbol, update state
#let thm-qed-show = {
  thm-qed-done.update("thm-qed-symbol")
  thm-qed-done.display()
}

We don't yet support https://typst.app/docs/reference/introspection/state/

jgm avatar Mar 18 '24 23:03 jgm

A similar problem occurs with this code:

#let solution(target-label, body) = context {
  let lbl = label(target-label)
  let elements = query(lbl)
  if elements.len() == 0 {
    text(fill: red)[*Error: Label #target-label not found*]
  } else if elements.len() > 1 {
    text(fill: red)[*Error: Multiple #target-label labels found*]
  } else {
    let target-element = elements.first()
    let num = counter(figure.where(kind: "exercise")).at(target-element.location()).first()

    figure(
      kind: "solution",
      supplement: "Solution",
      numbering: none,
      caption: [#num],
      body
    )
  }
}

This fails with:

unexpected end of input
expecting end of input
Content does not have a method "len" or FieldAccess requires a dictionary

behrangsa avatar Dec 10 '25 02:12 behrangsa