I'm using MiKTeX 2.9 and installed the miktex-tex4ht-base2.9 in order to convert my LaTeX files into HTML. I just updated everything before starting so I should have the latest packages for everything. I am also using Windows 7.

My LaTeX file contains other LaTeX files via the \include command. It is a book with chapters that are stored in a separate folder with their own tex files.

For example, I have Main.tex with Chapter1.tex, Chapter2.tex... and so forth which are included in the whole document using \include.

Is it possible to call htlatex Main.tex and it will compile all the required files or is there some step by step procedure to do each file? When I tried it, I got 100s of errors (pdflatex compiles without any errors and I have an output pdf file, htlatex even worked on a simple single file so I know htlatex is working properly). I would have pasted the errors but there are just so many and most of them relate to missing curly brackets for a section or missing an end{document} which is why I am thinking it has something to do with the \include command.

I have pasted below some errors,

! Extra }, or forgotten \endgroup.
l.22 ...lax }}\par \let \reserved@d =*\def \par }}
! Extra }, or forgotten \endgroup.
l.22 ...t \reserved@d =*\def \par }}{section.1}{}}

Below is the first error I recieve after running htlatex Main.tex

! Undefined control sequence.
<argument> )Qfigure.\theHfigure

l.40 \:CrossWord{)Qfigure.\theHfigure }{1}{5}

This is the main.tex file,


\usepackage[all]{hypcap}    %for going to the top of an image when a figure reference is clicked



%For toggling between print pdf and electronic pdf
%change the reference style.



%For switching between stand alone APPlication and plugin


%to NOT print the subsection numbers in the table of contents





    \title{\textbf{XYZ Quick Start} \\ (For stand-alone application users)}
    \title{\textbf{XYZ Plug-in Quick Start} \\ (For Plug-in users)}

\author{Company XYZ}




Below is a sample chapter,

\section{Creating a New Project}


\item Go to `File' menu.
\item Select `New'.

\ifapp  %if its the standalone

\item And click the XYZ Project option. Note: If you do not see this option then check whether you are in the XYZ perspective via Window$\rightarrow$Open Perspective.

\else %if its plugin

\item Select `Project...'.
\item A New Project dialog will open which will ask you to select a project wizard\index{Wizard}. Choose the XYZ project under the XYZ category (see figure \ref{fig:XYZWizard}) and then click `Next'.
    \caption{Eclipse New Project Dialog}


\item Give the project a name. You can either choose the default workspace location, or browse for another location. The Mod-Dat-Run style folder structure just creates the three respective folders in your project, if you check it (figure \ref{fig:XYZWizard2}); You can always create the folders later. These folders are independent of the files you put in them.
    \caption{XYZ New Project Wizard Dialog}


\item After clicking `Finish', Eclipse will ask you if you want to change to the XYZ perspective, click yes.


\item The project has been created and you will be able to see it in the Project Explorer.

  • I used to play with TeX4h a bit less than 10 years ago for similar purpose (posting book to web) but finally threw that idea away in favor of PDF. IMHO, TeX4h is unripe product. Commented Nov 1, 2011 at 14:51
  • @Igor Unfortunately, I need the html format and after a lot of research I got the impression that the miktex package of tex4ht is the most compatible with miktex.
    – nbz
    Commented Nov 1, 2011 at 14:53
  • I am open to the idea of using another converter which will work with miktex
    – nbz
    Commented Nov 1, 2011 at 14:55
  • 1
    I remember that TeX4h requires more strict syntax: e.g. $a_{\text{fus}}$ instead of $a_\text{fus}$, some symbols are prohibited in labels (perhaps, dot, underscore, semicolon, etc.). Sorry, I forgot exact details. Commented Nov 1, 2011 at 14:57
  • 1
    @Igor, 10 years is a long time ago. I've been happily using tex4ht for conversions to HTML, ODT, etc, on LaTeX files using many different packages. I've just tested a small example, where mainbook.tex contains \include{chap1/chaptertext} \include{chap2/chaptertext}, using tex4ht from MikTeX 2.9, and I'm looking at the generated HTML page now.
    – imnothere
    Commented Nov 1, 2011 at 15:14

1 Answer 1


The problem seems to be


Once I removed this particular line, delete the *.aux and *.xref files, running htlatex Mainbook produced an HTML file without errors. Remember to delete the *.aux, so that tex4ht doesn't pick up the auxiliary files containing the errors from the previous run.

Another thing is that by default, when tex4ht sees an \includegraphics, it tries to convert an .eps to a .png. This is often highly undesirable when you are already using PNG files anyway. The trick is to put the following in a myconfig.cfg file, on the same path as Mainbook.tex:

% Upper case PNG file extensions
   {\Picture[pict]{\csname Gin@base\endcsname.PNG}}

% Lower case png extensions
   {\Picture[pict]{\csname Gin@base\endcsname.png}}

And run the following command, to tell tex4ht to use your configuration file:

$  htlatex Mainbook "myconfig"

The <img> tags in your generated HTML file should now link to your existing PNG graphics.

  • I still get that Qfigure error I have pasted in my question. Let me paste a sample chapter.
    – nbz
    Commented Nov 1, 2011 at 16:30
  • You need to delete the *.aux files from the previous run, before running htlatex again, so that it doesn't pick up the previous lines on hypcap that it choked on.
    – imnothere
    Commented Nov 2, 2011 at 1:24
  • I'm getting the same error, I deleted all .aux files and put the myconfig file... but im still getting the error. It is actually in the Main.xref file. I removed the hyperref package and followed the same procedure but the error is still coming so I'm assuming its with a \ref command. I opened the .xref file and this is th line it messes up on \:CrossWord{)Qfigure.\theHfigure }{1}{5}%
    – nbz
    Commented Nov 2, 2011 at 12:01
  • That's great! Appreciate it if you can accept my answer. :) Note that I just corrected a typo in myconfig.cfg, where one \Configure{graphics*} gets a png extension and the other a PNG extension.
    – imnothere
    Commented Nov 2, 2011 at 12:40
  • Oh my god it worked! Finally, basically I had to delete the Main.xref file that was generated by htlatex. The statement \:CrossWord{)Qfigure.\theHfigure }{1}{5}% was not updated without the hypcap stuff so it kept dying! I am editing your answer with that and accepting it. Thank you so much!!!
    – nbz
    Commented Nov 2, 2011 at 12:41

You must log in to answer this question.

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