I have been looking around for an easy way to save my .tex into a .html file, but all the questions/answers are very technical, and I have not found one that is accessible to me/beginners. I have seen a bunch of names of presumably packages (hlatex? tex4ht?) but no basic explanation of 'how to', from A to Z. I mean, actually basic instructions (do i need to install anything? what? where do i run codes? etc..) Anyone available to do that for me? Thanks you SO much!! Giulia.


2 Answers 2


Try pandoc

long version:

pandoc -f filename.tex -t html -o output.html

short version:

pandoc filename.tex -o output.html

Regarding tex4ht: it is a system which use TeX itself for the conversion. It redefines TeX commands to insert special instructions, which can be configured to insert HTML or XML codes. Positive consequence of using TeX itself is that it supports all custom commands and packages to some degree - you need to provide configurations to get good markup, but basic stuff like font style and size should work even for unsupported custom commands.

The output files are extracted from the DVI file using tex4ht command, another command t4ht then creates CSS file and images.

So basically, to convert LaTeX file to HTML using tex4ht, this sequence of commands must be called:

latex with special instructions for tex4ht

To simplify the setup, several helper scripts exists. The basic script is htlatex, which calls all necessary commands and pass optional arguments for them.

Nowadays, it is better to use make4ht (disclaimer: I am the author), which has several advantages over htlatex:

  • it has simpler command line interface
  • it supports build files, where it is possible to call additional commands like biber or makeindex
  • it can post-process the output files and fix some issues, using Lua scripts or any XML processing tool such as XSLT

tex4ht and all necessary scripts are part of TeX distributions, most up to date version is in TeX Live 2018. It is not necessary to install anything.

In TL 2018, you can use it in this way:

Basic invocation, with HTML5 output in utf8 encoding:

 make4ht -u filename.tex

Output in the ODT format

 make4ht -f odt filename.tex
  • Thanks for this! Can I just ask you a couple more details such as: is make4ht a package, so should i install it within my latex editor? (texstudio in this case)
    – Grig
    Commented May 3, 2018 at 10:32
  • both for a yes/no answer, where must the commands be inserted? in the text? in the preamble?
    – Grig
    Commented May 3, 2018 at 10:34
  • @Grig I don't know if there is a support for make4ht in texstudio, but I think it should be possible to add it see texstudio documentation.
    – michal.h21
    Commented May 3, 2018 at 11:05
  • @Grig which command do you mean? commands for compilation don't work in document,
    – michal.h21
    Commented May 3, 2018 at 11:06
  • @michal.h21 I tried to follow the steps you outlined and attempted to produce a html output but I keep receiving this error ! Undefined control sequence. \pgfsys@svg@newline ->\Hnewline . I will be submitting this as a new question soon
    – sab hoque
    Commented Apr 3, 2019 at 2:40

You must log in to answer this question.

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