[tex4ht] [bug #488] \over does not give the same result as equivalent \frac

Michal Hoftich puszcza-hackers at gnu.org.ua
Mon Oct 26 23:35:17 CET 2020


Follow-up Comment #1, bug #488 (project tex4ht):

The simplest thing you can do is to convert your whole inline math to image,
using for example:

httex filename "xhtml,html5,pic-m"

Also, it works in MathML:

htttex filename "xhtml,html5,mathml,mathjax"

As it works in MathML, it is obvious that it is possible to configure \over to
produce sensible output in plain HTML. Here is a sample HTML document:

\documentclass{article}
\begin{document}
${a+2 \over b} $

$  1 + \begingroup a \over b \endgroup + 2$

$  1 + \bgroup a \over b \egroup + 2$

$  1 + { a \over b \egroup + 2$


$  1 + \bgroup a \over b } + 2$
\end{document}


And here is a config file:

----
\Preamble{xhtml}
\catcode`\:=11
\def\IgnoreRule{\ht:special{t4ht@\string_}}
\def\EndIgnoreRule{\ht:special{t4ht@\string_\string_}}

\Configure{over}
   {\Send{GROUP}{0}{<span class="fraction"><span
class="top">}\IgnoreRule\HCode{</span>}}
   {\HCode{<span
class="bottom">}\EndIgnoreRule\Send{EndGROUP}{0}{</span></span>}}

\Css{
.fraction {
  display: inline-flex;
  flex-direction: column;
  padding: 0 2px;
  align-items: center;
  font-size:130\%;
}}
\Css{.top {
  border-bottom: 2px solid grey;
}}

\Configure{$}{\DviMath}{\EndDviMath}{}
\catcode`\:=12
\begin{document}
\EndPreamble
----

It uses CSS flex box to render fractions. 

I don't really understand how \Send command works, as it is not really
documented anywhere in TeX4ht sources. But it can be used in these cases to
insert HTML code at beginning and end of the current group. It works only in
\DviMath mode, which is why the following configuration is necessary:

\Configure{$}{\DviMath}{\EndDviMath}{}

I don't know if it will have any side effects on other math configurations,
hopefully not.

Compile the example using 

make4ht -c config.cfg sample.tex


    _______________________________________________________

Reply to this item at:

  <http://puszcza.gnu.org.ua/bugs/?488>

_______________________________________________
  Message sent via/by Puszcza
  http://puszcza.gnu.org.ua/



More information about the tex4ht mailing list.