[tex4ht] MathJax support

Nasser M. Abbasi nma at 12000.org
Sun Dec 9 12:54:00 CET 2018


On 12/9/2018 5:25 AM, Michal Hoftich wrote:
>> I looked at the HTML generated and see no place where it loads mathjax.
>>
>> ie. I see no
>>
>> \Configure{@HEAD}{\HCode{ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> \Hnewline}}
>>
> 
> It should be included in html4-math.4ht, in the configuration for
> MathjaxSource. Does the attached version work?
> 
> M.
> 

hi Michal,

It is allready in html4-math.4ht

>grep -i  cdnjs /usr/local/texlive/2018/texmf-dist/tex/generic/tex4ht/html4-math.4ht
\Configure{MathjaxSource}{https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML}

I found why it does it now work on my end.

When I use my .cfg, the above line does not show in the HTML.

I did remove the old require mathjax-latex-4ht.sty from my .cfg.

But I think the reason is that my .cfg has additional mathjax
configurations I needed which you said to add it to .cfg before,
since I could not add it to mathjax-latex-4ht.sty. It uses
your

\ExplSyntaxOn
\regex_replace_all:nnN{ \x{23}\x{23}}{\x{23}}{\mymathjaxconf}
\ExplSyntaxOff

trick.

May be the order is now messed up from before when it worked?

Because I am doing additional MathJax.Hub.Config({ in my .cfg,
which does show in HTML, something now went wrong? This all worked
before. I need these additional fixes in my .cfg.

I am attaching my .cfg file. Can you please try on your end?

THis is how I called it

make4ht -c ./nma_mathjax.cfg foo1.tex "htm,mathjax"

Now mathjax do _not_ load in HTML, but when I do

make4ht foo1.tex "htm,mathjax"

Then it loads. Any work arounds?

Getting Mathjax to work is hard!

Thank you,
--Nasser
-------------- next part --------------
\Preamble{xhtml}

\Configure{VERSION}{}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
\Configure{@HEAD}{}
\Configure{@HEAD}{\HCode{<meta charset="UTF-8" />\Hnewline}}
\Configure{@HEAD}{\HCode{<meta name="generator" content="TeX4ht
(http://www.cse.ohio-state.edu/\string~gurari/TeX4ht/)" />\Hnewline}}
\Configure{@HEAD}{\HCode{<link
         rel="stylesheet" type="text/css"
         href="\expandafter\csname aa:CssFile\endcsname" />\Hnewline}}

%thanks to Michal Hoftich. Added Nov 18, 2018 to handle Maple Latex export problem
\Configure{@HEAD}{\HCode{
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    TeX: {
      Macros: {
        \unexpanded{
        sc : "\\small\\rm",
        sl: "\\it",
		LommelS: ["\\operatorname{LommelS\#1}",1],
		tauL: "\\tau L"		
      }
    },
    }
  });
</script>
}}

           
\begin{document}


%----------------------------------

%support for \relax and \setlength by Michal
\edef\mymathjaxconf{\detokenize{MathJax.Hub.Config({
        TeX: {
  MAXBUFFER: 40*1024,        
  Macros : {
relax: "{}",
setlength: ["{}", 2],
allowbreak: "{}",
sech: ["\\operatorname{sech}"],
csch: ["\\operatorname{csch}"],
arcsec: ["\\operatorname{arcsec}"],
arccot: ["\\operatorname{arccot}"],
arccsc: ["\\operatorname{arccsc}"],
arccosh: ["\\operatorname{arccosh}"],
arcsinh: ["\\operatorname{arcsinh}"],
arctanh: ["\\operatorname{arctanh}"],
arcsech: ["\\operatorname{arcsech}"],
arccsch: ["\\operatorname{arccsch}"],
arccoth: ["\\operatorname{arccoth}"],
erf: ["\\operatorname{erf}"],
AiryAi: ["\\operatorname{AiryAi}"],
AiryBi: ["\\operatorname{AiryBi}"],
BesselJ: ["\\operatorname{BesselJ}"],
BesselY: ["\\operatorname{BesselY}"],
BesselK: ["\\operatorname{BesselK}"],
BesselI: ["\\operatorname{BesselI}"],                
WhittakerM: ["\\operatorname{WhittakerM}"],
WhittakerW: ["\\operatorname{WhittakerW}"],
LambertW: ["\\operatorname{LambertW}"],
RootOf: ["\\operatorname{RootOf}"],
erfi: ["\\operatorname{erfi}"],
Ei: ["\\operatorname{Ei}"],
Si: ["\\operatorname{Si}"],
Ci: ["\\operatorname{Ci}"],
Ssi: ["\\operatorname{Ssi}"],
Shi: ["\\operatorname{Shi}"],
Chi: ["\\operatorname{Chi}"],
Li: ["\\operatorname{Li}"],
HeunC: ["\\operatorname{HeunC}"],
HeunCPrime: ["\\operatorname{HeunCPrime}"],
FresnelC: ["\\operatorname{FresnelC}"],
EllipticE: ["\\operatorname{EllipticE}"],
EllipticCE: ["\\operatorname{EllipticCE}"],
EllipticF: ["\\operatorname{EllipticF}"],
EllipticK: ["\\operatorname{EllipticK}"],
EllipticCK: ["\\operatorname{EllipticCK}"],
EllipticPi: ["\\operatorname{EllipticPi}"],
EllipticCPi: ["\\operatorname{EllipticCPi}"],
LegendreP: ["\\operatorname{LegendreP}"],
LegendreQ: ["\\operatorname{LegendreQ}"],
dilog: ["\\operatorname{dilog}"],
polylog: ["\\operatorname{polylog}"],
StruveH: ["\\operatorname{StruveH}"],
StruveL: ["\\operatorname{StruveL}"]
}},
});}}

\ExplSyntaxOn
\regex_replace_all:nnN{ \x{23}\x{23}}{\x{23}}{\mymathjaxconf}
\ExplSyntaxOff

\Configure{@HEAD}{\HCode{<script
type="text/x-mathjax-config"> \mymathjaxconf</script>}}


          
\EndPreamble


More information about the tex4ht mailing list