4

I've spent a considerable about of time trying to figure out how I can take a markdown file, which contains TeX math and convert it into an ePub file where the math is rendered properly.

For example:

This is a markdown file. Here is a [link](www.example.com).

Here is some inline math: $\sigma_{i=1}^n \frac{\mu}{100}$

Here is an equation:

$$ y = mx + b $$

How can I convert a markdown file with the above text into an ePub file?

I've experimented with different methods of conversion using Pandoc; however, I still can not find a solution which renders the math even 50% correct.

Can anyone provide any help as to how I can do this?

I've tried this solution as well as other Pandoc option without success. Thanks in advance for the help.

Community
  • 1
  • 1
drbunsen
  • 10,139
  • 21
  • 66
  • 94
  • I see ePub supports vector images. So, isn't this only a matter of running pdflatex on the equations on page without decorations, crop the PDF, convert to SVG, and inline the result in the ePub file ? After you get that working, then you will need some way to determine a correct base height for each inlined equation to get a consistent layout. – mmgp Dec 21 '12 at 15:44
  • 1
    Here's a read: [Use LaTeX to produce Epub](http://tex.stackexchange.com/q/1551/5764) – Werner Dec 21 '12 at 16:58

1 Answers1

6

Pandoc has an EPUB3 writer. It renders latex math into MathML, which EPUB3 readers are supposed to support (but unfortunately still few do). Use pandoc -t epub3 to force EPUB3 output, as opposed to EPUB2 which is the default.

Of course, this isn't much help if you want EPUB2 output or target readers that don't support MathML. Then you could try using the --webtex option, which will use a web service to convert the TeX to an image.

mb21
  • 34,845
  • 8
  • 116
  • 142
John MacFarlane
  • 8,511
  • 39
  • 33
  • 2
    John, thanks for taking the time to reply. pandoc-1.10 failed during the building phase, but I can wait until the next version now that I know what to do. Thanks for all your work on Pandoc, it's fantastic! – drbunsen Dec 21 '12 at 21:27