LaTeXML icon indicating copy to clipboard operation
LaTeXML copied to clipboard

foreignObject width & font size mismatch

Open xworld21 opened this issue 3 months ago • 0 comments

The variable --fo_width uses em units, based on the font size of its content. However, changes in font size are applied at different times in HTML. In this example:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \draw (0,1) node {Hello.};
  \draw (0,0) node {\scriptsize Hello.};
\end{tikzpicture}
\end{document}

both foreign objects get approximately the same size in em units, because LaTeXML is applying \scriptsize first.

However, the HTML looks like

<foreignObject style="--fo_width :2.54em;--fo_height:0.61em;--fo_depth :0em;" height="6.73" overflow="visible" transform="matrix(1 0 0 -1 0 6.73)" width="28">
  <span class="ltx_foreignobject_container">
    <span class="ltx_foreignobject_content">
      <span class="ltx_text" style="font-size:70%;">Hello.</span>
    </span>
  </span>
</foreignObject>

The width is applied to ltx_foreignobject_container, where the font size is still 100%. Somehow the font-size:70% should float up for this to work correctly.

xworld21 avatar Nov 22 '25 18:11 xworld21