As you want to test for tex4ht
using \@ifpackagesloaded
, you do not want to load tex4ht
in every job! This will interfere with the standard pdfLaTeX settings and make PDF creation more difficult. Instead, leave the package loading out (but include the test) and htlatex
will make the necessary arrangements to load tex4ht
when you are creating HTML files.
As to the “why” question, what is happening here is that under some circumstances the letter pair “ff” is replaced by “ff” LATIN SMALL LIGATURE FF U+FB00, which is understandable in a sense, but then things go wrong.
In cases 3 and 4, the character is presumably written correctly in the HTML document, but the font being used does not contain it, so the browser picks up a glyph from a backup font. The probably depends on font settings, which were not disclosed in the question.
In case 2, the character is written as UTF-8 encoded, bytes 0xEF 0xAC 0x80, but then these bytes get interpreted according to windows-1252, yielding “ff”. The reason is that the character encoding has been declared incorrectly, or maybe not at all, forcing browsers to guess, and they may guess wrong.
Using U+FB00 is understandable but questionable. Such characters used to be the only way to use ligatures in HTML document, but they only work when the font used contains them. Nowadays you can use font-feature-settings
in CSS, and although they are still relatively poorly supported (in fonts and in browsers), they are safe in the sense that when they fail, e.g. “ff” gets displayed just as “ff”, not in a fancy incorrect way.
Best Answer
A little investigation reveals that
htlatex
is indeed ash
script file, at least in my system:And the contents of that script are:
So it consists of a sequence of calls to
latex
,tex4ht
and finallyt4ht
. Apparently the script expects 5 parameters ($1
to$5
) and from their use we can deduce, more or less, their function:$1
is the name of the file containing thelatex
source. It is passed to all the tools in the chain.$2
is part of a parameter passed to a mysterious command\HCode
defined in place for thelatex
command, and whose mission I didn't try to understand. I will ignore this parameter until someone better equiped than me can discover its function$3
is passed totex4ht
as part of the-i
option, and thus serve to specify a folder for fonts.$4
is passed tot4ht
so looks like a place where we can specify additional switches fort4ht
.$5
is passed to latex, so it looks like a place where we can specify additional switches forlatex
.Using
t4ht --help
we discover that the-d
option can be used here to specify the destination directory, so I tried:And it worked. The result goes to
/tmp/
, but note that this affects only to the final step. The first steps still use the current directory, so all intermediate and auxiliary files are still there. I guess you cannot get ride of them with a switch.