# htlatex: customising the build process

I'd like to customise the processes used when calling htlatex; in particular, I'd like to be able to switch off the conversion of included images into .png files.

With the following file, say mwe.tex:

\documentclass{article}
\usepackage{graphics}
\begin{document}
Some mathematical content: $y=x$
\includegraphics{example-image-a}
\end{document}


and myconfig.cfg

\Preamble{xhtml,mathml}
\Configure{VERSION}{}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
(http://www.cse.ohio-state.edu/\string~gurari/TeX4ht/)" />\Hnewline}}
rel="stylesheet" type="text/css"
href="\expandafter\csname aa:CssFile\endcsname" />\Hnewline}}
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"\Hnewline
></script>\Hnewline}}
.MathJax_MathML {text-indent: 0;}\Hnewline
</style>\Hnewline}}
% margin note
\begin{document}
\EndPreamble


when I run

 htlatex.exe mwe "myconfig.cfg, charset=utf-8" " -cunihtf -utf8"


part of the process converts example-image-a.eps to example-image-a.png; this is as intended, but not necessary every time I call htlatex.

How can I configure my call to htlatex so that I can toggle the image conversion step?

Image conversion is executed by the t4ht command. It has -p option, which can suppress the image generation when the target file exists. You can options to t4ht using slightly complicated htlatex call:

htlatex.exe mwe "myconfig.cfg, charset=utf-8" " -cunihtf -utf8" " -p"


This can be simplified using make4ht. Create a build file mwe.mk4:

if mode == "draft" then
settings.t4ht_par = "-p"
end


The mode variable can be set on the command line using -m option. The draft mode uses only one LaTeX run instead of usual three, so it greatly speeds up the compilation. The equivalent to the htlatex call is the following make4ht command:

make4ht -um draft -c myconfig mwe


This is the result:

Btw, the config file can be simplified as well:

\Preamble{xhtml,mathml,html5}
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"\Hnewline
></script>\Hnewline}}

• @cmhughes there is only draft mode configured by default, but you can use your own modes in the build files. – michal.h21 Nov 23 '17 at 15:55
• many thanks. the htlatex works as expected, but the make4ht command still does the conversion; do I need to alert make4ht to mwe.mk4 in some way? – cmhughes Nov 23 '17 at 16:21
• The mk4 file is loaded automatically if it has the same basename as your TeX file. If it doesn't you can use the -e option to point to it. – michal.h21 Nov 23 '17 at 16:26