remark icon indicating copy to clipboard operation
remark copied to clipboard

MathJax resize issue on hidden slides

Open johanrosenkilde opened this issue 9 years ago • 2 comments

The "Examples" page has an example for enabling MathJax in a slide show. But there seems to be a resizing problem on math rendered on hidden slides. More precisely:

  1. You load your slide show on Slide 1 (refresh your browser).
  2. On Slide 2 you have some math, e.g. \(\LaTeX\).
  3. Moving to Slide 2, the rendered math is quite small.
  4. If you refresh your browser now, the math is rerendered much bigger.

This is most easily tested by having two identical slides with math and moving back and forth.

johanrosenkilde avatar Jan 26 '16 13:01 johanrosenkilde

It might be related to a well-known behaviour of MathJax, described e.g. here (long comment at the end by dpvc):

https://github.com/mathjax/MathJax/issues/1179

Namely that when math is to be pre-rendered within a container having "display: none", then MathJax uses various tricks and heuristics to guess the size and layout of the math. But it will only be guesses and is guaranteed to have glitches now and then.

I don't know if that leaves this as a "can't resolve issue"...

johanrosenkilde avatar Jan 26 '16 13:01 johanrosenkilde

  • This might be solved by hiding slides in another way e.g. visibility:hidden; height:0; overflow:hidden; so MathJax can still measure sizes. This might make rendering slower as browser needs to layout all slides rather than just current (?)

  • This could be mitigated by re-running MathJax on current slide after each slide switch? But that would result in ugly visible re-render on each slide with math :-1:

  • IIRC MathJax "CommonHTML" output is less sensitive to measurements but still does some? (asked on above issue...)

  • I think KaTeX will not have this problem?

cben avatar Mar 04 '20 14:03 cben