4 ms·
I played with this briefly, and saw that supplement can also take a function, which presumable how you make @wibble return '(34)' instead of 'Equation 34'? The
by qhwudbebd 2y ago
I played with this briefly, and saw that supplement can also take a function, which presumable how you make @wibble return '(34)' instead of 'Equation 34'? The function is passed the equation itself, so supplement: x => x makes the reference identical to the whole equation (!), but it wasn't obvious to me how to extract just the equation number from an equation x?
This is a really common idiom in mathematical writing: "from (1) we see that..." instead of "from Equation 1 we see that". (Randomly capitalising 'Equation' here is another controversial implication of using a fixed word string as a supplement.)
- cbolton 2y agoI would just define `#let eqref(target) = "(" + ref(target, supplement: none) + ")"` and then use it as in "from #eqref(<eq-xy>) we see that..". You can probably do that with a function given as supplement but it looks a bit involved, I think you'd have to do something like in this example: https://typst.app/docs/reference/model/ref/#customization https://typst.app/docs/reference/model/ref/#customization (I think the reference system is an area where things can be improved to main some common use cases simpler.)
- qhwudbebd 2y agoAgreed it could be improved fairly easily at this early stage, and even documenting 'standard recipes' would help. But I do think as a default, prefacing with a fixed string with fixed capitalisation is probably the wrong choice vs earlier systems which simply insert the reference number/letter itself and allow the user to word things correctly around that. Trying to make it do the right thing in context in a way that generalises across multiple languages is unnecessarily hard.