How to implement sub-numbering for custom figures and equations?

If I’m understanding your initial code correctly, you want to make all theorems before the first header just have a theorem counter number (e.g., (1)), and all theorems after a header to have that header’s number and the theorem counter number (e.g., (1.1)), yes? If that’s the case, inside your show rule for thm figures, you will want to:

  • save current header count in a variable (e.g., let header_count = ...)
  • save current theorem count in a variable (e.g., let thm_count = ...)
  • use an if statement to use one of the two numbering uses based on header_count, and save its result to a variable (e.g., let num = if header_count > 0 {...} else {...})

Give that a try!