I'm currently working on a little thing I called offline blog engine. The idea is to write my articles in simple (La)TeX files and create some static HTML files which contains the blog posts.

The infrastructure is written with an ant script. At the moment I'm having trouble to get HtLaTeX to work on my Windows 7 box (using MiKTeX 2.9).

HtLaTeX works just fine if I'm in the CLI in the directory with the article. E.g. If I'm currently in the directory C:\users\me\articles\ and there's one article article.tex:

C:\users\me\articles$> htlatex article.tex

Works just fine. It generates the formulas as PNGs, creates the css file and puts it in the current directory.

If I'm in a whole different directory and calling HtLaTeX with an absolute path it doesn't work. So,

 C:\users\me\other\dir$> htlatex C:\uisers\me\articles\article.tex

just generates an log file containg this information:

This is pdfTeX, Version 3.1415926-2.4-1.40.13 (MiKTeX 2.9) (preloaded format=latex 2013.8.3)  18 AUG 2013 11:20
entering extended mode
umentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname te
ode}{\documentstyle[tex4ht]}}}\makeatother\HCode html.a.b.c.\input  e:\Users\zo

! Emergency stop.
<*> ...keatother\HCode html.a.b.c.\input  c:\Users
End of file on the terminal!

Here is how much of TeX's memory you used:
 4 strings out of 493922
 56 string characters out of 3144897
 49031 words of memory out of 3000000
 3403 multiletter control sequences out of 15000+200000
 3640 words of font info for 14 fonts, out of 3000000 for 9000
 841 hyphenation exceptions out of 8191
 4i,0n,3p,1b,8s stack positions out of 5000i,500n,10000p,200000b,50000s
 No pages of output.

If I use relative paths some files more are generated (like the DVI file) but the html file and the mathematical formulas are missing too.

Any idea what's wrong here? Problem consist within ant script and from the CLI.

UPDATE: While escaping the backslashes didn't work, replacing them with regular slashes worked. (As David Carlisle suggested) But the PNGs of the formulas are missing. In the output they are generated but I can't find them.

The command looks like that:

C:\users\me\other\dir$> htlatex C:\users\me\articles\article.tex "html" "" "-dC:\users\me\articles\html"

Within the ant script it doesn't work because ant uses automatically the path devider of the current system and on windows it's backslash. (No problem, this call could be replaced by an batch file.)

  • 1
    see also tex.stackexchange.com/q/116476/2891 make4ht can process files with absolute paths
    – michal.h21
    Aug 18, 2013 at 10:42
  • Thanks for the suggestion. It's a shame that I had finished my own script just before seeing your post. Looks like it would have been a good base for my own scripts. I do a little bit more (transforming resulting html with easier template support, adding link to PDF, etc.) so maybe you're interested in github.com/schlingel/oobe
    – schlingel
    Aug 18, 2013 at 11:04

2 Answers 2

! Emergency stop.
<*> ...keatother\HCode html.a.b.c.\input  c:\Users

Shows that the path is being passed to TeX, where \ will do the wrong thing. You can use / instead

htlatex C:/uisers/me/articles/article.tex

Although it may be more robust just to get your script to split up the filepath, cd to the relevant directory and then just use the local name.

  • Hm, I tried escaping it. But I'll try what you suggest.
    – schlingel
    Aug 18, 2013 at 9:49
  • I tried your suggestion and added the result as update in the post above.
    – schlingel
    Aug 18, 2013 at 10:00
  • @schlingel hmm don't know (but converting formulas to images is just wrong anyway:-) Aug 18, 2013 at 10:04
  • How would you add formulas to HTML files?
    – schlingel
    Aug 18, 2013 at 10:05
  • 1
    @schlingel well as I'm the editor of the MathML spec I'd use MathML, possibly using MathJax to smooth out browser problems, but since you are converting from latex if you use mathjax you basically don't need to do much at all, juts put the tex syntax in the page. Aug 18, 2013 at 10:09

I ended up writing a little batch script to work around the limitations of htlatex on windows:

@echo off
set START_DIR=%~dp0

for /f %%f in ('dir /b *.tex') do @htlatex %%f

echo ...build web sites

echo starting coping process to %TARGET_DIR%

for /f %%f in ('dir /b *.png') do xcopy %%f %TARGET_DIR%\img /C /Y
for /f %%f in ('dir /b *.css') do xcopy %%f %TARGET_DIR%\css /C /Y
for /f %%f in ('dir /b *.html') do xcopy %%f %TARGET_DIR%\ /C /Y
echo ...moved web site

del *.png
del *.html
del *.css
del *.4ct
del *.4tc
del *.aux
del *.dvi
del *.idv
del *.lg
del *.log
del *.tmp
del *.xref

echo ...removed meta files

echo ...finished building html files

And I call it like that in my ant script:

    <exec executable="build.webpages.bat">
        <arg value="${articles.dir}" />
        <arg value="${basedir}\${build.dir}" />

If you're looking for a script to run on an unixoid system, have a look at make4ht

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .