# htlatex Defines a Command Then Chokes on it

I'm trying to compile a LaTeX document into a HTML document but I keep hitting the same problem. When I compile (using the command htlatex .\scratch.tex myhtml), I get the following output:

G:\PhD\Thesis 3\Scratch> htlatex .\scratch.tex myhtml

This is pdfTeX, Version 3.14159265-2.6-1.40.19 (MiKTeX 2.9.6800 64-bit)
entering extended mode
LaTeX2e <2018-04-01> patch level 5
! Undefined control sequence.
<*> ...tother\HCode myhtml.a.b.c.\input  .\scratch
.tex


From this output the problem doesn't seam to be anything to do with the document (and the error is the same whatever the document is), rather it's a bug in tex4ht, but for reference scratch.tex is this:

\documentclass{article}

\begin{document}
Text text.
\end{document}


It seams that tex4ht is trying to define a command (\HCode) then run it before running the actual document, but for some reason the definition fails to take hold.

Updating MikTeX didn't change anything. From this question, a similar problem with tex4ht was solved by altering one of the .def files that tex4ht uses. But I don't know which file is causing this error or how to fix it.

So, my two questions are: 1) what causes this error, and 2) which file would I need to change to fix it. I'm using MiKTeX 2.9 on Windows 10 64-bit, if that helps.

• why do you use htlatex .\scratch.tex? it tries to execute the \scratch command. You can either use htlatex scratch.tex or htlatex ./scratch.tex – michal.h21 Sep 30 '18 at 22:40

So the solution is to run htlatex scratch.tex myhtml and not htlatex .\scratch.tex myhtml - the .\ confuses the compiler, and it thinks that you're trying to run the command \scratch. Thanks to michal.h21 for pointing this out.
A better solution is to use make4ht, which doesn't choke on the .\.
I should note that .\scratch.tex is what you get when you use the PowerShell autocomplete feature.
• I am not on Windows, so cannot test it, but does make4ht .\scratch.tex work? make4ht is a replacement for htlatex with much more features. – michal.h21 Oct 1 '18 at 7:06
• you should take a look then, it fixes lot of htlatex issues, file name support is one of them – michal.h21 Oct 1 '18 at 12:34
• I recommend you just use make4ht for everything. You can still use the same options as before, but make4ht has many other functionalities. That is what I use now for all my builds. – Nasser Oct 11 '18 at 17:14