[tex4ht] latexmk instead of 3 systematic compilations?

Denis Bitouzé dbitouze at wanadoo.fr
Tue Sep 25 19:01:52 CEST 2012


Le lundi 17/09/12 à 20h33,
Denis Bitouzé <dbitouze at wanadoo.fr> a écrit :

> Maybe I could contact John Collins to provide him this information
> and to ask him to make Latexmk aware of TeX4Ht

Before that, I'll try to investigate a bit.

For instance, the htlatex script contains (on my Linux box) 3 times:

latex $5
'\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx"\HCode\def\HCode"##1"{\Link##1}\expandafter\HCode\else\expa
ndafter\Link\fi}\def\Link#1.a.b.c.{\g at addto@macro\@documentclasshook{\RequirePackage[#1,html]{tex4ht}}\let\HCode\documentstyle\def\documents
tyle{\let\documentstyle\HCode\expandafter\def\csname
tex4ht\endcsname{#1,html}\def\HCode####1{\documentstyle[tex4ht,}\@ifnextchar[{\HCode}{\
documentstyle[tex4ht]}}}\makeatother\HCode '$2'.a.b.c.\input ' $1

followed by:

tex4ht -f/$1  -i~/tex4ht.dir/texmf/tex4ht/ht-fonts/$3
t4ht -f/$1 $4 ## -d~/WWW/temp/ -m644

Because of the '$5', I guess htlatex accepts from 1 to 5 parameters.

I was told that, on Windows, the htlatex synopsis is:

  htlatex [options] file.tex [params1] [params2] [params3]

Here I see 5 possible parameters but, the man page of htlatex on Linux
is (http://linux.die.net/man/1/tex4ht):

  htlatex file [options1] [options2] [options3]

so I'm not sure what mean all of these $1 to $5 parameters: any help is
welcome.

Furthermore:

$ latex -help
Usage: pdftex [OPTION]... [TEXNAME[.tex]] [COMMANDS]
   or: pdftex [OPTION]... \FIRST-LINE
   or: pdftex [OPTION]... &FMT ARGS

so I'm not sure of what is what in the very long line:

  latex $5 '\makeatletter... '$2'.a.b.c.\input ' $1

So any extra help is welcome :)

Nevertheless, I was a bit successful with the following myhtlatex
script:

#########################################################
#!/bin/sh
latexmk $1
tex4ht -f/$1  -i~/tex4ht.dir/texmf/tex4ht/ht-fonts/$3
t4ht -f/$1 $4 ## -d~/WWW/temp/ -m644
#########################################################

and the following .latexmkrc file (no breaklines after neither
"latex", "\csname" nor ".a.b.c.", but spaces instead):

#########################################################
$pdf_mode = 0;
$quote_filenames = 0;
$latex = q(latex
'\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx"\HCode\def\HCode"##1"{\Link##1}\expandafter\HCode\else\expandafter\Link\fi}\def\Link#1.a.b.c.{\g at addto@macro\@documentclasshook{\RequirePackage[#1,html]{tex4ht}}\let\HCode\documentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname
tex4ht\endcsname{#1,html}\def\HCode####1{\documentstyle[tex4ht,}\@ifnextchar[{\HCode}{\documentstyle[tex4ht]}}}\makeatother\HCode .a.b.c.
\input ' %B);
#########################################################

Some remarks about the previous file:

  1. I suppose no config file (empty string before ".a.b.c")

  2. Because of the already simple and double quotes, I needed to use
  'quoting without quotes' q(...) perl notation.

I tested this with the following test.tex file:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{article}
\begin{document}
Test. 
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This is not that bad because after some runs of:

  ./myhtlatex test

only 2 latex compilations instead of 3 are executed :)

In fact, only 1 latex compilation should be executed if nothing changed
in the .tex file but, when running the previous command:

  1. every latex compilation writes in the test.tmp file:

     \def \Jobname{test}

  2. each of tex4ht and t4ht compilations write something in the same
  test.tmp file (resp. "xx" and "<LF>/* css.sty */")

So, when ./myhtlatex is run once again, the command:

latexmk test

is run, so a first latex compilation is executed, and Latexmk sees
that test.tmp has changed so it does a rerun of latex :(
-- 
Denis



More information about the tex4ht mailing list