-
Notifications
You must be signed in to change notification settings - Fork 5
/
mathjax-latex-4ht.sty
120 lines (111 loc) · 3.18 KB
/
mathjax-latex-4ht.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
\RequirePackage{etoolbox,expl3,environ}
\ExplSyntaxOn
\cs_new_protected:Npn \alteqtoks #1
{
\tl_set:Nx \l_tmpa_tl {\detokenize{#1}}
% delete spaces before left brackets
\regex_replace_all:nnN { \x{20} \x{7B} } { \x{7B} } \l_tmpa_tl
% replace < > and & with xml entities
\regex_replace_all:nnN { \x{26} } { & } \l_tmpa_tl
\regex_replace_all:nnN { \x{3C} } { < } \l_tmpa_tl
\regex_replace_all:nnN { \x{3E} } { > } \l_tmpa_tl
\tl_set:Nx \l_tmpb_tl{ \l_tmpa_tl }
\HCode{\l_tmpb_tl}
}
\ExplSyntaxOff
\AtBeginDocument{%
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
%\Configure{@HEAD}{\HCode{<link href="basic.css" rel="stylesheet" type="text/css" />\Hnewline}}
\Configure{@HEAD}{\HCode{
<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: {
\unexpanded{
inlineMath: [ ["\\\(","\\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],}
processEscapes: true,
processEnvironments: true
}
});
</script>\Hnewline
}}
\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}}
\long\def\AltMathOne#1${\alteqtoks{\(#1\)}$}
\Configure{$}{}{}{\expandafter\AltMathOne}
\long\def\AltlMath#1\){\expandafter\alteqtoks{\(#1\)}\)}
\Configure{()}{\AltlMath}{}
\long\def\AltlDisplay#1\]{\alteqtoks{\[#1\]}\]}
\Configure{[]}{\AltlDisplay}{}
\newcommand\VerbMathToks[2]{%
\alteqtoks{\begin{#2}
#1
\end{#2}}%
}
\newcommand\VerbMath[1]{%
\ifcsdef{#1}{%
\RenewEnviron{#1}{%
\NoFonts\expandafter\VerbMathToks\expandafter{\BODY}{#1}\EndNoFonts%
}
}{}%
}
\VerbMath{subarray}
\VerbMath{smallmatrix}
\VerbMath{matrix}
\VerbMath{pmatrix}
\VerbMath{bmatrix}
\VerbMath{Bmatrix}
\VerbMath{vmatrix}
\VerbMath{Vmatrix}
\VerbMath{cases}
\VerbMath{subequations}
\VerbMath{aligned}
\VerbMath{alignedat}
\VerbMath{gathered}
\VerbMath{gather}
\VerbMath{gather*}
\VerbMath{alignat}
\VerbMath{alignat*}
\VerbMath{xalignat}
\VerbMath{xalignat*}
\VerbMath{xxalignat}
\VerbMath{align}
\VerbMath{align*}
\VerbMath{flalign}
\VerbMath{flalign*}
\VerbMath{split}
\VerbMath{multline}
\VerbMath{multline*}
\VerbMath{equation}
\VerbMath{equation*}
\VerbMath{math}
\VerbMath{displaymath}
% it is necessary to reset env configurations for multline
\ConfigureEnv{multline}{}{}{}{}
\ConfigureEnv{multline*}{}{}{}{}
% fixes for tables of contents
\def\fixmathjaxtoc#1{\def#1{\detokenize{#1}}}
\fixmathjaxtoc\left
\fixmathjaxtoc\right
\fixmathjaxtoc\int
\fixmathjaxtoc\,
\fixmathjaxtoc\sin
\fixmathjaxtoc\cos
\fixmathjaxtoc\tan
\fixmathjaxtoc\arcsin
\fixmathjaxtoc\arccos
\fixmathjaxtoc\arctan
\fixmathjaxtoc\csc
\fixmathjaxtoc\sec
\fixmathjaxtoc\cot
\fixmathjaxtoc\sinh
\fixmathjaxtoc\cosh
\fixmathjaxtoc\tanh
\fixmathjaxtoc\coth
\fixmathjaxtoc\log
}