mathjax/MathJax-demos-node

text2svg cannot fully show formula

Opened this issue · 2 comments

i'm trying to make text to svg, i found some cannot fully show the formula,
thanks a lot

(\dfrac{1}{2}\overrightarrow{b})
QQ浏览器截图20240416182740

(\overrightarrow{a}//\overrightarrow{b})

QQ浏览器截图20240416183310

((\dfrac{1}{2}\overrightarrow{b}))

((\overrightarrow{a}//\overrightarrow{b}))

dpvc commented

The width of a MathJax SVG element correspond to the width of the typeset expression, which is not necessarily the bounding box of the ink for the expression. This is so that the amount of space that the SVG takes up within a line of HTML text will be the same as it would be for the typeset math in CHTML. But that does mean that some items may extend outside the viewBox of the SVG element, as in your case (in LaTeX, accents like the arrows not add to the width of the base character they are over).

See #61 for more information, and for a suggestions on how you can proceed. One it to use overflow: visible for the svg element so that the overlap will be rendered rather than clipped. Another is to use getBBox() on the top-level g element to get its bounding box and use that as a replacement for the viewBox values.