LaTeX to EPUB to Kindle

43 views
Skip to first unread message

Rob Beezer

unread,
Jan 18, 2018, 5:40:02 PM1/18/18
to mathja...@googlegroups.com
A progress report, and a request for hints on which way to go next. I'm using
mathjax-node 0.50, which I know is really out-of-date, but I'm trying to control
as many variables as possible before I make big changes to my pipeline.


* With page2svg I'm able to convert my HTML files to incorporate SVG images
for the math and pack them up as an EPUB3 file. It renders beautifully in
iBooks - fairly quick to load, and reflows/rescales nicely. Really nice.

* I ran this EPUB3 through Amazon's KindleGen. Viewing the result in the
Android Kindle app, all the math SVGs are no more than a faint dot. I used
KindleUnpack to see what was happening. Appears all the "svg" elements get
converted from inline use to external files incorporated with the "img" element.
So the glyph information near the top of each page is an external image file
and the math-bits are their own files. Which would seem to be enough to explain
why they don't render.

* Just tried the same drill with page2png. The PNG images do survive the trip
through KindleGen and the book renders quite well in my Kindle app on Android.
However the PNG images do not scale, and at large magnifications the baseline of
the math appears way below the baseline of the surrounding text. Also, the font
weight seems a bit greater for the math bits compared to the SVG versions.


So I feel like iBooks device is in good shape, and Kindle is the next
device/hurdle. I've looked at all the re-arrangements for mathjax-node as of
1.0. Despite not using Javascript too much, I should be able to cobble
something together.


* Is there now a way to create SVG output where the SVG are self-contained and
the KindleGen step will not separate the font information? My other SVG images
(diagrams) seemed to survive the KindleGen re-structuring just fine.

* If not, will mathjax-node-svg2png produce something more robust in and of
itself, so as to survive the KindleGen step and look consonant with its
surroundings?

* If the above approaches don't sound optimal with the newer versions of
mathjax-node, does anybody have any hints on how to leverage MathJax to get to
an acceptable Kindle version?


Thanks in advance for any replies pointing me in the right direction.

Rob

Davide Cervone

unread,
Jan 19, 2018, 11:49:00 AM1/19/18
to mathja...@googlegroups.com
> * Is there now a way to create SVG output where the SVG are self-contained and the KindleGen step will not separate the font information?

The page2svg command has a --localcache option that will prevent the use of a global <defs> object and instead use a separate <defs> tag in each equation. That should isolate the images. If that doesn't work, try --nofontcache, which will prevent using <defs> and <use> entirely. This might be needed if the <use> links aren't being handled properly even with a local <defs> tag.

Glad you are making progress on your workflow!

Davide

Rob Beezer

unread,
Jan 19, 2018, 12:31:24 PM1/19/18
to mathja...@googlegroups.com
Dear Davide,

Thanks! That sounds like just what I need. I saw some reference to a cache
when I was looking through some of the newer scripts, but had not seen it for my
out-of-date version.

I'll experiment and report back.

Rob
Reply all
Reply to author
Forward
0 new messages