Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Generating ePub from LaTeX (minireference.com)
99 points by ivan_ah on March 5, 2021 | hide | past | favorite | 13 comments


The code repo containing the automation scripts and a "demo" book is here: https://github.com/minireference/sample-book


Just want to note that EPUB 3.0 supports MathML.


Interesting. Do you happen to know which eReader devices (and ePub readers in general) support it?

MathML would be so much easier than images!


Webkit-based renderers support it, and AFAIK that means just iBooks, Kobo when using its kepub flavor of epub (but not in regular epubs, which trigger its inferior renderer), and software like Foliate. At Standard Ebooks we use MathML in our core source (see for example the Tractatus[1]) and during build it's rendered to PNG for maximum compatibility since so few ereaders support MathML right now.

[1] https://standardebooks.org/ebooks/ludwig-wittgenstein/tracta...


Which readers support ePub 3.0 and MathML? I don't think (full) support is that common. Would be interested in a caniuse.com like overview


In what sense? I thought epub was just the container format, you could put raw LaTeX in it if you really wanted to (though I'm not sure if there's a mime-type for it).


If ePub were just a container format, there would be interoperability headaches galore. Part of the ePub standard specifies how to format a book's contents as a mixture of HTML, CSS, and a handful of basic image types that readers are required to support. And now, apparently, MathML.


I enjoy reading descriptions about how various people solve their problems. This is nice! One question I had was why the author uses softcover instead of pandoc. Is it a preference or a technical reason?


The main reason is to have more control of how the math equations are rendered (the way softcover converts math to images is best-in-class). I also had a bunch of custom macros and environments that I knew how to do by adapting/extending softcover, and comparatively little experience with pandoc filters.

That being said, I've recently used pandoc for another project (a paper) and I really liked the result and the functionality (references using BibTex). Also, I see modern pandoc has support for MathML and even image math https://pandoc.org/epub.html#math so will be doing some testing to see how it works...


If you find success doing this with pandoc, please consider writing another blog post! I’ve had a ton of similar issues in this space and reading your solutions has given me a bunch of ideas.


Thanks, that is a great answer!


What an interesting article! I learned a couple of very useful things from it for a project I am starting, so thank you. I wonder, OP, if you looked into TeX4ht (https://www.tug.org/tex4ht/) at all?


Nice work. There is not enough support for stuff like this.

I’ve wanted forever to have a nice way to convert latex files to html. I wish I could use latex for my static site instead of markdown and I’ve tried a few things but nothing is consistent enough. This gives me a ton of hope!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: