4

The setup is simple. I have a file report.tex which includes an image from a folder. I send the output of htlatex to a separate directory. htlatex copies all images and HTML to that directory. The problem though, now all the links in the HTML are broken, since the links are generated relative to original location of report.tex and not to where the HTML now lives.

In pictures, I have this

 report.tex ...\includegraphics{e1/image.png}
   |
   +--------------------------+
   |                          |
   /e1/image.png             /report/
                               report.htm ....<img src="e1/image.png"
                               image.png

One can see the problem. The HTML is using src= thinking it was in the original location of the .tex file. So, I end up editing the HTML files fixing links by adding "../" to each image src link or by removing "e1/" since the image was copied!

I searched and was not able to find an option to fix this. Does anyone know of a solution to this?

Here is minimal working example:

\documentclass{article}%
\usepackage{graphicx}
\begin{document}
  \includegraphics{e1/image.png}
\end{document}

Here is the command used

  mkdir report; htlatex report.tex "htm" "" -dreport

and now looking in the folder report/report.htm shows the problem. The image does not show up without manually fixing the links.

Doing this works:

  htlatex report.tex "htm"

now the report.htm shows the image ok as expected. But I want all the output to go to separate folder.

I am using the TeXlive 2012 Debian package.

1 Answer 1

2

This is because of bug in t4ht. This is application which converts images, run system commands, generates css and copies files. For file copying, it uses system copy command, so in your example it is something like:

cp e1/image.png outdir/.

or

copy e1/image.png outdir/.

on windows.

This command doesn't create subdirectories in output dir, so all generated files are saved directly in this dir.

You can try my new project, make4ht, which tries to generate correct subdirs:

make4ht -d outdir -u report.tex

you have to put scripts to your local texmf tree:

texmfhome/scripts/lua/make4ht

and make symbolic link to texmf/scripts/lua/make4ht/make4ht or create shell script which run this file.

1
  • thanks for your build system. Using this command worked make4ht foo.tex "nma.cfg,htm,charset=utf-8" " -cunihtf -utf8" -d foo (notice no quotes at the end around the destination folder) see github.com/michal-h21/make4ht for more information.
    – Nasser
    Jun 9, 2013 at 13:27

You must log in to answer this question.

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