2

My test.tex MWE is:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{mathtools}

\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam a aliquam nisi, eu efficitur erat. Vivamus sagittis quis erat ut volutpat. Pellentesque venenatis convallis dignissim. Integer ullamcorper dolor et ornare sodales.

\par The visible samples of the input are $x_s(t) = 0.5\delta(t) -2.8\delta(t-ts) + 1.3\delta(t-2ts)+ 3.5\delta(t-3ts) -1.7\delta(t-4ts) + 1.1\delta(t-5ts) + 4\delta(t-6ts)$. 
Their corresponding output values are $x[n] = 0.5\delta[n] -2.8\delta[n-1] + 1.3\delta[n-2]+ 3.5\delta[n-3] -1.7\delta[n-4] + 1.1\delta[n-5] + 4\delta[n-6]$.

\end{document}

When I compile using 'pdflatex test.tex' I got everything justified because the math is breaking in two lines:

pdflatex output

But when compiling with 'make4ht test.tex -c make4ht.cfg -d html "mathml, mathjax"', the HTML output is like that:

HTML output

The make4ht.cfg file used is based on this answer, with some CSS modifications:

\Preamble{xhtml} 

% Fix math input errors when using mathml + mathjax + amsmath packages
\catcode`\:=11
\Configure{qopname}
   {\Configure{mathop}{*}
      {<\a:mathml mtext \mml:class="qopname">}
  {</\a:mathml mtext><mo> &\#x2061;<!--FUNCTION APPLICATION--> </mo>}
      {}}
\catcode`\:=12

\Css{body{  
    text-align: justify;
    margin:40px auto;  
    max-width:36em;  
    line-height:1.5;  
    font-size: 0.88em;  
    color:\#222;  
    background-color:\#FEFEF7;  
    padding:0 10px;}}  

\begin{document} 

\EndPreamble

There is any way to fix the HTML output?

1
  • mathjax doesn't linebreak inline math as far as I recall. Commented Nov 27, 2023 at 14:42

1 Answer 1

2

Line breaking in MathML doesn't work correctly, both in Firefox and in MathJax. Version 4 of MathJax should support linebreaking, but I cannot get it to work.

You can try it the beta version of MathJax 4 with this configuration file:

\Preamble{xhtml}
% Fix math input errors when using mathml + mathjax + amsmath packages
\catcode`\:=11
\Configure{qopname}
   {\Configure{mathop}{*}
      {<\a:mathml mtext \mml:class="qopname">}
  {</\a:mathml mtext><mo> &\#x2061;<!--FUNCTION APPLICATION--> </mo>}
      {}}
\catcode`\:=12

\Css{body{  
    text-align: justify;
    margin:40px auto;  
    max-width:36em;  
    line-height:1.5;  
    font-size: 0.88em;  
    color:\#222;  
    background-color:\#FEFEF7;  
    padding:0 10px;}}  

\Configure{MathJaxSource}{https://cdn.jsdelivr.net/npm/[email protected]/tex-mml-chtml.js}
\begin{document}
\EndPreamble

Link to the beta version is given in the MathJaxSource configuration.

It adds a new menu when you right click on the math content, suggesting that line breaking should work:

enter image description here

But it doesn't seem to do anything, unfortunately.

2
  • I tried V 4 beta of mathjax, using the command you showed above. Tried it on small document. Found V 3 is much better. in V 3.0, fonts are darker, more crisp, easier to read, and do not have small variation in weight. Also I see some letters have extra trailing _ at the end for some reason in V 4. I guess because this is still beta. Here is screen shot 12000.org/tmp/mathjax_4_beta/mathjax_V4_beta_vs_V3.png so you can see. Will try again whenever the final V 4 is out. This is one Brave browser. I should try other browsers to see if that makes difference.
    – Nasser
    Commented Dec 1, 2023 at 9:58
  • @Nasser I guess these things can change in the released version, hopefully :)
    – michal.h21
    Commented Dec 1, 2023 at 10:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .