[Tex/LaTex] LaTeX to HTML – Square roots

htmlmath-modetex4ht

I used SimpleTeX4ht to convert a LaTeX file to HTML. The file is fine except that square roots are rendering badly in juxtaposition with the rest of the text, e.g. like:

like this

Any suggestions on how to get the square roots to render better? (Whether by using a different converter, using different LaTeX, etc.)

My LaTeX code is

\noindent \textbf{Example:} Failure of unique prime factorization in $\mathbb{Z}[\sqrt{-5}\hspace{0.1 cm}]$:\\
 $6 = (1 + \sqrt{-5})\cdot (1 + \sqrt{-5}) = 2 \cdot 3$.\

and the corresponding HTML is something like

<!--l. 269--><p class="noindent" ><span 
class="cmbx-12">Example: </span>Failure of unique prime factorization in <span 
class="msbm-10x-x-120">&#x2124;</span>[<img 
src="Fermat10x.png" alt="&#x221A; --5"  class="sqrt" > ]:<br 
class="newline" />6 = (1 + <img 
src="Fermat11x.png" alt="&#x221A; ---
  - 5"  class="sqrt" >) <span 
class="cmsy-10x-x-120">&#x22C5; </span>(1 + <img 
src="Fermat12x.png" alt="&#x221A; ---
  - 5"  class="sqrt" >) = 2 <span 
class="cmsy-10x-x-120">&#x22C5; </span>3.<br 
class="newline" />

Best Answer

The previous two answers have already addressed your immediate query. However, I would like to add that may be you should try pandocHomepage. It can convert various formats like latex, html, xhtml, html5, docx, odt, epub, conTeXt etc. into each other. My experience has been pleasant. However, installation of pandoc requires haskell platform which took nearly 350MB of space on ubuntu 12.04.

For a good rendering of math in html, I think that mathjax is the way to go. It is supported by most browsers. It can handle most of the latex math environments. One drawback though is the slow loading of the webpages with a lot of math.

I used:

pandoc -s --mathjax a.tex -o a.html

to get

enter image description here

Personally, I have converted my PhD Thesis with a lot of math into html using pandoc which also handles bibliographies.

EDIT: Major bugs regarding math environments have been addressed in pandoc v1.9.2. The example above uses the latest version 1.9.4.5. Ubuntu repository has older versions. Hence, it is recommended that the latest versions be installed from haskell repository for best results.