[tex4ht] [bug #309] tex4ht does not work with package savetrees
Michal Hoftich
michal.h21 at gmail.com
Wed Jun 8 11:58:54 CEST 2016
Follow-up Comment #1, bug #309 (project tex4ht):
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\><<<
savetrees,>>>
\<add to usepackage\><<<
\def\:temp{savetrees}\ifx \@currname\:temp
% code to be executed
\fi
>>>
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
\newcommand{\dontusepackage}[2][]{%
\@namedef{ver@#2.sty}{9999/12/31}%
\@namedef{opt@#2.sty}{#1}}
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:
\let\:onefilewithoptions\@onefilewithoptions
\def\@onefilewithoptions#1[{%
\let\:temp\@reset at ptions
\def\@reset at ptions{%
\let\@reset at ptions\:temp
\edef\TivhTcats{%
\catcode`:=\the\catcode`:%
\catcode`@=\the\catcode`@}%
\catcode`\:=11 \catcode`\@=11
\a:usepackage
\TivhTcats
}%
\:onefilewithoptions#1[}
The original \@onefilewithoptions has following parameters
\def\@onefilewithoptions#1[#2][#3]#4{%
where the second argument are package options. We can change the tex4ht
redefinition slightly:
\let\:onefilewithoptions\@onefilewithoptions
\def\@onefilewithoptions#1[#2]{%
\let\:temp\@reset at ptions
\def\@reset at ptions{%
\let\@reset at ptions\:temp
\edef\TivhTcats{%
\catcode`:=\the\catcode`:%
\catcode`@=\the\catcode`@}%
\catcode`\:=11 \catcode`\@=11
\def\:currentoptions{#2}
\a:usepackage
\TivhTcats
}%
\:onefilewithoptions#1[#2]}
as you can see, new macro is defined, holding package options. We can then
define macro for blocking package loading like:
\newcommand{\:dontusepackage}[2][\:currentoptions]{%
\@namedef{ver@#2.sty}{9999/12/31}%
\@namedef{opt@#2.sty}{#1}
}
What do you think? Is that change safe?
_______________________________________________________
Reply to this item at:
<http://puszcza.gnu.org.ua/bugs/?309>
_______________________________________________
Message sent via/by Puszcza
http://puszcza.gnu.org.ua/
More information about the tex4ht
mailing list