# How to make ebook-friendly formula heavy documents?

Tablets and ebook readers can be very useful if you have to read a lot of scientific texts and papers, and don't want to print them all out. However, it can sometimes be really annoying, especially if you are reading PDFs on a 7 inch tablet. Either you display the whole page in portrait, but then the fonts are too small, or you view it in landscape, and you have to scroll a lot. Many programs have a "reflow" mode, but that completely breaks texts with formulas.

I'd like to make some scientific texts I'm working on tablet friendly, with special emphasis that the formulas and figures remain readable. The end goal is of course to convince others to do the same. The output should be either:

• A reflow friendly PDF.
• A PDF with different page sizes, depending on the device (is that possible? it would certainly be useful).
• In a dedicated ebook format.

The first two options would be definitely preferable, as I'd only have one file. If people download it for their tablet, they wouldn't have to redownload it for printing.

The formulas in my document are short enough that they don't have to be relayouted (if there are some that need it, they are few, and I can do it easily by hand).

I'm not so much concerned about the actual layouting, that is covered in other questions (for kindle, regarding margins), and I can do that myself. I'm wondering with what commands I can actually produce a "smart" PDF, or a ebook file, with emphasis on formula-heavy text (e.g. conversion to HTML and then to something else would likely give bad looking formulas).

• epub3 format has standard support for MathML, so you should be able to get high quality rendering in an html based epub3 ebook. Unfortunately though support in current implementations is sketchy at present. However webkit does have mathml support in its base these days (not always turned on in implementations) and some ebook makers are looking at mathjax so it will get better but it's not quite there yet.... – David Carlisle Apr 19 '13 at 13:02
• Yes, the best I managed to do was to export the document to HTML with the formulas in MathJax. It looks really nice, but I never finished that project. By the way, I don't actually need mathml, or any structured representation of math. It'd be fine (and I'd actually prefer) if LaTex would render the math (to vectors or high res bitmaps), and just put it in boxes so the reader knows where to break. – jdm Apr 19 '13 at 13:10
• There are lots of latex to html convertors that will convert latex to html and include images for the math (latex2html, tex4ht, for example) they both have mathml support these days but originally (and still an option) they made images for math. – David Carlisle Apr 19 '13 at 13:19
• Kevin Klement's version of Bertrand Russell's Philosophy of Mathematics is available in a number of screen size versions and includes source, and exists in an ePub version: people.umass.edu/klement/russell-imp.html – WillAdams Jul 31 '13 at 17:08

In reference to your E-Reader / Tablet issue, I had the same problem a few weeks ago and found the answer (or at least the idea for it) on wikipedia. Granted, an HTML version would be best, but if possible, a simple compilation to a second file type would save you hours of eye strain and problems. If your viewers are capable, a two file system may be best. Specifically for tablets, it turns out that the specifications for the Supreme Court briefs are just about perfect for viewing on a tablet. From Wikipedia ( http://en.wikibooks.org/wiki/LaTeX/Page_Layout )

Those who want to read on tablets or other handheld digital devices need to create documents without the extra whitespace. In order to create PDF documents with optimal handheld viewing, not only must the text field and margins be adjusted, so must the page size. If you are looking for a sensible dimension, consider following the paper size used by the Supreme Court of the United States, 441pt by 666pt (or 6.125 inches by 9.25 inches), which looks great on tablets. You could also use the Supreme Court's text field size of 297 pt by 513 pt, but this is too wide for fonts other than Century Schoolbook, the font required by the Supreme Court.

Here was my implementation of it. It is rather bullish and perhaps someone has a better working, but it works perfect for tablet viewing :)

% Adjust The page size via use of the geometry package
\usepackage[paperwidth=441pt, paperheight=666pt,
textwidth=297pt,textheight=513pt]{geometry}

% Use the New Century SchoolBook font and fourier math
\usepackage{fouriernc}


Note you can use any font you want, but with a high x-height and excellent readability on both tablet and print, this is an excellent choice. If it is truly to be a "tablet" viewing document, maybe even a sans font may be the ticket as they have better readability on low-res screens as well.

There is a way to accomplish the third option, which may end up being relatively hassle free.

You should be able to manage it with the pandoc command line tool. This is a package written in Haskell that converts between several different document formats. I think it's most powerful when converting documents written in markdown to many of other formats (e.g., HTML, docx, LaTeX). But you can also use it to convert from LaTeX to epub or epub3.

From the introduction:

LaTeX math (and even macros) can be used in markdown documents. Several different methods of rendering math in HTML are provided, including MathJax and translation to MathML. LaTeX math is rendered in docx using native Word equation objects.

So it should be able to manage your formulas.

You should test to see if the packages your LaTeX document use are supported by pandoc. I've read somewhere (I can't recall where) that pandoc doesn't do a great job with non-standard packages or with custom (user-defined) macros.

Anyway, pandoc is relatively well-documented, and there are even examples for making an ebook.

• Don't get me wrong, pandoc is nice, but it can't realistically do a book-grade conversion of LaTeX to anything viewable on most ebook reader (or anything at all IME). This has a lot to do with package support, but not exclusively. – Chris H Sep 30 '13 at 12:18