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

Missing qed symbol in nested proofs

Open fagu opened this issue 10 months ago • 1 comments

If you nest multiple proofs, only the innermost ones get a qed symbol.

#set page(width: 11cm, height: auto, margin: 1em)
#set par(justify: true)

#import "@preview/ctheorems:1.1.2": *
#show: thmrules
#let theorem = thmplain("theorem", "Theorem")
#let claim = thmplain("claim", "Claim", base: "theorem")
#let proof = thmproof("proof", "Proof")

#theorem[
  #lorem(10)
]
#proof[
  #lorem(10)
  #claim[
    #lorem(10)
  ]
  #proof[
    #lorem(20)
  ]
  #claim[
    #lorem(10)
  ]
  #proof[
    #lorem(20)
  ]
  #lorem(20)
]

nested-qed

A solution could be to make the thm-qed-done state a stack of booleans: At the start of a proof, push false. When showing the qed symbol, set the last entry to true. At the end of a proof, remove the last entry and show the qed symbol if the removed entry was false.

(That also seems to be what latex does.)

fagu avatar Apr 21 '24 10:04 fagu