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.
Try to change your preamble this way:
\documentclass[11pt,a4paper]{report}
\usepackage{fancyhdr}
\makeatletter
\@ifpackageloaded{tex4ht}{%
\usepackage[dvips]{color,graphicx}
\usepackage[tex4ht]{hyperref}
}{%
\usepackage[pdftex]{color,graphicx}
\usepackage{hyperref}
\setlength{\headwidth}{\textwidth}
\fancyhead[L]{\rightmark}
\fancyhead[R]{\includegraphics[height=0.43in]{Images/Fugrologo.eps}} % right with logo \fancyfoot{}%to remove centered default footer
\fancyfoot[L]{Fugro Roadware Inc.}
\fancyfoot[R]{\thepage \ of \pageref*{LastPage}}% page# of reference page(last)
\fancypagestyle{plain}% no header, footer contains page number centered {
\fancyhf{} %for the pages outside of content, list of figures etc.
\fancyhead[R]{ \includegraphics[height=0.43in]{Images/Fugrologo.eps}} % right with logo
\fancyfoot[L]{Fugro Roadware Inc.} \fancyfoot[R]{\thepage \ of \pageref*{LastPage}}
\pagestyle{fancy}
\usepackage[absolute]{textpos}
\usepackage{fullpage}
}
\makeatother
\usepackage{epstopdf}
\usepackage{lastpage}
\usepackage{makeidx}
\usepackage[english]{babel}
\usepackage{float}
\usepackage{subfig}
\usepackage{multirow}
\usepackage{appendix}
\usepackage{verbatim}
\renewcommand{\appendixtocname}{Appendix: Algorithm Parameters} \renewcommand{\appendixpagename}{Appendix-Algorithm Parameters}
\setlength{\topmargin}{-1.3cm} \setlength{\headsep}{0.6cm}
\renewcommand{\tablename}{\bfseries{Table}}
%The top margin above a chapter can be changed using the titlesec package
\hypersetup{
bookmarks=true, % show bookmarks bar?
unicode=false, % non-Latin characters in Acrobat’s bookmarks
pdftoolbar=true, % show Acrobat’s toolbar?
pdfmenubar=true, % show Acrobat’s menu?
pdffitwindow=false, % window fit to page when opened
pdfstartview={FitH}, % fits the width of the page to the window
pdftitle={My title}, % title
pdfauthor={Author}, % author
pdfsubject={Subject}, % subject of the document
pdfcreator={Creator}, % creator of the document
pdfproducer={Producer}, % producer of the document
pdfkeywords={keyword1} {key2} {key3}, % list of keywords
pdfnewwindow=true, % links in new window
colorlinks=true, % false: boxed links; true: colored links
linkcolor=black, % color of internal links
citecolor=green, % color of links to bibliography
filecolor=magenta, % color of file links
urlcolor=cyan % color of external links }
}
\input{Macro} %\renewcommand{\caption}[1]{{\underline{#1}}}
\makeindex
\renewcommand{\headheight}{0.6in} %Space above header \renewcommand{\headrulewidth}{1pt} %thickness of line under header \renewcommand{\footrulewidth}{1pt} \newcommand{\HRule}{\rule{\linewidth}{0.5mm}} %thickness of line on title page
\begin{document}
bhg fgfgf hgh ghghgf fdfd
\end{document}
important is the command \@ifpackageloaded{tex4ht}{true part ...}{false part ...}
. Now we can exclude packages which aren't needed when htlatex
is run, such as fancyheader
settings, and we can have different settings for packages which causes errors. In this case graphicx
with pdftex
option, htlatex
is running in dvi mode, so we can set it to dvips
Best Answer
This may help you. I made a batch script that I use when working with
htlatex
. You can copy and paste it into a file, and save it with.bat
extension, e.g.,html.bat
.cmd
, or press WndLogo + R and writecmd
to execute the command prompt. The command prompt is an application in which you can run different commands. In the top of the window you will see the current directory. For example,C:\Windows\system32\cmd.exe
. You can check this tutorial for more information.cd path
. For example, if you have your LaTeX documents in a folder in theC
drive calledMy Latex
, you can move to that folder usingcd "C:\My Latex"
. Note that you have to surround the path with quotes due to the spaces on it.html.bat file.tex
. That will create ahtml
directory in which you can find your file. (This assumes you have your file in the same directory as your.tex
file. However, you can place the script in a folder and add that folder to your environment variables. Then you will be able to call it from anywhere.)htlatex file.tex html "" -dSomeDir "--interaction=nonstopmode"
. Thehtml
option sets the type of output,-dSomeDir
sets the output directory toSomeDir
(although it is not mandatory, it is a good idea ashtlatex
produces several files), and thenonstopmode
tells the compiler not to stop if it can avoided.The script looks like this: