# MathML conversion not matched with LaTeX output using TeX4ht

My code as follows:

\documentclass{book}
\usepackage{amsmath}
\begin{document}

Test
\left.\begin{array}{c} \displaystyle\sum\limits_{t=0}^{T}\pi \rho^{t}\overset{\textrm{add and subtract 2nd and 3rd terms}}{\overbrace{=\displaystyle\sum\limits_{t=0}^{T}\pi \rho ^{t}+\displaystyle\sum\limits_{t=T+1}^{\infty }\pi \rho ^{t}-\displaystyle\sum\limits_{t=T+1}^{\infty }\pi \rho ^{t}}}\ \ \overset{\textrm{combine first two terms}}{\overbrace{=\displaystyle\sum\limits_{t=0}^{\infty }\pi \rho ^{t}-\displaystyle\sum\limits_{t=T+1}^{\infty }\pi \rho^{t}}} \\\noalign{\vskip6pt} \hspace*{-2pc}\underset{\textrm{factor out }\rho^{T+1}\textrm{ from second term}}{\underbrace{=\displaystyle\sum\limits_{t=0}^{\infty }\pi \rho^{t}-\rho ^{T+1}\displaystyle\sum\limits_{t=0}^{\infty }\pi \rho ^{t}}}\ \ \underset{\begin{smallmatrix}\textrm{use formula for sum of}\\ \textrm{geometric series}\end{smallmatrix}}{\underbrace{=\frac{1-\rho^{T+1}}{1-\rho }\pi }}. \end{array}\right. \label{eq formula geometric series}

\end{document}


And the output came as:

I am converting this to HTML with MathML through the tag

htlatex test "xhtml,mathml,mathml-" " -cunihft" "-cvalidate -p"


Conversion doesn't shows any errors, but the limits for the symbol sum changed to side limits, but I should match the MathML output same as TeX output, i.e., upper and lower limits should as is. Please advise...

• Which web browser do you use to view the html output? Firefix? Chrome? Safari? Something else? Various browsers handle mathml code in surprisingly different ways... – Mico Nov 11 '17 at 7:52
• @Mico I'm using Mozilla for viewing... – MadyYuvi Nov 11 '17 at 7:59

(too long for a comment, hence posted as an answer)

Your math code is rather complex -- dare I say, needlessly complex? Please give the following, modified and simplified form of your code a try. Do you still experience the discrepancy issues described in your query?

\documentclass{book}
\usepackage{amsmath}
% struts for to even out vertical spacing
\newcommand\BigStrutA{\vphantom{\sum_{t=0}^{T}}}
\newcommand\BigStrutB{\vphantom{\sum_{t=0}^{\infty}}}
\begin{document}

Proposed new form:
$$\begin{split} \sum_{t=0}^{T} \pi\rho^{t} &={} \overbrace{\sum_{t=0}^{T} \pi\rho^{t} +\sum_{t=T+1}^\infty \pi\rho^{t} -\sum_{t=T+1}^\infty \pi\rho^{t}}% ^{\textrm{add and subtract 2nd and 3rd terms}} {}={} \overbrace{\sum_{t=0}^\infty \pi\rho^{t} -\sum_{t=T+1}^\infty \pi\rho^{t}\BigStrutA}% ^{\textrm{combine first two terms}} \\ &={} \underbrace{\sum_{t=0}^{\infty} \pi\rho^{t} -\rho^{T+1} \sum_{t=0}^{\infty} \pi\rho^{t}}% _{\substack{\textrm{factor out \rho^{T+1}}\\ \textrm{from 2nd term}}} {}={} \underbrace{\frac{1-\rho^{T+1}}{1-\rho}\,\pi\BigStrutB}% _{\substack{\textrm{formula for}\\ \textrm{sum of geo-\strut}\\ \textrm{metric series}}}. \end{split} \label{eq proposed new form}$$

\medskip
For comparison, the orginal form:
\left.\begin{array}{c} \displaystyle\sum\limits_{t=0}^{T}\pi \rho^{t}\overset{\textrm{add and subtract 2nd and 3rd terms}}{\overbrace{=\displaystyle\sum\limits_{t=0}^{T}\pi \rho ^{t}+\displaystyle\sum\limits_{t=T+1}^{\infty }\pi \rho ^{t}-\displaystyle\sum\limits_{t=T+1}^{\infty }\pi \rho ^{t}}}\ \ \overset{\textrm{combine first two terms}}{\overbrace{=\displaystyle\sum\limits_{t=0}^{\infty }\pi \rho ^{t}-\displaystyle\sum\limits_{t=T+1}^{\infty }\pi \rho^{t}}} \\\noalign{\vskip6pt} \hspace*{-2pc}\underset{\textrm{factor out }\rho^{T+1}\textrm{ from second term}}{\underbrace{=\displaystyle\sum\limits_{t=0}^{\infty }\pi \rho^{t}-\rho ^{T+1}\displaystyle\sum\limits_{t=0}^{\infty }\pi \rho ^{t}}}\ \ \underset{\begin{smallmatrix}\textrm{use formula for sum of}\\ \textrm{geometric series}\end{smallmatrix}}{\underbrace{=\frac{1-\rho^{T+1}}{1-\rho }\pi }}. \end{array}\right. \label{eq orig form}

\end{document}

• Your suggestion works in TeX output, but in HTML+MathML same error only.... – MadyYuvi Nov 11 '17 at 7:58
• @MadyYuvi - It turns out that the "error" is caused by the browser, not the LaTeX code. To wit, if I run your compile sequence and view the html file with Safari instead of Mozilla/Firefox, the summation bounds are placed correctly. Unfortunately, the horizontal braces are not displayed correctly under Safari. In contrast, Mozilla/Firefox actually displays the braces correctly (even though it has problems with displaying the summation bounds). – Mico Nov 11 '17 at 8:40
• to fix mathml rendering issues in various browsers, it is best to use MathJax for rendering, like in this answer of mine: tex.stackexchange.com/a/362207/2891 – michal.h21 Nov 11 '17 at 9:45
• @MadyYuvi it seems that browsers just choose to render it this way, even if MathJax is used. – michal.h21 Nov 11 '17 at 19:03
• @michal.h21 and Mico, thanks a lot for both of your suggestions... – MadyYuvi Nov 13 '17 at 5:29