michal-h21 / make4ht

Build system for tex4ht
131 stars 15 forks source link

`\dfrac` inside `\dfrac` #129

Closed yalguzaq closed 10 months ago

yalguzaq commented 11 months ago

LaTeX

\documentclass{article}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{mathtools}
\usepackage{tikz-cd}
\begin{document}
$$\frac{C}{\left(\dfrac{x_1}{2}\right)^2}$$
\end{document}

make4ht

make4ht --format html5+join_colors --config make4ht.cfg --shell-escape markup.tex 'mathjax'

make4ht.cfg

\Preamble{xhtml,mathml,mathjax}

% 3.3.3 Use relative size for images
\makeatletter 
\ExplSyntaxOn 
\Configure{Gin-dim} 
{style="width:\fp_eval:n{round(\Gin@req@width/\textwidth*100,2)}\char_generate:nn { `\% } { 12 }"} 
\ExplSyntaxOff 
\makeatother 

\Configure{Gin-dim}{} 
\Css{img { 
    max-width: 100\%; 
    height: auto; 
}} 

% ISSUE #95: Outputing weird \mathcal characters
\catcode`\:=11
\renewcommand\mathcal[1]{\bgroup\HCode{<\a:mathml mi\Hnewline  data-mjx-variant="-tex-calligraphic" mathvariant="script">}#1\HCode{</\a:mathml mi>}\egroup}
\catcode`\:=12

% ISSUE #97: 'mathml'-option produces long vertical line 
\Configure{MathClass}{3}{*}{<mo class="MathClass-rel" stretchy="false">}{</mo>}{}

% ISSUE #101: 'mathml'-option produces large division sign
\Configure{MathClass}{2}{*}{<mo class="MathClass-bin" stretchy="false">}{</mo>}{}

\begin{document}

\EndPreamble

Erroneous output

image

Comment

\dfrac not working inside \dfrac under these settings for some reason.

michal-h21 commented 10 months ago

Try this configuration file:

\catcode`\:=11
\pend:def\dfrac{\Configure{genfrac}{\HCode{<\a:mathml mstyle \mathchoice{\a:mathml displaystyle="true"}{}{}{}><mfrac><mrow>}\Configure{over}{}{}}{}{}{\HCode{</mrow><mrow>}}{}{\HCode{</mrow></mfrac></\a:mathml mstyle>}}}
\pend:def\tfrac{\Configure{genfrac}{\HCode{<\a:mathml mstyle \mathchoice{\a:mathml displaystyle="false"}{}{}{}><mfrac><mrow>}\Configure{over}{}{}}{}{}{\HCode{</mrow><mrow>}}{}{\HCode{</mrow></mfrac></\a:mathml mstyle>}}}
\catcode`\:=12
\Preamble{xhtml}
\begin{document}
\EndPreamble
yalguzaq commented 10 months ago

Thanks. I hope this will be added in the next update.