[OS X TeX] LaTeX conversion to eBook?

Axel Kielhorn tex at axelkielhorn.de
Wed Apr 25 19:49:55 CEST 2012


Am 25.04.2012 um 17:48 schrieb David Derbes:

> Some years ago a friend and I retyped, edited and otherwise modernized an old book in LaTeX (to PDF) for its subsequent reissue (The Einstein Theory of Relativity by Lillian and Hugh Lieber). The firm that reissued it, Paul Dry Books of Philadelphia, is thinking about doing it as an eBook. They have a firm that converts their books to ePub format and has done their non-technical stuff for a fee. The firm wants three times their usual fee for this one. I am hoping to find a much cheaper (or even free, with my sweat equity) solution. 
> 
> I suspect that someone (or several someones) on this list have a very simple solution. Is there a package for turning a LaTeX'd book into ePub format?

Have a look at

http://johnmacfarlane.net/pandoc/releases.html

You can convert LaTeX to LaTeX to see how much of the original book gets lost.
If that looks promising you should convert the file to markdown and use that to create pdf (via LaTeX) and ePub.

Please note that math on an ebook reader may be problematic.
You should try an example on Adobe Digital Edition and Kindle Previewer first to learn the limitations.[1] Including math as images may be the only option.

Axel

[1] You can create a simple markdown document with the formulas you need.
You may have to install additional fonts (I'm using Free Serif on my ebook reader because the standard fonts don't have the characters needed for simple math.)

From the readme:

Anything between two `$` characters will be treated as TeX math.  The
opening `$` must have a character immediately to its right, while the
closing `$` must have a character immediately to its left.  Thus,
`$20,000 and $30,000` won't parse as math.  If for some reason
you need to enclose text in literal `$` characters, backslash-escape
them and they won't be treated as math delimiters.

TeX math will be printed in all output formats. How it is rendered
depends on the output format:

HTML, Slidy, DZSlides, S5, EPUB
  ~ The way math is rendered in HTML will depend on the
    command-line options selected:

    1.  The default is to render TeX math as far as possible using unicode
        characters, as with RTF, DocBook, and OpenDocument output. Formulas
        are put inside a `span` with `class="math"`, so that they may be
        styled differently from the surrounding text if needed.

    2.  If the `--latexmathml` option is used, TeX math will be displayed
        between $ or $$ characters and put in `<span>` tags with class `LaTeX`.
        The [LaTeXMathML] script will be used to render it as formulas.
        (This trick does not work in all browsers, but it works in Firefox.
        In browsers that do not support LaTeXMathML, TeX math will appear
        verbatim between $ characters.)

    3.  If the `--jsmath` option is used, TeX math will be put inside
        `<span>` tags (for inline math) or `<div>` tags (for display math)
        with class `math`.  The [jsMath] script will be used to render
        it.

    4.  If the `--mimetex` option is used, the [mimeTeX] CGI script will
        be called to generate images for each TeX formula. This should
        work in all browsers. The `--mimetex` option takes an optional URL
        as argument. If no URL is specified, it will be assumed that the
        mimeTeX CGI script is at `/cgi-bin/mimetex.cgi`.

    5.  If the `--gladtex` option is used, TeX formulas will be enclosed
        in `<eq>` tags in the HTML output.  The resulting `htex` file may then
        be processed by [gladTeX], which will produce image files for each
        formula and an `html` file with links to these images.  So, the
        procedure is:

            pandoc -s --gladtex myfile.txt -o myfile.htex
            gladtex -d myfile-images myfile.htex
            # produces myfile.html and images in myfile-images

    6.  If the `--webtex` option is used, TeX formulas will be converted
        to `<img>` tags that link to an external script that converts
        formulas to images. The formula will be URL-encoded and concatenated
        with the URL provided. If no URL is specified, the Google Chart
        API will be used (`http://chart.apis.google.com/chart?cht=tx&chl=`).





More information about the macostex-archives mailing list