200 likes | 349 Views
Beautiful maths in all browsers. Introduction. Input and display of non-trivial maths to any electronic format problematic …and even more of a pain for display on web pages. Input : can be slow and cumbersome – the natural UI is pen and paper
E N D
Introduction • Input and display of non-trivial maths to any electronic format problematic • …and even more of a pain for display on web pages. • Input: can be slow and cumbersome – the natural UI is pen and paper • Display: we still live in a predominantly western ASCII world. Mathematical type setting far more complex
“MUR FIRST ORDERBOUNDARY CONDITION” • Many non-alphanumeric symbols • Lines (sometimes curved) use to indicate expressions and function.
2D arrays… • Correct alignment essential else meaning can be lost
Standards for representing mathematical notation in ASCII • MathML • A language of the web for the presentation and meaning of formula components. • A W3C ‘proposed recommendation’ (as of 10/08/2010) • Browser support patchy • Firefox and other Gecko based browsers – good native support • Opera – partial native support, some problems • IE – not natively (only with plugin) • IE9 – reportedly buggy support • Safari/Chrome – ??? reportedly only in nightly builds (browser tests using https://eyeasme.com/Joe/MathML/MathML_browser_test.html) • But a common output from many mathematical tools (Mathematica) and major office products (MS Office 2007, OpenOffice).
Standards for representing mathematical notation in ASCII MathML - Example notation: <mathmode="display"xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> <mi>x</mi> <mo>=</mo> <mfrac> <mrow> <moform="prefix">−<!-- − --></mo> <mi>b</mi><mo>±<!-- ± --></mo> <msqrt> <msup> <mi>b</mi> <mn>2</mn> </msup> <mo>−<!-- − --></mo> <mn>4</mn> <mo>⁢<!-- ⁢ --></mo> <mi>a</mi> <mo>⁢<!-- ⁢ --></mo> <mi>c</mi> </msqrt> </mrow> <mrow> <mn>2</mn> <mo>⁢<!-- ⁢ --></mo> <mi>a</mi> </mrow> </mfrac> </mrow> </math>
Standards for representing mathematical notation in ASCII • LaTeX • A document language for high quality typesetting. • Most widely used by mathematicians, scientists, engineers, and other scholars in academia. • Human readable (?) • Has special packages for extending LaTeX to handle mathematical notation (amsmath)
Standards for representing mathematical notation in ASCII LaTeX - Example notation: x = \frac{-b \pm \sqrt{b^2 - 4ac}} {2a}
Displaying mathematical notation on the web • Use images • don’t scale, • print out quality can be poor • accessibility issues • HTML with tables to control layout and use entity references for symbols • can be hard work for complex equations! • just about OK for simple examples • scaling may lead to unpredictable results • accessibility issues
Displaying mathematical notation on the web • Javascript solutions to programmatically layout in HTML and CSS • A few different open source implementations, most popular include: • ASCIIMathML • LaTeXMathML • jsMath • MathJax
Investigation and evaluation http://dev02.elearning.eps.manchester.ac.uk/~stuart/web-maths/
Built from ground up from 6 years prior experience by Davide Cervone (author of jsMath) • Works across multiple browsers and platforms: PC: Internet Explorer, Firefox, Chrome, Safari, OperaMac: Safari, Firefox, Opera, Chrome, OmniWeb, Camino, iCabUnix: Firefox, Konqueror, Opera, Chrome, Iceweasel, Galeon, EpiphanyiPod:Safari • Uses HTML/CSS, JavaScript, and unicode fonts for high-quality typesetting that is scalable and prints at full resolution • Is Ajax-based, modular, highly configurable
INPUT FORMATS MathJax.js OUTPUT FORMATS MathML+ HTML /CSS TEX Central Hub voice MathML MathML MathJax – technical background • MathJax has four major components: • Different input "jax" (TEX, MathML) • Different output "jax" (HTML-CSS, voice, MathML) • An internal format (MathML+) • A central hub to glue it all together
MathJax – issues • Slow to render large chunks of mathematical notation (in beta version tested Spring 2010) • Relies on CSS technology only recently widely implemented in browsers • @font-face • since IE4; Firefox 3.5 (30/06/2009); Chrome 4 (25/01/2010), Webkit/Safari 3.1 • …but where @font-face not supported, falls back to rendering with image fonts.
MathJax - usage • Set up: • Import a javascript file into HTML page <script type="text/javascript" language="javascript" src="js/MathJax.js"> • May need to also add some short configuration notation into HTML page to specify input and output formats. • …but should be able to abstract this away to MathJax.js file. • Needs further investigation as to best set up
MathJax – usage (LaTeX) • Delimiting blocks of notation in your HTML with: • $ … $ for inline maths (analogous to HTML <span>…</span>)or • $$ … $$ for blocks (analogous to HTML <div>…</div>) • Will also automatically recognise some LaTeX notation • Example: $$ x = \frac{-b \pm \sqrt{b^2 - 4ac}} {2a} $$
LaTeX - oh no!Another technology to learn… • In most cases you may only need to learn a little… • However, WYSIWYG editors exist for LaTeX • http://www.codecogs.com/index.php • http://www.sitmo.com/latex/ • Example: this took less than 5 minutes to create(with no previous experience of the “codecogs” WTSIWYG editor) \dot{\varepsilon} = \frac{K' D G b}{k T} \cdot \left ( \frac{b}{d} \right )^p \cdot \left ( \frac{\sigma}{G} \right )^{1/m}
Advantages - Disadvantages • Advantages • High quality typography • Cross-browser support • Scalable • Some consideration for accessibility • Copy and paste into Word(?) plus maths software • Rich API • Disadvantages • Still some problems with printing • For best results needs recent browser (esp. non-IE) • Maths LaTeX support good, but still gaps • Slightly slow rendering in complex examples • 36Mb download (mostly due to fonts and images)
Where to next? • What about setting up a centralised MathJax service??? • Most University staff who may have a need for displaying maths on-line won’t know LaTeX. • Education? • Rely on WYSIWYG editors? • Most University staff who may have a need for displaying maths on-line who know LaTeX resistant to change. Happy to carry on producing PDFs • Some interest from staff, but may be initially more of use to ELTs?? • However, setting up a service should be low cost – just a small website with examples (but not a LaTeX tutorial) and careful configuration. • Need to manage expectations from staff
More info • http://www.mathjax.org/ • In particular Davide Cervone’s presentation: • http://www.mathjax.org/resources/articles-and-presentations/