Tex that generats nested SVGs in Mathjax - How to avoid nesting?

33 views
Skip to first unread message

Marcel Bolten

unread,
Dec 21, 2021, 3:39:49 PM12/21/21
to MathJax Users
Hi all,

I use preloaded MathJax components with node.js (source code) to convert tex to SVG in an html document in eLabFTW, an open source electronic lab notebook, and it works very well. MathJax is a great tool.
Now, I want to convert the html document containing the SVG to a PDF with mpdf and it works very well most of the time. But there are cases when Mathjax generates nested SVGs. E.g., with the mhchem extensions: $\ce{A ->[H2O] B}$
So far I think the nesting is limited to stretched arrows with the optional arguments for text above and below.
PDF generation is not working in these cases due to mpdf limitations. Nested SVGs are simply not implemented.
For my use case it would be better to have a short error if that avoids the nesting and hence there will be no problems during PDF generation.

My questions:
  1. Is there a way to avoid stretching of the arrows?
  2. Are there ways to avoid the SVG nesting?
  3. Are there other tex macros that generate nested SVGs?
  4. How can I identify them?

Kind regards,
Marcel

Peter Krautzberger

unread,
Dec 22, 2021, 3:19:49 AM12/22/21
to MathJax Users
Hi,

Random bystander here. MathJax v3's SVG output also generates nested SVGs for labeled equations.

Other PDF tools don't have a problem with nested SVGs so I think it's more appropriate to file an issue with mpdf instead.

Regards,
Peter.

Marcel Bolten

unread,
Feb 17, 2022, 12:09:24 AM2/17/22
to MathJax Users
Hi Peter,

A bit late but nevertheless thanks for your comment and pointing me to the labeled equations.
I was hoping to get a more satisfying answer but was also expecting this kind of answer because you are correct, MathJax is doing an awesome job and everything according to specifications. The bottle neck is mpdf.

In case someone else has a similar issue, in the end I used PHP to find the nested SVGs and convert them to PNGs with imagemagick before PDF generation. This is not ideal but it does the job without running into the problems I was facing before.
 
Regards,
Marcel
Reply all
Reply to author
Forward
0 new messages