michal-h21 / make4ht

Build system for tex4ht
139 stars 15 forks source link

Macros do not detect the following space. #152

Open danielezambelli opened 1 week ago

danielezambelli commented 1 week ago

Hi Michal, I started using make4ht again after a long time, but I ran into a problem I had never encountered before. I am sending you a minimal example that compiles perfectly with lualatex, but fails with make4ht.

The versions of lualatex and TexLive are as follows:

$> lualatex --v This is LuaHBTeX, Version 1.18.0 (TeX Live 2025/dev/Debian)

$> texliveonfly --v 1.2

Thanks for your attention.

\documentclass[10pt,a4paper]{memoir}
\usepackage{amsmath, amsthm, amssymb}% amsfonts è caricato da amssymb

\newcommand{\sand}{~ \wedge ~}

\newcommand{\ssRarrow}{\quad \Rightarrow \quad}

\begin{document}
The following lines all work in pdf but not in html.

\medskip
Trovare la mediana delle seguenti serie di osservazioni:\\
a: {3, 4, 6, 7, 10}; \quad 
b: {6, 7, 8, 12, 15, 22}; \qquad 
c: {34, 53, 45, 67, 87, 91, 100, 123, 129, 135}. 

\(\text{Teorema di Pitagora: } \qquad a^2 = b^2 + c^2\)

\(y = \sin x\)

\(\sigma x\)

\sigma x

\[\frac{f_{i;j}}{f_{i;}.}=\frac{f._{;j}}{N} \sand 
  \frac{f_{i;j}}{f._{;j}}=\frac{f_{i;}.}{N} \ssRarrow 
  f_{i;j}=\frac{f_{i;}. \times f._{;j}}{N}\]

\[\forall i,j\colon\; c_{ij}=0 
\ssRarrow\sum_{i=1}^{i=h}\sum_{j=1}^{j=k}\frac{c_{ij}^2}{f_{ ij}}=0\]

\bigskip
These works around work correctly.

\medskip
Trovare la mediana delle seguenti serie di osservazioni:\\
a: {3, 4, 6, 7, 10}; \(\quad\) 
b: {6, 7, 8, 12, 15, 22}; \(\qquad\) 
c: {34, 53, 45, 67, 87, 91, 100, 123, 129, 135}. 

\(\text{Teorema di Pitagora: } {\qquad} a^2 = b^2 + c^2\)

\(y = {\sin} x\)

\({\sigma} x\)

\(\sigma\) x

\[\frac{f_{i;j}}{f_{i;}.}=\frac{f._{;j}}{N} {\sand} 
  \frac{f_{i;j}}{f._{;j}}=\frac{f_{i;}.}{N} {\ssRarrow} 
  f_{i;j}=\frac{f_{i;}. {\times} f._{;j}}{N}\]

\[{\forall} i,j\colon\; c_{ij}=0 
\ssRarrow\sum_{i=1}^{i=h}\sum_{j=1}^{j=k}\frac{c_{ij}^2}{f_{ ij}}=0\]

\end{document}
michal-h21 commented 1 week ago

Hi Danielle, I only get the error with this command: \sigma x, used outside the math mode on line 23. I think it is an error, but you are right that LuaLaTeX compiles it without errors. When I compile it with the -l option of make4ht, which requires LuaLaTeX backend, it compiles without error too.

I get the error only in the default PDFLaTeX mode. And I get an error also with PDFLaTeX, so the behavior of make4ht seems to be the same.

danielezambelli commented 1 week ago

Compiling with:

make4ht macro.tex -c ml_make4ht -l -u -s -d ./html/mathjax2 "mathjax, 2, sec-filename, fn-in, blind"

I get the following html file:

<!DOCTYPE html> 
<html lang='en-US' xml:lang='en-US'> 
<head> <title></title> 
<meta charset='utf-8' /> 
<meta content='TeX4ht (https://tug.org/tex4ht/)' name='generator' /> 
<meta content='width=device-width,initial-scale=1' name='viewport' /> 
<link href='macro.css' rel='stylesheet' type='text/css' /> 
<meta content='macro.tex' name='src' /> 
<script>window.MathJax = { tex: { tags: "ams", packages: {'[+]': ['html','enclose']}, macros: { uline: ["\\enclose{bottom}{#1}",1], uuline: ["\\enclose{bottom}{\\enclose{bottom}{#1}}",1], uwave: ["#1",1], sout: ["\\enclose{horizontalstrike}{#1}",1], xout: ["\\enclose{bottom}{\\enclose{horizontalstrike}{#1}}",1], dashuline: ["\\style{border-bottom:1px dashed black;}{#1}",1], dotuline: ["\\style{border-bottom:1px dotted black;}{#1}",1], N: "\\mathbb{N}", Nz: "\\mathbb{N}^0", Z: "\\mathbb{Z}", Zz: "\\mathbb{Z}^0", Q: "\\mathbb{Q}", Qz: "\\mathbb{Q}^0", Qp: "\\mathbb{Q}^+", J: "\\mathbb{J}", R: "\\mathbb{R}", Rz: "\\mathbb{R}^0", Rp: "\\mathbb{R}^+", C: "\\mathbb{C}", IN: "{}^*\\hspace{-.12em}\\mathbb{N}", IZ: "{}^*\\hspace{-.12em}\\mathbb{Z}", IR: "{}^*\\hspace{-.12em}\\mathbb{R}", IC: "{}^*\\hspace{-.12em}\\mathbb{C}", A: "\\mathbb{A}", K: "\\mathbb{K}", Dispari: "\\mathbb{D}", Pari: "\\mathbb{P}", Pol: "\\mathbb{P}", epsilon: "\\varepsilon", theta: "\\vartheta", rho: "\\varrho", phi: "\\varphi", tonda: ["\\left(#1\\right)", 1], quadra: ["\\left[#1\\right]", 1], rquadra: ["\\left]#1\\right[", 1], graffa: ["\\left\\{#1\\right\\}", 1], abs: ["\\left\\lvert#1\\right\\lvert", 1], valass: ["\\left\\lvert#1\\right\\lvert", 1], angolare: ["\\left\\langle#1\\right\\rangle", 1], pint: ["\\left\\lfloor#1\\right\\rfloor", 1], compreso: ["~[#1]~", 1], escluso: ["~]#1[~", 1], sistema: ["\\left\\{\\begin{array}{lcl}#1\\end{array}\\right.", 1], fatratti: ["\\left\\{\\begin{array}{rclcl}#1\\end{array}\\right.", 1], matrice: ["\\begin{bmatrix}#1\\end{bmatrix}", 1], determ: ["\\begin{vmatrix}#1\\end{vmatrix}", 1], vect: ["\\overrightarrow{#1}", 1], coppia: ["\\tonda{#1;~#2}", 2], terna: ["\\tonda{#1;~#2;~#3}", 3], punto: ["#1\\tonda{#2;~#3}", 3], dist: ["\\mathcal{D}\\coppia{#1}{#2}", 2], lung: ["\\mathcal{L}\\coppia{#1}{#2}", 2], area: ["\\mathcal{A}_{#1}", 1], duep: "\\!:~", intervcc: ["\\left[#1;~#2\\right]", 2], intervac: ["\\left]#1;~#2\\right]", 2], intervca: ["\\left[#1;~#2\\right[", 2], intervaa: ["\\left]#1;~#2\\right[", 2], sand: "~ \\wedge ~", sor: "~ \\vee ~", scap: "~ \\cap ~", scup: "~ \\cup ~", svert: "~ \\vert ~", sLarrow: "~ \\Leftarrow ~", ssLarrow: "\\quad \\Leftarrow \\quad", sLRarrow: "~ \\Leftrightarrow ~", ssLRarrow: "\\quad \\Leftrightarrow \\quad", sRarrow: "~ \\Rightarrow ~", ssRarrow: "\\quad \\Rightarrow \\quad", slarrow: "~ \\leftarrow ~", sslarrow: "\\quad \\leftarrow \\quad", slrarrow: "~ \\leftrightarrow ~", sslrarrow: "\\quad \\leftrightarrow \\quad", srarrow: "~ \\rightarrow ~", ssrarrow: "\\quad \\rightarrow \\quad", stext: ["~~\\text{#1}~~", 1], sstext: ["\\quad\\text{#1}\\quad", 1], Dom: "\\mathcal{D}", ID: "\\mathrm{I.D.}", Cod: "\\mathcal{C}", II: "\\mathrm{I.I.}", CE: "\\mathrm{C.E.}", IS: "\\mathrm{I.S.}", dd: "\\mathrm{d}", dx: "\\mathrm{d}x", Deriv: ["\\mathit{D}\\quadra{#1}", 1], fstar: ["{}^*\\hspace{-.15em}#1", 1], sen: "\\sin", tg: "\\tan", Log: "\\mathrm{Log}", ost: "\\mathrm{st}", st: ["\\ost \\tonda{#1}", 1], omon: "\\mathrm{mon}", mon: ["\\omon \\tonda{#1}", 1], oGal: "\\mathrm{Gal}", Gal: ["\\oGal \\tonda{#1}", 1], infvic: "\\approx", indist: "\\sim", Kor: "\\mathbf{K}", Rel: "\\mathfrak{R}", divint: "\\;\\mathrm{div}\\;", Mod: "\\;\\mathrm{mod}\\;", mcd: "\\mathrm{MCD}", mcm: "\\mathrm{mcm}", card: "\\mathrm{card}", Area: "\\mathrm{Area}", vari: "\\mathrm{Var}", cfvar: "\\mathrm{CV}", cvar: "\\mathrm{CVar}", spV: "\\mathbf{V}", media: "\\mathrm{media}", mediana: "\\mathrm{mediana}", moda: "\\mathrm{moda}", cels: "{}^\\circ\\hspace{-.10em}\\mathrm{C}", grado: "{}^{\\circ}", meuro: "\\, \\text{€}", munit: ["\\, \\mathrm{#1}", 1], qed: "q.e.d.", Ast: "{}^{\\ast}", aC: "a.C.", dC: "d.C.", aev: "a.C.", paev: "d.C.", unit: "\\,", relax: "", } } }  //}}</script> 
 <script async='async' id='MathJax-script' src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js' type='text/javascript'></script>  
</head><body>
<!-- l. 9 --><p class='noindent'>The following lines all work in pdf but not in html.
</p><!-- l. 12 --><p class='indent'>   Trovare la mediana delle seguenti serie di osservazioni:<br class='newline' />a: 3, 4, 6, 7, 10;    b: 6, 7, 8, 12, 15, 22;       c: 34, 53, 45, 67, 87, 91, 100, 123, 129,
135.
</p><!-- l. 17 --><p class='indent'>   \(\text{Teorema di Pitagora: } \qquada^2 = b^2 + c^2\)
</p><!-- l. 19 --><p class='indent'>   \(y = \sinx\)
</p><!-- l. 21 --><p class='indent'>   \(\sigmax\)
</p><!-- l. 23 --><p class='indent'>   x
</p><!-- l. 27 --><p class='indent'>   \[\frac{f_{i;j}}{f_{i;}.}=\frac{f._{;j}}{N} \sand\frac{f_{i;j}}{f._{;j}}=\frac{f_{i;}.}{N} \ssRarrowf_{i;j}=\frac{f_{i;}. \timesf._{;j}}{N}\]
</p><!-- l. 30 --><p class='indent'>   \[\foralli,j\colon\; c_{ij}=0 \ssRarrow\sum_{i=1}^{i=h}\sum_{j=1}^{j=k}\frac{c_{ij}^2}{f_{ ij}}=0\]
</p><!-- l. 33 --><p class='indent'>   These works around work correctly.
</p><!-- l. 36 --><p class='indent'>   Trovare la mediana delle seguenti serie di osservazioni:<br class='newline' />a: 3, 4, 6, 7, 10; \(\quad\) b: 6, 7, 8, 12, 15, 22; \(\qquad\) c: 34, 53, 45, 67, 87, 91, 100, 123, 129,
135.
</p><!-- l. 41 --><p class='indent'>   \(\text{Teorema di Pitagora: } {\qquad} a^2 = b^2 + c^2\)
</p><!-- l. 43 --><p class='indent'>   \(y = {\sin} x\)
</p><!-- l. 45 --><p class='indent'>   \({\sigma} x\)
</p><!-- l. 47 --><p class='indent'>   \(\sigma\) x
</p><!-- l. 51 --><p class='indent'>   \[\frac{f_{i;j}}{f_{i;}.}=\frac{f._{;j}}{N} {\sand} \frac{f_{i;j}}{f._{;j}}=\frac{f_{i;}.}{N} {\ssRarrow} f_{i;j}=\frac{f_{i;}. {\times} f._{;j}}{N}\]
</p><!-- l. 54 --><p class='indent'>   \[{\forall} i,j\colon\; c_{ij}=0 \ssRarrow\sum_{i=1}^{i=h}\sum_{j=1}^{j=k}\frac{c_{ij}^2}{f_{ ij}}=0\]
</p>   

</body> 
</html>

The configuration file is:

\Preamble{xhtml}

%\renewenvironment{alternativetext}[1]{\Configure{Picture-alt}{#1}}{}

\catcode`\:=11
\Configure{underbrace}
   {\Configure{mathop*}{*}
         {<\a:mathml munder
                 \a:mathml accentunder="false"><\a:mathml mrow>}
         {</\a:mathml mrow><\a:mathml mo>\string
               &\#x23DF;</\a:mathml mo></\a:mathml munder>}
         {\Configure{mathop}{}{}{}{}}%
   }
   {\let\o:underbrace:=\displaystyle}
   {}
\Configure{overrightarrow}
  {\leavevmode\hbox\bgroup$\Tg<\a:mathml mover accent="true" class="overrightarrow">%
   \Tg<\a:mathml mrow\Hnewline>\:gobble}
  {\Tg</\a:mathml mrow>\HCode{<\a:mathml mo>&\#x2192;</\a:mathml mo>}%
   \Tg</\a:mathml mover>$\egroup}
\Configure{overleftarrow}
  {\leavevmode\hbox\bgroup$\Tg<\a:mathml mover accent="true" class="overleftarrow">%
   \Tg<\a:mathml mrow\Hnewline>\:gobble}
  {\Tg</\a:mathml mrow>\HCode{<\a:mathml mo>&\#x2190;</\a:mathml mo>}%
   \Tg</\a:mathml mover>$\egroup}

\catcode`\:=12

\makeatletter
\@ifpackageloaded{ulem}{%
\Configure{uline}
   {\HCode{<span class="uline">}\NoFonts} {\EndNoFonts\HCode{</span>}}
\Configure{uline-math}
   {\HCode{<span class="uline">}\NoFonts} {\EndNoFonts\HCode{</span>}}
\Css{.uline,.uline-math{ text-decoration:underline; }}
\Configure{uuline}
   {\HCode{<span class="uuline">}\NoFonts} {\EndNoFonts\HCode{</span>}}
\Configure{uuline-math}
   {\HCode{<span class="uuline">}\NoFonts} {\EndNoFonts\HCode{</span>}}
\Css{.uuline,.uuline-math{ text-decoration:underline double; }}
\Configure{sout}
   {\HCode{<span class="sout">}\NoFonts} {\EndNoFonts\HCode{</span>}}
\Configure{sout-math}
   {\HCode{<span class="sout">}\NoFonts} {\EndNoFonts\HCode{</span>}}
\Css{span.sout, .sout-math {text-decoration: line-through }}
\Configure{xout}
   {\HCode{<span class="xout">}\NoFonts} 
   {\EndNoFonts\HCode{</span>}}
\Configure{xout-math}
   {\HCode{<span class="xout-math">}\NoFonts} 
   {\EndNoFonts\HCode{</span>}}
\Css{span.xout, .xout-math {text-decoration: line-through underline }}
\Configure{uwave}
   {\HCode{<span class="uwave">}\NoFonts} 
   {\EndNoFonts\HCode{</span>}}
\Configure{uwave-math}
   {\HCode{<span class="uwave-math">}\NoFonts} 
   {\EndNoFonts\HCode{</span>}}
\Css{span.uwave, .uwave-math {text-decoration:underline wavy; }}
\Configure{dashuline}
   {\HCode{<span class="dashuline">}\NoFonts} 
   {\EndNoFonts\HCode{</span>}}
\Configure{dashuline-math}
   {\HCode{<span class="dashuline-math">}\NoFonts} 
   {\EndNoFonts\HCode{</span>}}
\Css{span.dashuline, .dashuline-math {text-decoration:underline dashed;}}
\Configure{dotuline}
   {\HCode{<span class="dotuline">}\NoFonts} 
   {\EndNoFonts\HCode{</span>}}
\Configure{dotuline-math}
   {\HCode{<span class="dotuline-math">}\NoFonts} 
   {\EndNoFonts\HCode{</span>}}
\Css{span.dotuline, .dotuline-math {text-decoration:underline dotted;}}
}{}
\makeatother

\ifcsname a:MathJaxConfig\endcsname

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Configurations for MathJax %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\catcode`\#=11 
\Configure{MathJaxConfig}{{ 
  tex: { 
    tags: "ams", 
    packages: {'[+]': ['html','enclose']},
    \detokenize{% 
      macros: { 
        uline: ["\\enclose{bottom}{#1}",1], 
        uuline: ["\\enclose{bottom}{\\enclose{bottom}{#1}}",1],  
        uwave: ["#1",1], 
%         uwave: ["\\enclose{bottom}{#1}",1],
%         uwave: ["\\style{border-bottom:1px underline wavy black;}{#1}",1], 
        sout: ["\\enclose{horizontalstrike}{#1}",1], 
        xout: ["\\enclose{bottom}{\\enclose{horizontalstrike}{#1}}",1], 
        dashuline: ["\\style{border-bottom:1px dashed black;}{#1}",1], 
        dotuline: ["\\style{border-bottom:1px dotted black;}{#1}",1], 
%%%% Insiemi numerici %%%%
        N: "\\mathbb{N}", 
        Nz: "\\mathbb{N}^0",
        Z: "\\mathbb{Z}",
        Zz: "\\mathbb{Z}^0",
        Q: "\\mathbb{Q}",
        Qz: "\\mathbb{Q}^0",
        Qp: "\\mathbb{Q}^+",
        J: "\\mathbb{J}",
        R: "\\mathbb{R}",
        Rz: "\\mathbb{R}^0",
        Rp: "\\mathbb{R}^+",
        C: "\\mathbb{C}",
        IN: "{}^*\\hspace{-.12em}\\mathbb{N}",
        IZ: "{}^*\\hspace{-.12em}\\mathbb{Z}",
        IR: "{}^*\\hspace{-.12em}\\mathbb{R}",
        IC: "{}^*\\hspace{-.12em}\\mathbb{C}",
        A: "\\mathbb{A}",
        K: "\\mathbb{K}",
        Dispari: "\\mathbb{D}",
        Pari: "\\mathbb{P}",
        Pol: "\\mathbb{P}",
%%%% Lettere greche in corsivo %%%%
        epsilon: "\\varepsilon",
        theta: "\\vartheta",
        rho: "\\varrho",
        phi: "\\varphi",
%%%% Delimitatori e parentesi %%%%
        tonda: ["\\left(#1\\right)", 1],
        quadra: ["\\left[#1\\right]", 1],
        rquadra: ["\\left]#1\\right[", 1],
        graffa: ["\\left\\{#1\\right\\}", 1],
        abs: ["\\left\\lvert#1\\right\\lvert", 1],
        valass: ["\\left\\lvert#1\\right\\lvert", 1],
        angolare: ["\\left\\langle#1\\right\\rangle", 1],
        pint: ["\\left\\lfloor#1\\right\\rfloor", 1],
        compreso: ["~[#1]~", 1],
        escluso: ["~]#1[~", 1],
%%%% Sistemi, vettori, punto %%%%
        sistema: ["\\left\\{\\begin{array}{lcl}#1\\end{array}\\right.", 1],
        fatratti: ["\\left\\{\\begin{array}{rclcl}#1\\end{array}\\right.", 1],
        matrice: ["\\begin{bmatrix}#1\\end{bmatrix}", 1],
        determ: ["\\begin{vmatrix}#1\\end{vmatrix}", 1],
%         vettore: ["\\left(\\begin{array}{c}#1\\end{array}\\right)", 1],
%         matrice: ["\\tonda{\\begin{array}{#1}#2\\end{array}}", 2],
        vect: ["\\overrightarrow{#1}", 1],
        coppia: ["\\tonda{#1;~#2}", 2],
        terna: ["\\tonda{#1;~#2;~#3}", 3],
        punto: ["#1\\tonda{#2;~#3}", 3],
        dist: ["\\mathcal{D}\\coppia{#1}{#2}", 2],
        lung: ["\\mathcal{L}\\coppia{#1}{#2}", 2],
        area: ["\\mathcal{A}_{#1}", 1],
        duep: "\\!:~",
%%%% Intervalli %%%%
        intervcc: ["\\left[#1;~#2\\right]", 2],
        intervac: ["\\left]#1;~#2\\right]", 2],
        intervca: ["\\left[#1;~#2\\right[", 2],
        intervaa: ["\\left]#1;~#2\\right[", 2],
%%%% Aggiunta di spazi ad alcuni operatori %%%%
        sand: "~ \\wedge ~",
        sor: "~ \\vee ~",
        scap: "~ \\cap ~",
        scup: "~ \\cup ~",
        svert: "~ \\vert ~",
        sLarrow: "~ \\Leftarrow ~",
        ssLarrow: "\\quad \\Leftarrow \\quad",
        sLRarrow: "~ \\Leftrightarrow ~",
        ssLRarrow: "\\quad \\Leftrightarrow \\quad",
        sRarrow: "~ \\Rightarrow ~",
        ssRarrow: "\\quad \\Rightarrow \\quad",
        slarrow: "~ \\leftarrow ~",
        sslarrow: "\\quad \\leftarrow \\quad",
        slrarrow: "~ \\leftrightarrow ~",
        sslrarrow: "\\quad \\leftrightarrow \\quad",
        srarrow: "~ \\rightarrow ~",
        ssrarrow: "\\quad \\rightarrow \\quad",
        stext: ["~~\\text{#1}~~", 1],
        sstext: ["\\quad\\text{#1}\\quad", 1],
%%%% Funzioni, derivate %%%%
        Dom: "\\mathcal{D}",
        ID: "\\mathrm{I.D.}",
        Cod: "\\mathcal{C}",
        II: "\\mathrm{I.I.}",
        CE: "\\mathrm{C.E.}",
        IS: "\\mathrm{I.S.}",
        dd: "\\mathrm{d}",
        dx: "\\mathrm{d}x",
        Deriv: ["\\mathit{D}\\quadra{#1}", 1],
%         effestar: "{}^*\\hspace{-.15em}f",
        fstar: ["{}^*\\hspace{-.15em}#1", 1],
%%%% Funzioni circolari %%%%
        sen: "\\sin",
        tg: "\\tan",
        Log: "\\mathrm{Log}",
%%%% Iperreali %%%%
        ost: "\\mathrm{st}",
        st: ["\\ost \\tonda{#1}", 1], 
        omon: "\\mathrm{mon}",
        mon: ["\\omon \\tonda{#1}", 1],
        oGal: "\\mathrm{Gal}",
        Gal: ["\\oGal \\tonda{#1}", 1],
        infvic: "\\approx",
        indist: "\\sim",
%%%% Insiemi e numeri %%%%
        Kor: "\\mathbf{K}",
        Rel: "\\mathfrak{R}",
        divint: "\\;\\mathrm{div}\\;",
        Mod: "\\;\\mathrm{mod}\\;",
        mcd: "\\mathrm{MCD}",
        mcm: "\\mathrm{mcm}",
        card: "\\mathrm{card}",
        Area: "\\mathrm{Area}",
%%%% Statistica %%%%
        vari: "\\mathrm{Var}",
        cfvar: "\\mathrm{CV}",
        cvar: "\\mathrm{CVar}",
        spV: "\\mathbf{V}",
        media: "\\mathrm{media}",
        mediana: "\\mathrm{mediana}",
        moda: "\\mathrm{moda}",
%%%% Unità di misura %%%%
        cels: "{}^\\circ\\hspace{-.10em}\\mathrm{C}",
        grado: "{}^{\\circ}",
        meuro: "\\, \\text{€}",
        munit: ["\\, \\mathrm{#1}", 1],
%%%% Varie %%%%
        qed: "q.e.d.",
        Ast: "{}^{\\ast}",
        aC: "a.C.",
        dC: "d.C.",
        aev: "a.C.",
        paev: "d.C.",
        unit: "\\,",
        relax: "",
      } 
    } 
  } 
} 
//}}}
\catcode`\#=6 

\else

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% code for MathML            %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\fi

\begin{document} 
\EndPreamble
michal-h21 commented 1 week ago

Ah, I can see it now. Try to add these definitions to your config file:

\def\quad{\HCode{<span class="quad"></span>}}
\Css{.quad{min-width: 2rem;display: inline-block;}}
\def\qquad{\HCode{<span class="qquad"></span>}}
\Css{.qquad{min-width: 3rem;display: inline-block;}}
\def\sigma{\HCode{<i>&sigma;</i>}}

This will have an effect on these commands used outside of the math mode.

danielezambelli commented 1 week ago

But I get: \text{Teorema di Pitagora: } \qquada^2 = b^2 + c^2 instead of: \text{Teorema di Pitagora: } \qquad a^2 = b^2 + c^2

michal-h21 commented 1 week ago

Ah, you shouldn't get that with the current TeX4ht code, but there was a bug that could lead to this. I fixed it a month ago.

danielezambelli commented 1 week ago

How can I install the correct version?

michal-h21 commented 1 week ago

If you use TeX Live, tlmgr update --all should suffice. The correct version of mathjax-latex-4ht.4ht (you can find the location using kpsewhich mathjax-latex-4ht.4ht) should be:

  % mathjax-latex-4ht.4ht (2024-09-27-09:25), generated from tex4ht-mathjax.tex
danielezambelli commented 1 week ago

Unfortunately, both sudo tlmgr update --all and tlmgr update --all

give as a result:

(running on Debian, switching to user mode!) (see /usr/share/doc/texlive-base/README.tlmgr-on-Debian.md) TLPDB: not a directory, not loading: /root/texmf tlmgr: user mode not initialized, please read the documentation!

And I couldn't get out of it from here.

I searched at https://github.com/michal-h21/make4ht/tree/master for the file mathjax-latex-4ht.4ht, to replace it directly in the dir tex4ht but couldn't find it.

Can you give me any hints?

Thanks.

michal-h21 commented 1 week ago

Ah, so you use TL in your distro, so you cannot use tlmgr directly. I think Debian is a bit slower in picking up updates, but I hope they will do it eventually.

In the meantime, here is the up-to-date mathjax-latex-4ht.4ht file:

% mathjax-latex-4ht.4ht (2024-09-27-09:25), generated from tex4ht-mathjax.tex
% Copyright 2018-2024 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
%   https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <https://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\immediate\write-1{version 2024-09-27-09:25}

\ExplSyntaxOn
\cs_new_protected:Npn \alteqtoks #1
{
  \tl_set:Ne \l_tmpa_tl {\detokenize{#1}}
  % % replace < > and & with xml entities
  \regex_replace_all:nnN { \x{26} } { &amp; } \l_tmpa_tl
  \regex_replace_all:nnN { \x{3C} } { &lt; } \l_tmpa_tl
  \regex_replace_all:nnN { \x{3E} } { &gt; } \l_tmpa_tl
  % replace \par command with blank lines
  \regex_replace_all:nnN { \x{5C}par\b } {\x{A}\x{A}} \l_tmpa_tl
  \tl_set:Ne \l_tmpb_tl{ \l_tmpa_tl }
  \HCode{\l_tmpb_tl}
}
\ExplSyntaxOff

\NewConfigure{MathJaxConfig}{1}
\NewConfigure{MathJaxMacros}[1]{%
\Configure{@BODY}{\bgroup\NoFonts\ttfamily\detokenize{\(}%
  \special{t4ht*<#1}%
\detokenize{\)}\EndNoFonts\egroup}%
}

\long\def\AltlMath#1\){\expandafter\alteqtoks{\(#1\)}\)}
\long\def\AltlDisplay#1\]{\alteqtoks{\[#1\]}\]}
\long\def\AltMathOne#1${\alteqtoks{\(#1\)}$}
% this seems a bit hacky -- we need to skip some code inserted at the
% beginning of each display math
\long\def\AltlDisplayDollars#1$${\alteqtoks{\[#1\]}$$}

\NewConfigure{MathjaxEnv}{2}

\newcommand\VerbMathToks[2]{%
  \a:MathjaxEnv%
  \HCode{\string\begin{#2}}%
    \alteqtoks{#1}%
  \HCode{\string\end{#2}}%
  \b:MathjaxEnv%
}
\ExplSyntaxOn
\seq_new:N\:savedmathjaxenvs

\newcommand\:savemathjaxenv[1]{%
  \seq_gput_right:Nn\:savedmathjaxenvs{#1}
  \expandafter\let\csname mathjax-#1\expandafter\endcsname\csname #1\endcsname%
  \expandafter\let\csname mathjax-end#1\expandafter\endcsname\csname end#1\endcsname%
}

% we must not reintroduce the matrix environmeint in TikZ, because it interferes with the \matrix command
\newcommand\:ignoretikzmatrix{\seq_remove_all:Nn\:savedmathjaxenvs{matrix}}

\newcommand\RestoreMathJaxEnvironment[1]{%
  \expandafter\let\csname #1\expandafter\endcsname\csname mathjax-#1\endcsname%
  \expandafter\let\csname end#1\expandafter\endcsname\csname mathjax-end#1\endcsname%
}

\newcommand\RestoreMathJaxEnvironments{%
  \seq_map_function:NN\:savedmathjaxenvs\RestoreMathJaxEnvironment%
}
\ExplSyntaxOff
\ExplSyntaxOn
\cs_generate_variant:Nn \regex_extract_once:nnNTF {nV}
\newcommand\VerbMath[2][]{%
  \cs_if_exist:cTF{#2}{
    \:savemathjaxenv{#2}%
    \RenewDocumentEnvironment{#2}{+!b}{%
      \NoFonts\expandafter\VerbMathToks\expandafter{\detokenize{##1}}{#2}\EndNoFonts%
      \ifx\relax#1\relax\else%
      \refstepcounter{#1}%
      \regex_extract_once:nVNTF { label\s* \x{7B}([^\x{7D}]*)\x{7D}} {\l_tmpb_tl} \l_tmp_seq {\label{\seq_item:Nn\l_tmp_seq{2}}} {}%
      \fi
    }{}
  }{}%
}
\ExplSyntaxOff
\def\fixmathjaxtoc#1{\Configure{writetoc}{\def#1{\detokenize{#1}}}}

\AtBeginDocument{%
\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]{equation}
\VerbMath{equation*}
\VerbMath{math}
\VerbMath{displaymath}
\VerbMath{eqnarray}
\VerbMath{eqnarray*}
\ConfigureEnv{gather}{}{}{}{}
\ConfigureEnv{gather*}{}{}{}{}
\ConfigureEnv{multline}{}{}{}{}
\ConfigureEnv{multline*}{}{}{}{}
\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
\fixmathjaxtoc\ln
\fixmathjaxtoc\sum
\fixmathjaxtoc\(
\fixmathjaxtoc\)
\fixmathjaxtoc\begin
\fixmathjaxtoc\end
\fixmathjaxtoc\\
\fixmathjaxtoc\exp
\fixmathjaxtoc\left
\fixmathjaxtoc\right

\@ifpackageloaded{mhchem}{%
\def\:tempa#1{\texttt{\detokenize{\(\ce{#1}\)}}}
\HLet\ce\:tempa
}{}

\@ifpackageloaded{tikz}{%
\tikzset{every picture/.append code={\:ignoretikzmatrix\RestoreMathJaxEnvironments}}
}{}

}
\endinput
danielezambelli commented 6 days ago

Thanks for your expertise and helpfulness!

michal-h21 commented 6 days ago

You are welcome! I hope TL in Debian will get the fixed version soon.