2

My situation is like this. I have a LaTeX file that I want to compile with pdflatex and tex4ht, which includes a package in another directory.

The file bug.tex contains:

\documentclass{article}

\usepackage{etoolbox}
\csdef{input@path}{{subdir/}}
\usepackage{mypackage}

\begin{document}

Test: \aaa.

\end{document}

The file subdir/mypackage.sty contains:

\ProvidesPackage{mypackage}
\newcommand\aaa{AAA}

and the file subdir/mypackage.4ht contains:

\renewcommand\aaa{BBB}

When I compile with pdflatex, I get Test: AAA. in the output. But when I compile with make4ht, I still get Test: AAA. instead of Test: BBB.

(When the package is in the working directory, it works as expected.)

This indicates to me that, when using tex4ht, the redefinition of input@path occurs, but when including packages, tex4ht doesn't search it for .4ht files.

Can anyone help me work around this?

Of course, you are probably thinking that I'm doing this wrong, and I should put the package in my texmf, or set $TEXINPUTS correctly, and you would be right. But I have a complex project that I will need to share with colleagues who I can't expect to use make, so it would be much better if I can manage everything from within the tex files.

2

tex4ht didn't support the \input@path by default. I've just added the support to the sources, so it should be included in TL soon. It was necessary to change some core macros that are not possible to modify using a .cfg file. So until the update is available, you can use the following workaround:

\InputIfFileExists{mypackage.4ht}{}{}
\Preamble{xhtml}
\begin{document}
\EndPreamble

The \InputIfFileExists command searches the \input@path and includes the required file if it is found.

The result:

enter image description here

  • This is great, thank you for making this change so quickly! – Alex Watson Sep 29 at 19:47
  • @AlexWatson you are welcome. I didn't know about the \input@path before, so it was also something new for me :) – michal.h21 Sep 29 at 19:55

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.