more robust mathjax handling