EpicEricEE / typst-plugins

My plugins and packages for typst
MIT License
28 stars 1 forks source link

Equate: Supplement function not called if default `#set ref(supplement: ..)` is set #12

Closed hbierlee closed 3 months ago

hbierlee commented 3 months ago

Hi,

Great work on your equate plugin!

I think I found an issue if I set supplement default on ref.

image

See Example on typst.app

#import "@preview/equate:0.2.0": equate
#show: equate.with(breakable: false, sub-numbering: true)
#set math.equation(numbering: "(1.1)")
#set heading(numbering: "(1.1)")

= heading
<sec>
A ref to heading with custom sup @sec

$
  1+1=2 #<dbg:eq:1-1>\
  42
$ <dbg:eq:1>

This is a ref to an equation @dbg:eq:1, and ok ref to sub-equation @dbg:eq:1-1

#set ref(supplement: el => {
  if el.func() == heading {
    [CUSTOM SUP.]
  } else {
    el.supplement
  }
})

This is a ref to an equation @dbg:eq:1, and buggy sub-equation @dbg:eq:1-1

A work-around at the moment is to use show instead, but it would be nice if we can safely overwrite ref default arguments.

Cheers,

Henk