michal-h21 / make4ht

Build system for tex4ht
133 stars 15 forks source link

make4ht with mathjax/mathml not working on mathcal #32

Closed ishanina closed 4 years ago

ishanina commented 4 years ago

Hi,

I am having an issue with running make4ht with the mathjax,mathml option. It is trying to render mathcal as a png. Here is a minimal not-working example.

I am running the following command: make4ht test.tex "mathjax,mathml"

Where test.tex consists of

\documentclass[12pt]{amsart}
\ifdefined\HCode   
\def\pgfsysdriver{pgfsys-dvisvgm4ht.def}
\fi%to make tikz-cd work correctly
\usepackage{tikz-cd}
\begin{document}
\[\begin{tikzcd} U \arrow[r] & V \end{tikzcd}\]
$\mathcal{O}$
\end{document}

The output html file is

<!DOCTYPE html> 
<html lang="en-US" xml:lang="en-US" > 
<head><title></title> 
<meta  charset="iso-8859-1" /> 
<meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)" /> 
<meta name="viewport" content="width=device-width,initial-scale=1" /> 
<link rel="stylesheet" type="text/css" href="test.css" /> 
<meta name="src" content="test.tex" /> 
 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=MML_HTMLorMML"></script>  
</head><body 
>
  <table class="equation-star"><tr><td>
<!--l. 7--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="block" class="equation">
                                  <img 
src="test0x.svg" alt="U         V "  />
</math></td></tr></table>
<!--l. 8--><p class="noindent" ><!--l. 8--><math 
 xmlns="http://www.w3.org/1998/Math/MathML"  
display="inline" ><mi 
mathvariant="bold-script"><img 
src="cmsy10-c-4f.png" alt="O" class="10-120x-x-4f" /></mi></math>
</p> 
</body> 
</html>

This looks like

Screen Shot 2020-07-15 at 10 53 49 AM

You can see that there is an error message Unknown node type: img. I'm not too concerned about that, as I have a workaround for it. I am more concerned that $\mathcal{O}$ is being rendered as cmsy10-c-4f.png, which is not what I want, because it it isn't flexible (I can't use superscripts/subscripts for example). I would prefer if it just used mathjax to render it.

I can also run the command without mathml: make4ht test.tex "mathjax" which gives

<!DOCTYPE html> 
<html lang="en-US" xml:lang="en-US" > 
<head><title></title> 
<meta  charset="iso-8859-1" /> 
<meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)" /> 
<meta name="viewport" content="width=device-width,initial-scale=1" /> 
<link rel="stylesheet" type="text/css" href="test.css" /> 
<meta name="src" content="test.tex" /> 
 <script type="text/x-mathjax-config"> MathJax.Hub.Config({ 'fast-preview': {disabled: true}, TeX: { extensions: ["color.js","AMSmath.js"], equationNumbers: { autoNumber: "AMS" } }, extensions: ["tex2jax.js"], tex2jax: {  inlineMath: [ ["\\\(","\\\)"] ], displayMath: [ ['$$','$$'], ["\\[","\\]"] ], processEscapes: true, processEnvironments: true } }); </script> 
 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>  
</head><body 
>
<!--l. 7--><p class="noindent" >\[\begin{tikzcd} U \arrow [r] &amp; V \end{tikzcd}\] \(\mathcal{O}\) </p> 
</body> 
</html>
Screen Shot 2020-07-15 at 10 52 55 AM

But the issue with this is that the tikz-cd diagram isn't working correctly with mathjax.

So is there a reason mathcal is appearing as a png via mathml instead of being rendered normally by mathjax? Is there a way to fix it?

Thanks so much!

michal-h21 commented 4 years ago

I don't get this result on your test file, $\mathcal{O}$ is converted as

<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi mathvariant='bold-script'>𝒪</mi></math>

This may be caused by older version of configuration files for TeX4ht fonts in Miktex. Try the following file, cmsy.htf:

cmsy 0 127
'&#x2212;' ''  0 %
'&#x22C5;' ''  1 % cmsy.htf (unicode)            2020-05-27-14:14 %
'&#x00D7;' ''  2 % Copyright 2000-2009 Michel Goossens %
'&#x2217;' ''  3 % Eitan M. Gurari
'&#x00F7;' ''  4 % 
'&#x25C7;' ''  5 % This work may be distributed and/or modified under the conditions 
'&#x00B1;' ''  6 % of the LaTeX Project Public License, either version 1.3 of this 
'&#x2213;' ''  7 % license or (at your option) any later version. The latest version 
'&#x2295;' ''  8 % of this license is in http://www.latex-project.org/lppl.txt and 
'&#x2296;' ''  9 % version 1.3 or later is part of all distributions of LaTeX version 
'&#x2297;' '' 10 % 2003/12/01 or later. 
'&#x2298;' '' 11 % This work has the LPPL maintenance status "maintained". 
'&#x2299;' '' 12 % Current Maintainer of this work is the TeX4ht Project. 
'&#x25CB;' '' 13 % 
'&#x2218;' '' 14 % If you modify this file, changing the 
'&#x2219;' '' 15 % version identification would be appreciated. 
'&#x224D;' '' 16 % 
'&#x2261;' '' 17 % tex4ht@tug.org 
'&#x2286;' '' 18 % https://tug.org/tex4ht 
'&#x2287;' '' 19 % 
'&#x2264;' ''  20
'&#x2265;' ''  21
'&#x227C;' ''  22
'&#x227D;' ''  23
'&#x223C;' ''  24
'&#x2248;' ''  25
'&#x2282;' ''  26
'&#x2283;' ''  27
'&#x226A;' ''  28
'&#x226B;' ''  29
'&#x227A;' ''  30
'&#x227B;' ''  31
'&#x2190;' ''  32
'&#x2192;' ''  33
'&#x2191;' ''  34
'&#x2193;' ''  35
'&#x2194;' ''  36
'&#x2197;' ''  37
'&#x2198;' ''  38
'&#x2243;' ''  39
'&#x21D0;' ''  40
'&#x21D2;' ''  41
'&#x21D1;' ''  42
'&#x21D3;' ''  43
'&#x21D4;' ''  44
'&#x2196;' ''  45
'&#x2199;' ''  46
'&#x221D;' ''  47
'&#x2032;' ''  48
'&#x221E;' ''  49
'&#x2208;' ''  50
'&#x220B;' ''  51
'&#x25B3;' ''  52
'&#x25BD;' ''  53
'&#x2044;' ''  54
'&#x21A6;' ''         55
'&#x2200;' ''  forall             56
'&#x2203;' '' 57
'&#x00AC;' ''  58
'&#x2205;' ''  59
'&#x211C;' ''  60
'&#x2111;' ''  61
'&#x22A4;' ''  62
'&#x22A5;' ''  63
'&#x2135;' ''  64
'&#x1D49C;' ''         script A         65
'&#x212C;' ''         script B         66
'&#x1D49E;' ''         script C         67
'&#x1D49F;' ''         script D         68
'&#x2130;' ''         script E         69
'&#x2131;' ''         script F         70
'&#x1D4A2;' ''         script G         71
'&#x210B;' ''         script H         72
'&#x2110;' ''         script I         73
'&#x1D4A5;' ''         script J         74
'&#x1D4A6;' ''         script K         75
'&#x2112;' ''         script L         76
'&#x2133;' ''         script M         77
'&#x1D4A9;' ''         script N         78
'&#x1D4AA;' ''         script O         79
'&#x1D4AB;' ''         script P         80
'&#x1D4AC;' ''         script Q         81
'&#x211B;' ''         script R         82
'&#x1D4AE;' ''         script S         83
'&#x1D4AF;' ''         script T         84
'&#x1D4B0;' ''         script U         85
'&#x1D4B1;' ''         script V         86
'&#x1D4B2;' ''         script W         87
'&#x1D4B3;' ''         script X         88
'&#x1D4B4;' ''         script Y         89
'&#x1D4B5;' ''         script Z         90
'&#x222A;' ''  91
'&#x2229;' ''  92
'&#x228E;' ''  93
'&#x2227;' ''  94
'&#x2228;' ''  95
'&#x22A2;' ''  96
'&#x22A3;' ''  97
'&#x230A;' ''  98
'&#x230B;' ''  99
'&#x2308;' ''  100
'&#x2309;' ''  101
'&#x007B;' ''  102
'&#x007D;' ''  103
'&#x27E8;' ''  104
'&#x27E9;' ''  105
'&#x007C;' ''  106
'&#x2225;' ''  107
'&#x2195;' ''  108
'&#x21D5;' ''  109
'&#x2216;' ''  110
'&#x2240;' ''  111
'&#x221A;' ''  112
'&#x2210;' ''  113
'&#x2207;' ''  114
'&#x222B;' ''  115
'&#x2294;' ''  116
'&#x2293;' ''  117
'&#x2291;' ''  118
'&#x2292;' ''  119
'&#x00A7;' ''  120
'&#x2020;' ''  121
'&#x2021;' ''  122
'&#x00B6;' ''  123
'&#x2663;' ''  124
'&#x2662;' ''  125
'&#x2661;' ''  126
'&#x2660;' ''  127
cmsy 0 127
ishanina commented 4 years ago

Thanks for the response Michal,

Here is the solution I ultimately went with:

It turned out to be unnecessary to use both the mathjax and mathml options for make4ht, but rather I only needed mathjax. The trick is to not use the tikzcd environment in math mode. In particular, if you replace \[\begin{tikzcd} U \arrow[r] & V \end{tikzcd}\] with \begin{center}\begin{tikzcd} U \arrow[r] & V \end{tikzcd}\end{center} you get the same pdf output, but now when you run make4ht, mathjax doesn't try to render it, and it gets converted to svg. However using only mathjax makes my macros not work, so I essentially took the advice here to make my macros still work.

Thanks again!