Parts of my issue has already been answered in different questions on this site and elsewhere, however none of them solves my problem as a whole.

A question about just specifying the output directory can be found here:

Specify output directory for htlatex

I've constructed a big number of different .tex-files which are all combined in different ways through a few main, standalone .tex-files. This makes changing a specific thing about the big "end-file" much simpler, as each chapter has its own directory with all of its components. As of right now, I have one directory with .tex-files containing the bodytext of the project. In the second directory, I have standalone files which \include the bodytext-files and all of the preamble which decides how the text should look in the end. In the third directory I have all the images, some of which are used several times throughout the chapters. The fourth directory is called "output", and is simply where I want to have all of the results after running a shellscript of some sort.

Now, the problem that I've stumbled upon was not something I gave much thought to to begin with. The parts of the text that are supposed to be printed or read directly on the computer screen, are converted to .pdf, with the pdflatex myfile.tex command. I also add pdflatex -output-directory=output/. myfile.tex in order for the files to end up where I want them. I earlier struggled with getting all of the included paths to find their specified files, but this issue was solved by pathing everything from the root folder instead of from each document. This is also why the commands which are supposed to convert the .texs are run in the root folder.

So the .pdf-converting works just fine, however I would like to have a similarly easy process with .html as well. I've tried using htlatex myfile.tex “” “” -doutput/ which works fine since it copies the .html and .css to the output directory. But the command doesn't work well on the files which include other files within them. This is my try at an MWE which reproduces the same errors on a smaller scale:

I have three test directories: source, texs and output. source contains myfile.tex


This is myfile.tex

texs contains include.tex:


output is where I want the results of the conversion-command to end up.

Now, if the root folder is my working directory and I run the command

$ pdflatex -output-directory=output texs/include.tex

everything works just fine. I get the .pdf, .log and .aux in the output folder.

However, when I try the command:

$ htlatex texs/include.tex "" "" -doutput/

which should work (and it does with files that does not \include other files), I get the error:

This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2014/05/01>
Babel <3.9k> and hyphenation patterns for 78 languages loaded.
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
! Extra \else.
l.227     \else


When continuing i instead get ! Extra \fi. and so on... How can I make this work at least somewhat as painless as the .pdf-command?

Also, when running the command, all the temporary files (.4ct, .4tc, .aux etc.) are still in the working directory where the conversion command was run. This, I would like to have a solution to. How do I get rid of all the temporary files in the working directory when converting a .tex -file to.htmlusinghtlatex`?

I have also happened upon another problem... It seems that htlatex does not like the commands used in the included document, as I get the error:

! Undefined control sequence.
<write> ...{1}{x1-10001}{QQ2-1-1}{\subsection:ttl 
                                                  {Connecting to UPPMAX}}}{\...

  • The error has nothing to do with the structure: tex4ht obviously doesn't like the standalone package (which is doing a lot of magic). – Ulrike Fischer Jul 30 '14 at 9:44
  • 1
    this is known issue see tex.stackexchange.com/q/95701/2891 – michal.h21 Jul 30 '14 at 10:55
  • 2
    this issue was fixed in development version of standalone, which is not on CTAN yet. you may download it directly from bitbucket.org/martin_scharrer/standalone/raw/… and place it to thse base directory – michal.h21 Jul 30 '14 at 11:22
  • @UlrikeFischer Would docmute be a preferable option? Or should I try updating the package to the development version, like michal mentioned? – Rikardny Jul 30 '14 at 13:56
  • @michal.h21 I'm sorry, I'm not too bright when it comes to this because I'm kind of new. I guess I'm supposed to update the package manually, how exactly do I do that? – Rikardny Jul 30 '14 at 13:57

Your Answer

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

Browse other questions tagged or ask your own question.