polylux icon indicating copy to clipboard operation
polylux copied to clipboard

Improve usage of uncover, only, etc., in math mode

Open Holt59 opened this issue 2 years ago • 4 comments
trafficstars

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.

Holt59 avatar Apr 20 '23 12:04 Holt59

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?

andreasKroepelin avatar Apr 21 '23 09:04 andreasKroepelin

Can you take a look if this is fixed by using Typst 0.3.0? Because it did something with hide in maths mode.

andreasKroepelin avatar May 01 '23 15:05 andreasKroepelin

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) {
    │            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  

Holt59 avatar May 02 '23 09:05 Holt59

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.

Enivex avatar May 08 '23 18:05 Enivex