Reputation: 1273
I've been writing some documents with Knitr and Rmarkdown to .pdf, but it turns out I need to have then in .epub format instead.
I had been running a command like this to convert the .md files to .epub.
pandoc --mathjax -s --highlight-style tango file.md --to epub -o output.epub
That seems to have some issue handling latex code, though. Inline latex code with $x_1$
, for example, seems to work fine. However, for latex blocks like:
$$
x_1 = 1, x_2 = 1 \\
h(x) = f(-20 + 15 + 17) \\
h(x) = f(12) \approx 1 \\
$$
It just displays the raw latex:
\[ x\_1 = 1, x\_2 = 1 \\\\ h(x) = f(-20 + 15 + 17) \\\\ h(x) = f(12) \\approx 1 \\\\ \]
Am I using latex for multi-line equations wrong in Rmarkdown? Is there a recommended way to get big chunks of latex working with Epub?
Upvotes: 1
Views: 338
Reputation: 39508
From Creating an ebook with pandoc :
Pandoc has an EPUB3 writer. It renders LaTeX math into MathML, which EPUB3 readers are supposed to support (but unfortunately 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 should try using the
--webtex
option, which will use a web service to convert the TeX to an image.
Upvotes: 1
Reputation: 73592
Though I can't really reproduce your issue (at least the line breaks are discarded) -- eventually it's worth to use some more latex code for your equation:
\begin{equation}
\begin{aligned}
\label{eq7}
x_1 = 1, x_2 = 1 \\
h(x) = f(-20 + 15 + 17) \\
h(x) = f(12) \approx 1 \\
\end{aligned}
\end{equation}
Upvotes: 0