MathBook: An XML Application

This page is frozen, as of September 2013

Please go to the MathBook XML site for current progress.

This page reports progress initiated with a Shuttleworth Flash Grant, and sustained with support from National Science Foundation under Grant No. DUE-1022574.

Frozen Content (September 2013)

A specification for XML tags and stylesheets to create mathematical content that yields usable output.

Shuttleworth Funded

Rob Beezer,

Design Goals:

  1. Simple for authors to use - no more complicated logically than LaTeX
  2. Capture the structure of writing about mathematics and Sage
  3. Processing into a variety of formats
  4. A limited number of rational tags, with simple names
  5. Minimal use of external shell scripts
  6. XSLT 1.0 compatible: ideally the only semi-unusual required tool is xsltproc

Output Formats:

  1. HTML web pages, enhanced with MathJax, Sage Cell server, knowls for web browsing

  2. LaTeX input as precursor of PDF output via pdflatex for print

  3. Doctesting of Sage code examples for quality assurance
  4. Sage Worksheets (Sage Notebook, Sage Math Cloud)
  5. E-Books, once technically feasible
  6. Maybe a DocBook representation for conversion to other outputs and future-proofing

Project Status:

Examples (Updated 2013/08/23)

  1. A short sample article: XML Source-Author Format <HTML Output> <PDF Output>

  2. A skeletal mock book: XML Source-Author Format <HTML Output> <PDF Output>


High-level commentary is recorded on my blog.

June 14 June 27, 2013 June 28, 2013 August 23, 2013

Implemented Features

Files and Commands, the nitty-gritty

Updated: August 23, 2013

Prerequisites: xsltproc is in most Linux distributions and on Mac OS as a command-line executable. Information on Windows availablity would be helpful - please write. You'll need TeX to run pdflatex. You can author if you also have a text editor and a browser - that is all you need.

HTML output: MathJax does the math, Sage Cell Server does the code, knowls do the citations. Use the following command and files below to create (X)HTML output and view in your browser by opening the output file.

xsltproc mathbook-html.xsl calculus-article.xml > calculus-article.html

PDF: Same XML source file. Use a different XSLT file to process. View PDF as you please. Issue the following to produce.

xsltproc mathbook-latex.xsl calculus-article.xml > calculus-article.tex
pdflatex calculus-article.tex

More: repeat above with the mock book, graph-theory-book.xml, linked above.

Advanced: create a Sage Cloud worksheet from the same source. I have this working in the lab. Posted soon.

Files: Use your browser to save these files locally, do not simply click on them. The XSL files can be scary - not critical for an author to understand them. You'll want the CSS to render any HTML you produce.

  1. XSL transform to HTML

  2. XSL transform to LaTeX

  3. MathBook CSS

The AQ (Asked Questions)

  1. I can't seem to get a matrix into my document.
    It's math so put it inside <m> or <me> or <md> tags and use LaTeX syntax (amsmath package supported). But the ampersand is one of two troublesome special characters in XML, so you need to escape it. Like so

    <me>\begin{bmatrix} 1 &amp; 2 \\ 3 &amp; 4 \end{bmatrix}</me>
    Or you can wrap the whole thing as a CDATA section (which will cause all markup to be ignored). This might be preferable for a big matrix.
    <me><![CDATA[\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}]]></me>
  2. I have a "less than" in my math which is causing problems.
    The other nasty special character. Use \lt instead of <.

To Do (unprioritized)

Other Projects

mathbook (last edited 2014-04-30 17:24:35 by rbeezer)