You cannot put blank lines in the MathJax configuration. It results in JavaScript parsing error, so your definitions aren't used at all. Here is a corrected version:
\Preamble{xhtml,p-width}
%This below does not work. see https://tex.stackexchange.com/questions/543919/what-are-the-limitations-of-using-tikz-with-tex4ht
%\tikzset{every node/.style={/pgf/tex4ht node/escape=true}}
%this disables make4ht loading mathjax
\Configure{MathjaxSource}{}
%\Configure{@HEAD}{\HCode{ <script type="text/javascript" src="/scripts/MathJax-2.7.3/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> \Hnewline}}
%this loads mathjax
\Configure{MathjaxSource}{https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js}
%V3.0
\Configure{MathJaxConfig}{{
tex: {
maxBuffer: 40*1024,
packages: {'[+]': ['textmacros']},
\unexpanded{%
macros: {
sp: "^",
sb: "_",
noalign: ["\#1", 1],
myadjustbox: ["\#1", 1],
medskip: "",
sc: "\\small\\rm",
sl: "\\it",
symbfit: "\\boldsymbol",
LommelS: ["\\operatorname{LommelS\#1}",1],
sinc: ["\\operatorname{sinc}"],
dag: ["\\dagger"],
ddag: ["\\ddagger"],
tauL: "\\tau L",
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}"],
erfi: ["\\operatorname{erfi}"],
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}"],
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}"],
ParabolicCylinderD: ["\\operatorname{ParabolicCylinderD}"],
hypergeom: ["\\operatorname{hypergeom}"],
WeierstrassP: ["\\operatorname{WeierstrassP}"],
MathieuS: ["\\operatorname{MathieuS}"],
MathieuC: ["\\operatorname{MathieuC}"],
MathieuSPrime: ["\\operatorname{MathieuSPrime}"],
MathieuCPrime: ["\\operatorname{MathieuCPrime}"],
logintegral: ["\\operatorname{log\\_integral}"],
Mapleoverset: ["\\mathop{\#2}\\limits^{\#1}",2],
Mapleunderset: ["\\mathop{\#2}\\limits_{\#1}",2]
}},
autoload: {
color: [],
colorV2: ['color']
},
packages: {'[+]': ['noerrors','textmacros']}
},
options: {
ignoreHtmlClass: 'tex2jax_ignore',
processHtmlClass: 'tex2jax_process'
},
loader: {
load: ['[tex]/noerrors','[tex]/textmacros']
}
};
}
%added oct 4,2019
%\Configure{@HEAD}{\HCode{
%<script async src="https://www.googletagmanager.com/gtag/js?id=UA-149430386-1"></script>
%<script>
% window.dataLayer = window.dataLayer || [];
% function gtag(){dataLayer.push(arguments);}
% gtag('js', new Date());
% gtag('config', 'UA-149430386-1');
%</script>}}
\Configure{@HEAD}{\HCode{<SCRIPT TYPE="text/javascript">
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == "string")
href=mylink;
else
href=mylink.href;
window.open(href, windowname, "width=600,height=200,scrollbars=yes");
return false;
}
</SCRIPT>\Hnewline}}
\Configure{@HEAD}{\HCode{
<link rel="shortcut icon" href="\#" />\Hnewline
}}
\Configure{@HEAD}{\HCode{
<script type="text/javascript" src="/scripts/gifffer-master/lib/gifffer.js"></script>\Hnewline
<script>
window.onload = function() {
Gifffer();
}
</script>\Hnewline
}}
%added March 1, 2020
\Configure{@HEAD}{\HCode{
<script type="text/javascript" src="/scripts/libgif-js-master/libgif.js"></script>\Hnewline
<script type="text/javascript" src="/scripts/libgif-js-master/rubbable.js"></script>\Hnewline
}
}
\Configure{@HEAD}{\HCode{
<script type="text/javascript" src="/styles/syntaxhighlighter/scripts/shCore.js"></script>\Hnewline
<script type="text/javascript" src="/styles/syntaxhighlighter/scripts/shBrushMatlab.js"></script>\Hnewline
<script type="text/javascript" src="/styles/syntaxhighlighter/scripts/shBrushPlain.js"></script>\Hnewline
<script type="text/javascript" src="/styles/syntaxhighlighter/scripts/shBrushPython.js"></script>\Hnewline
<script type="text/javascript" src="/styles/syntaxhighlighter/scripts/shBrushRuby.js"></script>\Hnewline
<script type="text/javascript" src="/styles/syntaxhighlighter/scripts/shBrushPerl.js"></script>\Hnewline
<script type="text/javascript" src="/styles/syntaxhighlighter/scripts/shBrushCpp.js"></script>\Hnewline
<script type="text/javascript" src="/styles/syntaxhighlighter/scripts/shBrushBash.js"></script>\Hnewline
<script type="text/javascript" src="/styles/syntaxhighlighter/scripts/shBrushXml.js"></script>\Hnewline
<script type="text/javascript">SyntaxHighlighter.all()</script>\Hnewline
<link href="/styles/syntaxhighlighter/styles/shCore.css" rel="stylesheet" type="text/css" />\Hnewline
<link href="/styles/syntaxhighlighter/styles/shThemeDefault.css" rel="stylesheet" type="text/css"/>\Hnewline
}}
\makeatletter
\@ifpackageloaded{graphicx}{%
\DeclareGraphicsExtensions{.svg,.png}
%this below to make it resize the SVG image, if it is there, to
%what is in the includegraphics.
%thanks to @Michal.h21 for this trick
\newcommand\emwidth{10}
\newcommand\CalcRem[1]{\strip@pt\dimexpr(#1)/\emwidth}
\Configure{graphics*}
{svg}
{\Picture[pict]{\csname Gin@base\endcsname.svg \space style="width:\CalcRem{\Gin@req@width}em;"}%
\special{t4ht+@File: \csname Gin@base\endcsname.svg}
}
%make sure this below is here, this will make it resize the png image
%to what is in the includegraphics command
\Configure{graphics*}
{png}
{%the special command below so it will copy the png over
\special{t4ht+@File: \csname Gin@base\endcsname.png}
\Picture[pict]{\csname Gin@base\endcsname .png
\space width="\expandafter\the\csname Gin@req@width\endcsname"
}%
}%
}{}
\makeatother
%see https://tex.stackexchange.com/questions/490873/problem-with-vertical-alignment-of-text-and-images-in-long-table-when-using-tex4
\makeatletter
\@ifpackageloaded{adjustbox}{%
\Configure{halignTR}{}
\Configure{AdjustboxValignTop}{\Css{\#TBL-\TableNo-\HRow-{vertical-align:top;}}}
\Configure{AdjustboxValignMiddle}{\Css{\#TBL-\TableNo-\HRow-{vertical-align:middle;}}}
\Configure{AdjustboxValignCenter}{\Css{\#TBL-\TableNo-\HRow-{vertical-align:middle;}}}
\Configure{AdjustboxValignBottom}{\Css{\#TBL-\TableNo-\HRow-{vertical-align:bottom;}}}
}{}
\makeatother
%see https://tex.stackexchange.com/questions/249179/tex4ht-how-to-create-fixed-width-table-columns
\catcode`\:=11
\Configure{halignTD} {}{}
{<}{\HCode{ style="white-space:nowrap; text-align:left;"}}
{-}{\HCode{ style="white-space:nowrap; text-align:center;"}}
{>}{\HCode{ style="white-space:nowrap; text-align:right;"}}
{^}{\HCode{ style="vertical-align:top; white-space:nowrap;"}}
{=}{\HCode{ style="vertical-align:baseline; white-space:nowrap;"}}
{||}{\HCode{ style="vertical-align:middle; white-space:nowrap;"}}
{_}{\HCode{ style="vertical-align:bottom; white-space:nowrap;"}}
{p}{\HCode{ style="white-space:wrap; text-align:left;"}\Protect\a:HColWidth}
{m}{\HCode{ style="white-space:wrap; text-align:left; vertical-align:middle;"}\Protect\a:HColWidth}
{b}{\HCode{ style="white-space:wrap; text-align:left; vertical-align:baseline;"}}
{}
\catcode`\:=12
%see https://tex.stackexchange.com/questions/370308/why-tex4ht-adds-an-extra-newline-when-using-begindescription-after-item
\Css{dl:after {content:"";display:table;clear:both;}}
\Css{dt{float:left;min-width:1em;clear:left;}}
\Css{dd{float:left;}}
\begin{document}
%-------------------------------
%this remove lines above graphics and below them in HTML
\ConfigureEnv{figure}
{\HCode{}}{\HCode{}}{}{}
% This one removes the rulers. Taking a look at html4.4ht should make
% clear what has been changed.
\Configure{float}
{\ifOption{refcaption}{}{\csname par\endcsname\ShowPar \leavevmode}}
{\HCode{}}
{\ifvmode \IgnorePar \fi\EndP \HCode{}\csname par\endcsname\ShowPar}
%----------------------------------
\Css{html{
font-size: 100.0\%;
}}
\Css{body{margin-top: 1em;
margin-bottom: 1em;
width: 92\%;
max-width: 65em;
margin-left: auto;
margin-right: auto;
padding: 0em;
color: \#444;
font-family: arial, sans-serif;
%line-height: 16px;
font-style: normal;
font-size: 1.0em;
%border: 1px solid \#F0F0F0 ;
text-align:left;
background: \#FFFFFF;}}
\Css{li img{vertical-align:middle;}}
\Css{div.caption{text-align:center;}}
\Configure{float}{\csname par\endcsname\ShowPar}
{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="float">}}
{\ifvmode\IgnorePar\fi\EndP\HCode{</div>}\ShowPar}
\Css{table.longtable{margin-left: auto;margin-right:auto;}}
%added august 22, 2020 to force table to have fixed width columns.
%see https://stackoverflow.com/questions/4185814/fixed-table-cell-width
%does not work
%\Css{table.longtable{width:65em; word-break:break-all;}}
%added feb 10, 2019 to center graphics
%see https://tex.stackexchange.com/questions/474282/tex4ht-css-code-works-using-standard-book-class-but-has-no-effect-using-koma-sc
\Css{div.fbox {display:table;margin-left:auto; margin-right: auto;}}
\Css{div.caption{text-align:center;}}
\Css{div.figure img{text-align:center;display:block;margin-left:auto; margin-right: auto;}}
\Css{div.float img{text-align:center;display:block;margin-left:auto; margin-right: auto;}}
\Css{div.fbox img{text-align:center;display:block;margin-left:auto; margin-right: auto;}}
\Css{div.caption table{margin: auto;}}
%added april 7, 2019 to make underline works with mathjax for math. Thanks
%to Michal Hoftich and Bill Hammond
\Css{span.underline {border-bottom: 0.15ex solid black;text-decoration:none;}}
\Css{tr {vertical-align:top;}}
\Css{div.titlepage{text-align:center;}}
%\Css{ td { padding: 10px; }} %bug in texh4t
\EndPreamble
The resulting HTML:
I couldn't tell from your description if you are making those definitions available in the web page using those macros
Yes. This is done via the.cfg
file. It defines the macros/command which go into the web page header (inserted there by tex4ht) and then used by mathjax when the page is loaded. I do not know to how to define these commands there seems to be the problem. The option-c ./nma_mathjax.cfg
loads these macros into the web page.\#1
looks wrong shouldn't that be#1
?#
has to be escaped since in a string. If I do not escape them, tex4ht gives error! Illegal parameter number in definition of \a:MathJaxConfig. <to be read again>
I've used these before in .cfg, and those were escaped also and work.\
in the final javascript config see docs.mathjax.org/en/v2.7-latest/tex.html#defining-tex-macros#
isn't a special character in javascript strings