polylux
polylux copied to clipboard
Improve usage of uncover, only, etc., in math mode
Maybe I missed something, but usage of uncover, etc., in math mode seems kind of tricky, I tried the following:
# times is not directly available, need to go for #sym.times
$ x = 4 #uncover(2)[#sym.times (y + 5)] $
# needs to escape * and the * symbol is not the one from math mode (not vertically centered)
$ x = 4 #uncover(2)[\* (y + 5)] $
# does not work, compile error
$ uncover(2 *, y + 5) $
Ideally, one should be able to write math as if inside an equation when using uncover, etc.
This looks like it is due to more general issues in Typst and its maths typesetting. What is the compile error in the last case?
Can you take a look if this is fixed by using Typst 0.3.0? Because it did something with hide in maths mode.
The error is still present with latest typst, the error in the last case is
error: panicked with: "you may only provide a single integer, an array of integers, or a string"
┌─ examples\slides.typ:82:13
│
82 │ panic("you may only provide a single integer, an array of integers, or a string")
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: error occurred in this call of function `_check-visible`
┌─ examples\slides.typ:111:11
│
111 │ if _check-visible(subslide.at(loc).first(), visible-subslides) {
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I've defined this myself as a workaround for now
#let only-math(visible-subslides, string) = {
[#h(0cm)#_conditional-display(visible-subslides, false, "doesn't even matter", eval("$"+string+"$"))#h(0cm)]
}
(uncover can be modified similarly)
You can then write for instance #only-math(2,"F^(1\/2)") inside an equation. The #h(0cm)s are required to get correct spacing for some reason.