Friday, November 11, 2011

Getting Better Math from htlatex

I am happy to report that I have solved one more issue involved with producing good ebooks from a LaTeX source.  So far I have discovered how to use a configuration file to force htlatex to produce png images for displayed math and tables.  This can also be done to render arrays and eqnarrays as images.  Unfortunately when I view my equations and tables on the Kindle they look a little small and grayer than normal text.

The solution to these problems is to modify /etc/tex4ht/tex4ht.env changing the default parameters for the dvipng command.  The original line looks like this

    Gdvipng -T tight -x 1400 -D 72 -bg Transparent -pp %%2:%%2 %%1 -o %%3

My updated file has this line

    Gdvipng -T tight --gamma 1.5 -x 1600 -D 72 -bg Transparent -pp %%2:%%2 %%1 -o %%3

The -x option is a magnification so my output is about 14% larger.  The --gamma 1.5 option sets the gamma value (default 1) to 1.5 to force the text to appear darker.

Here is what I would normally get:


Here is what I get with the revised parameters for dvipng:


This is darker without being harsh and is large enough to make my rendered math a little more readable on Kindles, Nooks and other e-readers.

No comments: