Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
2  
It may help if you describe what techniques you have tried and include examples of what turned out weird. –  N.N. Dec 25 '11 at 14:57
4  
Perhaps one of the questions listed at tex.stackexchange.com/questions/tagged/latex2html is helpful to you? –  doncherry Dec 25 '11 at 15:18
1  
@doncherry: And if those don't, there's always the FAQ. –  Martin Schröder Dec 25 '11 at 18:19
1  
So, @XYZ: Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. –  doncherry Dec 25 '11 at 19:08
    
See comment below answer. –  XYZ Dec 26 '11 at 13:52

4 Answers 4

Using PDF as an intermediate format when converting from LaTeX to HTML is not very good idea. LaTeX and HTML are both mostly structural markup langauages, which means you use them to describe the document structure (sections, emphasize, formulas etc.), whereas PDF is mostly about representation of your document on the screen or paper. When converting LaTeX to PDF, you loose 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.

share|improve this answer
    
I used MiKTeX 2.9 which I downloaded off the internet onto a computer using Windows 7. It is TeXworks and some of the options are pdfLaTeX + MakeIndex + BibTeX, LaTeXmk, pdfTeX, pdfLaTeX, pdfLaTeX + MakeInndex + BibTex, XeTeX, XeLaTeX, XeLaTeX + MakeIndex, + BibTex, ConTeXt(LuaTeX), conTeXt(pdfTeX), ConteXt(XeTeX) –  XYZ Dec 27 '11 at 14:04
    
the link "number of ways" does not work. –  Kaveh Jul 7 '13 at 19:59
1  
@Kaveh Here's a wayback archive link –  Darael Jul 8 '13 at 19:44

Is there a converter that will convert LaTeX to HTML?

Yes. There are lots. But you already knew this, as evidenced by your second "question":

I have tried several services but the LaTeX diagrams and some of the maths came out weird.

"turning out weird" could mean any number of things:

  • The document fails to compile
  • The document compiles, but is empty or corrupted
  • The document compiles and opens, but is somehow faulty.

Each of these categories breaks down further and the solution may well depend on what you used to do the conversion, so as it stands, this question is unanswerable.

For diagrams, one word of general advice I would give is that it might be best to compile the diagrams separately and include them into the html by hand with <img> tags. Diagrams are hard. The standalone package/class can help with this. See also the pgf/TikZ externalisation tag.

share|improve this answer
    
I actually converted the Latex to PDF without a problem. Then I used www.pdfonline.com 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. –  XYZ Dec 26 '11 at 13:48
2  
@XYZ add this information to your question, along with an example of a file that has this problem. –  Seamus Dec 26 '11 at 17:13

As previously observed using PDF format for converting from LaTeX to HTML is very bad idea. Here you will find a comprehensive list of programs that convert LaTeX to HTML (Note not all of those programs are capable of converting pure TeX.)

http://www.tex.ac.uk/cgi-bin/texfaq2html?label=LaTeX2HTML

I am familiar with three of these programs: LaTeX2HTML, TeX4ht, and Hevea. All of them have their strengths and weaknesses and they use different approaches. TeX4ht is included in TeXLive and MiKTeX unlike other two and from the point of view of theoretical CS is a "correct" way to do conversion (not surprisingly it was written by a (now deceased) member of the CS department at Ohio State). If you have just a few pages to convert, probably the right approach for you would be to chose any of the three and then do some manual editing. Now you have to be careful. For example Hevea will try to use HTML tags for things like square root while TeX4ht will use bitmap images for any math expressions. Since pure HTML has a poor support for mathematics the first approach can quickly get into trouble but when it works the output is really beautiful.

As for diagrams and pictures, all of the above programs to my knowledge rely on ImageMagic to do image conversion. Hevea has to be run multiple times (it is actually bunch of scripts) and the proper way to use it is by writing a Makefile (Unix again). I would actually convert images and diagrams manually using GraphicMagic which is IMHO far more stable and better batch image processor than ImageMagic.

share|improve this answer

RtextDoc has a built in Latex to Html converter

share|improve this answer
1  
How well does it cope with the type of documents the poster is interested in? –  Andrew Swann Oct 23 '13 at 6:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.