Transcript
Page 1: Automated Equation Processing and Rendering Workflows for Publishers

Automated Workflows for Mathematical Equation

Processing and Rendering

EDUPUB 2013 October 29, 2013

Sanders Kleinfeld O’Reilly Media, Inc.

Page 2: Automated Equation Processing and Rendering Workflows for Publishers

Or:

!b ± b2 ! 4ac2a

Page 3: Automated Equation Processing and Rendering Workflows for Publishers

How should I produce books with

complex mathematical

content?

Page 4: Automated Equation Processing and Rendering Workflows for Publishers

Publishers often go one of two

routes for source files…

Page 5: Automated Equation Processing and Rendering Workflows for Publishers

Typeset with LATEX! \section{Bayes's Theorem}

At this point we have everything we need to derive Bayes's Theorem. We'll start with the observation that conjunction is commutative; that is % \[ \p{A \AND B} = \p{B \AND A} \] % for any events $A$ and $B$. \index{Bayes's Theorem derivation} \index{conjunction}

Next, we write the probability of a conjunction: % \[ \p{A \AND B} = \p{A}~\p{B|A} \] %

(Source From Think Bayes [O’Reilly Media]: http://code.google.com/p/thinkstats/source/browse/trunk/thinkbayes/book.tex#634)

Page 6: Automated Equation Processing and Rendering Workflows for Publishers

OR…

Page 7: Automated Equation Processing and Rendering Workflows for Publishers

Just Embed Images!

(From Head First Algebra [O’Reilly Media])

Page 8: Automated Equation Processing and Rendering Workflows for Publishers

Downsides of LATEX approach:

Downsides of image approach:

•  What if you don’t want to build a TEX toolchain?

•  LATEX is great for PDF export, but what about output to EPUB/Mobi?

•  Maintenance is a pain! •  How to scale/optimize for different

output formats?

Page 9: Automated Equation Processing and Rendering Workflows for Publishers

O’Reilly’s Solution: Embed LATEX

in Standard ASC or DB Source

(From High Performance Browser Networking [O’Reilly Media])

Instead, we start with a small congestion window and double it for every roundtrip--i.e., exponential growth. As a result, the time required to reach a specific throughput target is a function (<<SS_TIME>>) of both the roundtrip time between the client and server and the initial congestion window size. [[SS_TIME]] [latexmath] .Time to reach the cwnd size of size N ++++ \begin{aligned} \mathrm{Time} = \mathrm{RTT} \times \left\lceil log_2 \left( \frac{\mathrm{N}}{\mathrm{initial\ cwnd}} \right) \right\rceil \end{aligned} ++++

Page 10: Automated Equation Processing and Rendering Workflows for Publishers

BUT…

Page 11: Automated Equation Processing and Rendering Workflows for Publishers

How do I render embedded LATEX for

all my different (e)book outputs?

Page 12: Automated Equation Processing and Rendering Workflows for Publishers

What about MathML? (http://www.w3.org/Math/)

Page 13: Automated Equation Processing and Rendering Workflows for Publishers

MathML Rendered to PDF*

* With AntennaHouse Formatter

Page 14: Automated Equation Processing and Rendering Workflows for Publishers

MathML in EPUB (iBooks)

Page 15: Automated Equation Processing and Rendering Workflows for Publishers

MathML in EPUB (NOOK)

Page 16: Automated Equation Processing and Rendering Workflows for Publishers

MathML in Mobi (Kindle Fire)

Page 17: Automated Equation Processing and Rendering Workflows for Publishers

OK, what about SVG? (http://www.w3.org/Graphics/SVG/)

Page 18: Automated Equation Processing and Rendering Workflows for Publishers

SVG Rendered to PDF*

* With AntennaHouse Formatter

Page 19: Automated Equation Processing and Rendering Workflows for Publishers

SVG in EPUB (iBooks)

Page 20: Automated Equation Processing and Rendering Workflows for Publishers

SVG in Mobi (Kindle Paperwhite)

Page 21: Automated Equation Processing and Rendering Workflows for Publishers

SVG in Mobi (Kindle “classic”)

Page 22: Automated Equation Processing and Rendering Workflows for Publishers

Gah, what’s left? JPEG or PNG?

Page 23: Automated Equation Processing and Rendering Workflows for Publishers

Well, yes. Only standard bitmap image formats work

reliably everywhere

Page 24: Automated Equation Processing and Rendering Workflows for Publishers

BUT…

Page 25: Automated Equation Processing and Rendering Workflows for Publishers

Why do we need a one-size-fits-all

solution?

Page 26: Automated Equation Processing and Rendering Workflows for Publishers

Can’t we optimize equation output separately for each format?

Page 27: Automated Equation Processing and Rendering Workflows for Publishers

“Frustrated man at a desk” (by LaurMG; http://commons.wikimedia.org/wiki/File:Frustrated_man_at_a_desk_(cropped).jpg)

Page 28: Automated Equation Processing and Rendering Workflows for Publishers

Don’t Worry!

Page 29: Automated Equation Processing and Rendering Workflows for Publishers

Make an API!

Page 30: Automated Equation Processing and Rendering Workflows for Publishers

O’Reilly Media’s Math Conversion API (a.k.a. STIX)

LATEX Source

MathML Source STIX

EPUB Equation

Mobi Equation

PDF Equation

Web Equation

Page 31: Automated Equation Processing and Rendering Workflows for Publishers

STIX: Under the Hood

LATEX

tralics

Source Format

Output Format

(http://www-sop.inria.fr/marelle/tralics/)

MathML

MathML

SVGMath (http://sourceforge.net/projects/svgmath/)

SVG

rsvg (https://developer.gnome.org/rsvg/stable/)

PNG

Conversion Tool

Intermediate Format

Page 32: Automated Equation Processing and Rendering Workflows for Publishers

Equation Output Formats Per Ebook Format

EBOOK Format Equation Output Format

EPUB PNG

Mobi PNG

PDF MathML (rendered by AntennaHouse Formatter*)

HTML (for Web) LATEX or MathML (with MathJax** for rendering)

* http://www.antennahouse.com/ ** http://www.mathjax.org/

Page 33: Automated Equation Processing and Rendering Workflows for Publishers

Future Improvements

•  MathJax-based engine for STIX (à la svgtex)

•  Improved Accessibility!

(alt text for PNG via ChromeVox)

https://github.com/agrbin/svgtex

http://kefletcher.blogspot.com/2013/07/next-steps-from-accessibility-sprint.html

Page 34: Automated Equation Processing and Rendering Workflows for Publishers

Contact Me! Email: [email protected]

Twitter: @sandersk


Top Related