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.

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 }}
                                                  {section.1}{}}
?
! 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,

\documentclass[11pt,a4paper,oneside]{article}

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

\usepackage{fullpage}

\SetWatermarkText{INTERNAL}
\SetWatermarkFontSize{5cm}
\SetWatermarkScale{4.5}
\SetWatermarkLightness{0.9}

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

%\electronicfalse
\electronictrue

\ifelectronic
\newcommand{\xyzref}[1]{\nameref{#1}}
\else
\newcommand{\xyzref}[1]{\ref{#1}}
\fi

%For switching between stand alone APPlication and plugin
\newif\ifapp

%\apptrue
\appfalse

%to NOT print the subsection numbers in the table of contents
\newcounter{sectocnonumdepth}
\setcounter{sectocnonumdepth}{2}

\renewcommand{\familydefault}{\sfdefault}

\hypersetup{colorlinks=true}

\usepackage{listings}

\begin{document}

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

\author{Company XYZ}
\maketitle

\tableofcontents

\input{Chapters/Chap1}
\input{Chapters/Chap2}
\input{Chapters/Chap3}
\input{Chapters/Chap4}

\end{document}

Below is a sample chapter,

\section{Creating a New Project}
\label{sec:newProject}

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

\begin{enumerate}
\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'.
\begin{figure}[hp]
    \centering
        \includegraphics[width=0.50\textwidth]{Images/XYZWizard.PNG}
    \caption{Eclipse New Project Dialog}
    \label{fig:XYZWizard}
\end{figure}

\fi

\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.
\begin{figure}[hp]
    \centering
        \includegraphics[width=0.50\textwidth]{Images/XYZWizard2.PNG}
    \caption{XYZ New Project Wizard Dialog}
    \label{fig:XYZWizard2}
\end{figure}

\ifapp

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

\fi

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

\end{enumerate}
share|improve this question
    
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. –  Igor Kotelnikov Nov 1 '11 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. –  nEm Nov 1 '11 at 14:53
    
I am open to the idea of using another converter which will work with miktex –  nEm Nov 1 '11 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. –  Igor Kotelnikov Nov 1 '11 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. –  LianTze Lim Nov 1 '11 at 15:14

1 Answer 1

up vote 3 down vote accepted

The problem seems to be

\usepackage[all]{hypcap}

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:

\Preamble{html}
\begin{document}
% Upper case PNG file extensions
\Configure{graphics*}
   {PNG}
   {\Picture[pict]{\csname Gin@base\endcsname.PNG}}

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

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.

share|improve this answer
    
I still get that Qfigure error I have pasted in my question. Let me paste a sample chapter. –  nEm Nov 1 '11 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. –  LianTze Lim Nov 2 '11 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}% –  nEm Nov 2 '11 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. –  LianTze Lim Nov 2 '11 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!!! –  nEm Nov 2 '11 at 12:41

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.