bugtex4ht - Bugs: bug #309, tex4ht does not work with package...

Show feedback again

You are not allowed to post comments on this tracker with your current authentification level.

bug #309: tex4ht does not work with package savetrees

Submitted by:  Nasser M. Abbasi <nma123>
Submitted on:  Sun Jun 5 03:55:15 2016  
Category: NonePriority: 5 - Normal
Severity: 3 - MinorStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Closed

Fri Jul 1 16:21:10 2016, comment #4:

committed usepackage.4ht and tex4ht.sty to TL (r41591), closing, thanks.

Karl Berry <karl>
Project Administrator
Wed Jun 15 14:02:41 2016, comment #3:

I've just committed the changes to the repo. The modified package loading hook doesn't seem to cause issues in my tests.

Michal Hoftich <michal_h21>
Project Member
Thu Jun 9 22:15:38 2016, comment #2:

There is missing discussion which happened on the mailing list, but anyway, there is a patch for tex4ht which enables blocking of package loading and which blocks savetrees package. I left configuration for fontspec, as it has it's own bug report.

(file #241)

Michal Hoftich <michal_h21>
Project Member
Wed Jun 8 09:58:54 2016, comment #1:

Savetrees package redefines lot of internal LaTeX commands, so it is no surprise that it crashes tex4ht. As the changes it does aren't useful in conversion to HTML, an easy solution is to use conditional inclusion.

Another possibility I've just found is to block the loading of the package from tex4ht. It seems that it is possible to call an action at \usepackage call, tex4ht has list of packages which request it. It is possible to add a package to this list in tex4ht-4ht.tex:

\<use package\><<<

\<add to usepackage\><<<
\def\:temp{savetrees}\ifx \@currname\:temp
% code to be executed


these configurations are added to usepackage.4ht, which is included every time \usepackage command is used. Now we need to block package loading.

I've found nice macro:

% http://tex.stackexchange.com/a/39418/2891

the problem is, it needs to be called with the same package options as \usepackage in the document, otherwise we would get option clash error message. I've took a look at the LaTeX and tex4ht.sty sources and it seems that the options aren't saved in any macro. In fact, I've found following definition in tex4ht.sty:

\catcode`\:=11 \catcode`\@=11

The original \@onefilewithoptions has following parameters


where the second argument are package options. We can change the tex4ht redefinition slightly:

\catcode`\:=11 \catcode`\@=11

as you can see, new macro is defined, holding package options. We can then define macro for blocking package loading like:


What do you think? Is that change safe?

Michal Hoftich <michal_h21>
Project Member
Sun Jun 5 03:55:15 2016, original submission:

This MWE


Gives an error when compiled with make4ht or htlatex:

! You can't use `\relax' after \the.
\NoHtmlEnv ....0pt\ht:everypar {\the \ht:everypar
l.3 \begin{document}


TL 2015 on Linux

Nasser M. Abbasi <nma123>


Attached Files
file #241:  savetrees.patch added by michal_h21 (3kB - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by karl (Posted a comment)
  • -unavailable- added by michal_h21 (Posted a comment)
  • -unavailable- added by nma123 (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    2 latest changes follow.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri Jul 1 16:21:10 2016karlOpen/ClosedOpen=>Closed
    Thu Jun 9 22:15:38 2016michal_h21Attached File-=>Added savetrees.patch, #241
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup+gray