I am using tex4ht to convert a LaTeX document to HTML. I would like to know how to obtain a full display of equations either in the eqnarray, align and array environments. The following snippet illustrates my problem.




  \omega = \sqrt{\displaystyle\frac{\displaystyle k}{\displaystyle m}} 
  & \displaystyle\mbox{ and } 
  & \displaystyle\gamma = \frac{\displaystyle b}{\displaystyle m}

  \omega = \sqrt{\displaystyle\frac{\displaystyle k}{\displaystyle m}} 
  & \displaystyle\mbox{ and } 
  & \displaystyle\gamma = \frac{\displaystyle b}{\displaystyle m}

  \omega & = & \sqrt{\displaystyle\frac{\displaystyle k}{\displaystyle m}} \\
  \gamma & = & \frac{\displaystyle b}{\displaystyle m}

  \omega = \sqrt{\frac{k}{m}}


If I compile it with pdflatex, the rendering is good. However, with tex4ht (make4ht --utf8 test.tex "mathml,mathjax"), the fractions are squished. The HTML looks like that:

enter image description here

I tried to put as much \displaystyle as I could. Notice that when the equation is in a regular equation environment (fourth line), it looks good. Is there a way to give more space to these fractions in the first three lines?

  • 3
    \displaystyle is doing nothing here, both evironments are display by default. Commented Oct 4, 2022 at 14:14
  • 1
    eqnarray is one of an older format tag, please use align as always...
    – MadyYuvi
    Commented Oct 4, 2022 at 14:28

1 Answer 1


We need to use the displaystyle="true" attribute to get the correct size of fractions etc. I will fix it in TeX4ht sources. In the meantime, you can use the following configuration file, which uses the original TeX4ht configuration with this attribute added:

   {\HCode{<\a:mathml mtable\Hnewline \a:mathml displaystyle="true" \mml:class="eqnarray\ifx
       \a:mathml columnalign="right center left" >}}%
   {\HCode{</\a:mathml mtable>}}
   {\HCode{<\a:mathml mtr>}}  {\HCode{</\a:mathml mtr>}}
   {\Tg<\a:mathml mtd\Hnewline \mml:class="eqnarray-\HCol">
      \ifnum \HCol=4
        \Tg<\a:mathml mtext
  {\EndPauseMathClass \mtextfalse
\HCode{</\a:mathml mtext><\a:mathml
                                mstyle\Hnewline \mml:class="math">}}%
  {\HCode{</\a:mathml mstyle><\a:mathml
       mtext \a:@mtext>}\ht:special{t4ht@,&\#x00A0;}%
  {\EndPauseMathClass \mtextfalse
\HCode{</\a:mathml mtext><\a:mathml
                                mstyle\Hnewline \mml:class="math">}$}%
  {$\HCode{</\a:mathml mstyle><\a:mathml
       mtext \a:@mtext>}\ht:special{t4ht@,&\#x00A0;}%
   {\ifnum \HCol=4 \mtextfalse
\Tg</\a:mathml mtext>\fi
      \Tg</\a:mathml mtd>}

       \ifvmode\else \def\end:al:env{\par\ShowPar\IgnoreIndent}\fi\fi}
     {\end:al:env }
    \ifvmode \EndP  \else \EndP  \HCode{<!--tex4ht:inline-->}\fi
       \Tg<\a:mathml mrow>\def\end:mathalign{\Tg</\a:mathml mrow>}%
       \def\end:mathalign{\EndDviMath \DisplayMathfalse}%
    \HCode{<\a:mathml mtable\Hnewline
                \a:mathml columnalign="left" \a:mathml displaystyle="true" \mml:class="#2">}}
   {\HCode{</\a:mathml mtable>}\end:mathalign }
   {\HCode{<\a:mathml mtr>}}    {\HCode{</\a:mathml mtr>}}
   {\HCode{<\a:mathml mtd\Hnewline
      \ifodd\HCol \a:mathml  columnalign="right" \fi
      \mml:class="align-\ifnum \HCol>\maxfields@ label\else
         \ifodd\HCol\space  odd\else     even\fi
       <\a:mathml mspace width="2em"/>\fi
</\a:mathml mtd>}}}

   \a:mathml equalrows="false"
   \ifx\columnlines\empty\else\a:mathml columnlines="\columnlines" \fi
   \a:mathml equalcolumns="false" \a:mathml class="array" \a:mathml displaystyle="true" }<>\HAlign}


This is the result:

enter image description here

  • Great! It works for eqnarray and align. I however noticed that I also have this problem within the array environment in a few equations. Can this configuration be adapted to also cover array? In any case, thank you for your help. Commented Oct 4, 2022 at 16:03
  • 1
    @FrédéricGalliano hopefully yes. can you update your question with an array example, so I have something for testing?
    – michal.h21
    Commented Oct 4, 2022 at 18:06
  • Thank you for the update. Now it looks perfect. Commented Oct 6, 2022 at 9:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .