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

G:\PhD\Thesis 3\Scratch>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@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 myhtml.a.b.c.\input  .\scratch.tex
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

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:


Text text.

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, 2018 at 22:40

1 Answer 1


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, 2018 at 7:06
  • Yes it does. I didn't know that make4ht existed. Oct 1, 2018 at 12:29
  • you should take a look then, it fixes lot of htlatex issues, file name support is one of them
    – michal.h21
    Oct 1, 2018 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, 2018 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.