[Tex/LaTex] Convert LaTeX to HTML

conversionhtmllatex2htmlpdftex

Is there a converter that will convert LaTeX to HTML? I have tried several services but the LaTeX diagrams and some of the maths came out weird.

I actually converted the Latex to PDF without a problem. Then I used an online PDF to HTML converter to convert from PDF to HTML. The square root signs did not appear properly and some of the Cartesian coordinate plane diagrams had nothing on them except the grid.

\documentclass[12pt,a4paper]{report}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{pstricks,pst-plot}
\usepackage{pst-eucl}
\addtolength{\hoffset}{0.2cm}
\addtolength{\textwidth}{1.1cm}
\addtolength{\textheight}{1.0cm}
\addtolength{\voffset}{-0.7cm}
\linespread{1.3}
\begin{document}

If $x$ is non-positive then $x \leq -\sqrt{\frac{1}{2}}$     $\hspace{30 mm} $     (6)\\

(4) and (6) tell us that\\

(4)  $-1 \leq x \leq 0$  \\

(6)  If $x$ is non-positive then $x \leq -\sqrt{\frac{1}{2}}$\\

Therefore $-1 \leq x \leq -\sqrt{\frac{1}{2}}$\\

\vspace{50 mm}

\begin{align*}
\psgrid[unit=2cm](0,0)(-2,-2)(2,2)
\pnode(-1.8,.87){b}\uput[50](b){b}
\pnode(-1.8,1.8){a}\uput[50](a){a}
\psset{linecolor=green}
\psline[linewidth=1pt](-1.8, 0)(-1.8,4)
\psset{linecolor=green}
\psline[linewidth=1pt](-1.8, 0)(-1.8,-4)
\psset{linecolor=blue}
\psellipticarc(0,0)(2,2){0}{180}
\psset{linecolor=red}
\psline[linewidth=1pt,linestyle=dashed,dash=2pt](-2,2)(-1.41,1.41)
\psset{linecolor=red}
\psline[linewidth=1pt](-1.41,1.41)
\psset{linecolor=red}
\psline[linewidth=1pt]{->}(4,-4)
\psset{linecolor=red}
\psline[linewidth=1pt]{->}(-2,2)(-4,4)
\end{align*}

\end{document}

PDF output:

enter image description here

PDF->HTML output:

enter image description here

Best Answer

Using PDF as an intermediate format when converting from LaTeX to HTML is not a very good idea. LaTeX and HTML are both mostly structural markup languages, which means you use them to describe the document structure (sections, emphasize, formulas etc.), whereas PDF is mostly about the representation of your document on the screen or paper. When converting LaTeX to PDF, you lose much of the structural information, and it cannot be successfully recovered by conversion from PDF to HTML.

It is much better to convert LaTeX directly to HTML. There are number of ways (WayBack Archive) how to do that, one I would recommend is by using htlatex. It is probably already part of your TeX distribution, is very powerful and flexible, and its use can be as simple as running

htlatex mydocument.tex

If you tell us more about your environment (which operating system do you use, what is your TeX distribution, your text editor/LaTeX IDE, how you generated the PDF file etc.) we may be able to give you more details on how to use htlatex.