Configuration for TeX4ht

1. Handling Japanese Documents

We can convert Japanese TeX documents by using NTT-JTeX.
The method I'm using now is written here, although it is not very satisfactory yet.

2. Conversion of Math Formulas into Pictures

I had to play with the configuration file /etc/tex4ht/tex4h.env to produce graphics files with satisfactory quality within reasonable time. The current Debian package works fine with the default setting.
The following is my current configuration.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% tex4ht.env  / .tex4ht          unix                               %
%                                                                   %
% Notes:                                                            %
%  1. Empty lines might be harmful                                  %
%  2. Tagged script segments <tag>...</tag> are scanned only if     %
%     their names are specified within -ctag switches of tex4ht.c   %
%     and t4ht.c. When -c switches are not supplied, a -cdefault    %
%     is implicitly assumed.                                        %
%  3. Place this file in your work directory and/or root directory  %
%     and/or in directory `xxx' of your choice. In the latest case, %
%     compile tex4ht.c and t4ht.c with `#define ENVFILE xxx', or    %
%     provide the address of the file to tex4ht and t4ht throught   %
%     the -e switch                                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% * Replace `path', and possibly what follows, with appropriate     %
%   content                                                         %
% * A path may start with:                                          %
%   ~ for environment variable HOME                                 %
%   ~~ for environment variable TEX4HTTFM                           %
% * A ! requests recursive search into subdirectories               %
% * Multiple t and i entries are allowed                            %
% * When supported by kpathsea                                      %
%   + t entries are ignored                                         %
%   + the path before /ht-fonts/ is ignored in i records that don't %
%     represent real addresses                                      %
%   + (see /usr/share/doc/tex4ht/README.kpathsea for details)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%tpath/tex/texmf/fonts/tfm/!
%
<default>
i/usr/share/texmf/tex4ht/ht-fonts/iso8859/1/!
i/usr/share/texmf/tex4ht/ht-fonts/alias/!
i/usr/local/lib/texmf/tex4ht/ht-fonts/mozilla/!
</default>
%                                                                   %
<mozhtf>
i/usr/share/texmf/tex4ht/ht-fonts/mozilla/!
i/usr/share/texmf/tex4ht/ht-fonts/unicode/!
i/usr/share/texmf/tex4ht/ht-fonts/iso8859/1/!
i/usr/share/texmf/tex4ht/ht-fonts/alias/!
</mozhtf>
%
<unihtf>
i/usr/share/texmf/tex4ht/ht-fonts/unicode/!
i/usr/share/texmf/tex4ht/ht-fonts/iso8859/1/!
i/usr/share/texmf/tex4ht/ht-fonts/alias/!
</unihtf>
%                                                                   %
<symhtf>
i/usr/share/texmf/tex4ht/ht-fonts/unicode/!
i/usr/share/texmf/tex4ht/ht-fonts/iso8859/1/!
i/usr/share/texmf/tex4ht/ht-fonts/alias/!
</symhtf>
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% dvi-to-gif/png scripts                                            %
%                                                                   %
% lyx-users:  you may have to replace the %%4 with %%3 to get these %
% scripts to work, one user has reported problems with the default  %
% scripts below.                                                    %
%                                                                   %
% dvips options                                                     %
%   magnification: -x mag  (e.g., -x 1200)                          %
%   page size:     -T x,y  (e.g., -T 14in,14in)                     %
%                                                                   %
% Default script for generating bitmaps, using imagemagick:
Gdvips -mode ibmvga -D 110 -f %%1 -pp %%2 > zz%%4.ps
Gps2pdf zz%%4.ps zz%%4.pdf
Gconvert  -crop 0x0 -density 110x110 -transparent '#FFFFFF' zz%%4.pdf %%3
Grm zz%%4.ps
Grm zz%%4.pdf
%
% If you have installed netpbm instead of imagemagick package, delete the 'G'
% lines above and remove the initial space from the lines following, to
% substitute an alternative script for generating the bitmaps.
 % Alternative script using netpbm utilities instead of imagemagick:
 Gdvips -Ppdf -mode ibmvga -D 110 -f %%1 -pp %%2 > zz%%4.ps
 Ggs -sDEVICE=ppm -sOutputFile=zz%%4.ppm -q -dbatch -dNOPAUSE zz%%4.ps -c quit
 Gpnmcrop  zz%%4.ppm > zzz%%4.ppm
 Gpnmtopng -interlace -transparent=rgb:ff/ff/ff zzz%%4.ppm > %%3
 Grm zz%%4.ps
 Grm zz%%4.ppm
 Grm zzz%%4.ppm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Default scripts, shifted rightward 1 pos
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 s--- needs --- %%1.idv[%%2] ==> %%3 ---
 b--- characters ---
% upstream default changed to generate PNG representations of symbols:
g.png
% empty gifs                                                        %
 Ecopy  empty.gif %%1%%2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% * Address for an automatically created bookkeeping file           %
% * Ignored under kpathsea                                          %
% * The work directory is assumed for a default                     %
 l~/tex4ht.dir/tex4ht.fls
%
% t4ht -d%%2                                                        %
Mmv %%1 %%2%%3
Ccp %%1 %%2%%3
% t4ht -d%%2 -m%%1                                                  %
Achmod %%1 %%2%%3
% removed protection                                                %
S*
% validations, XSTL tranformations,...                              %
 Xmake -f NSGMLS name=%%1  ext=%%2
%
<oo>
%%% openoffice                                                      %
.4os mkdir sxw-%%0.dir
.4os mkdir sxw-%%0.dir/Pictures
.4os mv    %%1.4os         sxw-%%0.dir/settings.xml
.4os mv    %%0.xml         sxw-%%0.dir/content.xml
%                                                                   %
.4om mkdir sxw-%%0.dir/%%1
.4om mv    %%1.4om         sxw-%%0.dir/%%1/content.xml
.4om cp    sxw-%%0.dir/settings.xml  sxw-%%0.dir/%%1/settings.xml
%                                                                   %
.4of mkdir sxw-%%0.dir/META-INF
.4of mv    %%1.4of         sxw-%%0.dir/META-INF/manifest.xml
%                                                                   %
.4ot mv    %%1.4ot         sxw-%%0.dir/meta.xml
.4oy mv    %%1.4oy         sxw-%%0.dir/styles.xml
.4og mv    %%1             sxw-%%0.dir/Pictures/%%1
%                                                                   %
.4ox cd sxw-%%0.dir; zip -r %%0.sxw * ; cd ..
%                                                                   %
.4ox mv    sxw-%%0.dir/%%0.sxw .
%                                                                   %
.4ox rm    %%1.4ox
.4ox rm -r -f sxw-%%0.dir
%%% end openoffice                                                  %
</oo>
%
% end of file                                                       %
The math formulas are converted into PDF and the into graphics files. This reduces the conversion time a lot.

3. Capacity of TeX

When I TeX4ht-ed my lecture note on fiber bundles and fibrations, TeX4ht stopped with "tex capacity exceeded" error. There was no problem when typeset it with TeX.
I added the following lines to /etc/texmf/texmf.cnf.
% Settings for latex and jlatex to be used
% in conjunction with TeX4ht.
  extra_mem_top.latex = 100000
  extra_mem_top.jlatex = 100000
  extra_mem_bot.latex = 100000
  extra_mem_bot.jlatex = 100000
  hash_extra.latex = 30000
  hash_extra.jlatex = 30000
  pool_size.latex = 250000
  pool_size.jlatex = 250000