Author Archives: Peter Krautzberger

LaTeX The Phantom Menace

(Week 2 of the challenge.)

LaTeX is the path to the dark side. LaTeX leads to TeX. TeX leads to DVI. DVI leads to suffering.
— not Yoda.

Ever since joining MathJax, MathML has been a major part of my professional life. It’s a slightly unhealthy relationship: wide-eyed enthusiasm and bottomless despair are frequent companions (although, I think, I’m becoming slightly more stable). Among the web standards of the W3C, MathML is, I think, unique and this is both good and bad (and topic for another post).

One thing that comes up regularly in discussions is how the use of LaTeX notation on the web is somehow evil. I believe this is a phantom menace.

Five(-ish) reasons why TeX/LaTeX is no threat to MathML

  • Full TeX/LaTeX is so messy

You might say that comparing full TeX/LaTeX and MathML is comparing apples and orange — at most, I should be comparing math-mode TeX/LaTeX to MathML. But the problem is that the difference is tricky since mixing math and tex mode is all too common in the real world. Since TeX is a programming language and lacks enforceable best practices, there will never be a “good” subset of TeX/LaTeX that could provide reasonable markup constraints. The reality of how people use TeX/LaTeX is just too messy.

  • on the web, “LaTeX” doesn’t exist

Quite literally, there is no such thing as “LaTeX” on the web. What is really being compared is a bunch of TeX-like input languages. If you think Markdown is bad off (yay CommonMark!) take a look at the number of easily incompatible TeX-like input on the web. MathJax’s TeX-input vs Wikipedia’s texvc vs iTeXMML vs pandoc vs … — they are all different on some level.

And even if you think: oh well, one day there’ll be one standard LaTeX subset for the web (right?), then there’s still no threat here. Markdown, wikitext etc have never threatened HTML; raphaeljs, d3.js etc have never threatened SVG; threejs, pixi.js etc have never threatened WebGL. Instead, these tools pushed the use and thereby the standards forward. Pretending that TeX-like input (or asciimath or jqmath) has any other affect is a phantom.

  • in the DOM, LaTeX does not make sense

While you might still wish to speculate that LaTeX could somehow be coaxed into being playing nice with HTML, CSS etc, the story really ends at the DOM. LaTeX does not fit in the DOM; period.

  • MathML is TeX for the web

There is a reason why MathML is so damn good for mathematics — it was created by people with a huge amount of experience, in particular in TeX and CAS. So in many ways, MathML is the natural continuation of the insights gained from TeX, applied to the web.

  • MathML is better

While at first sight MathML appears verbose (just like HTML or SVG might appear), it ultimately has one huge advantage over TeX: it is clean, self-contained, and stable. MathML provides a clear-cut presentation of equational content. It is infinitely easier to understand someone else’s MathML than it is to understand someone else’s TeX. (And you also cannot redefine \relax in MathML…)

  • MathML has won already

Fun fact: for roughly a decade, almost all new mathematics has been stored as MathML. Mathematicians are usually surprised by this — doesn’t every math journal accept TeX submissions? That’s true and nobody would claim that the majority of mathematics is authored in MathML (come to think of it, that one probably goes to MS Word). But unless you publish with a very math-specific publisher (e.g., the AMS), your content is invariably converted into XML and your equational content into MathML. So even in pure math research (which is a miniscule amount of mathematics published compared to STEM in general) the authoritative format is MathML.

  • If MathML failed because of math-mode LaTeX, that would be pathetic

So LaTeX as a web standard is just not practical. Which brings me to my final point. If MathML fails because of a bunch math-mode LaTeX-like input thingies, then I think we deserve to fail. These are such a weak contender, MathML would have to be truly a miserable standard to loose out. By contraposition, the fact that MathML is far from miserable (as its success demonstrates every day) means it will not fail no matter how many web pages include TeX/LaTeX in their HTML.

Where is this phantom menace coming from?

The more interesting question for me is where this phantom originates from. I suspect this is really about the lack of browser implementations. It’s always easier to look for a scapegoat. Making up a phantom like TeX will distract us from the important discussion: what’s really holding back browser implementation? It’s definitely not the math end where MathML simply rocks. And then the really interesting question can be: what could MathML 4 and MathML 5 look like?

Welcome to Westdeutschland

(Week 1 of the challenge. Sorry for those looking for TeX/MathML related stuff. Sometimes, there are more urgent things, you know?)

25 years ago today, the wall fell in Berlin, opening up Germany, opening up Europe. Admittedly, I don’t remember much about that night; of course, I technically remember (and reconstructive memory is grand) but the event held little signficance to 10-year-old me. (Though arguably not zero signficance since I had actually visited Berlin for the first time that year, and I remember standing on a platform near the Brandenburger Tor, looking over the death strip to that iconic land mark and not really understanding things).

As you may have noticed, I recently moved back to Germany and most recently to Göttingen. This meant, after some 8+ years, I’m living in West Germany again. Admittedly, when I lived in Berlin while working on my PhD, I lived in a heavily gentrified (i.e., West-ernized) East Berlin quarter (fun fact 1: at the time, the percentage of foreign citizens in Prenzlauer Berg was precisely the city average, with the “slight” difference of almost all of those being from G8 countries…). Still, even that part of East Berlin (let alone other parts) remained structurally very different from, e.g., Bonn and Munich. A particular aspect for me was always the absence of the typical West German “infrastructure” of small shops and businesses (or ATMs for that matter). In any case, Prenzlberg still felt incredibly different from anything West German (though not as much as it did in the 90s or even early 2000s when I first fell in love with Berlin).

Gaussturm near Göttingen

Gauss did not build this when he was 9 years old

It has struck me how Göttingen, to me, seems like a perfect example of a West German city. I can’t quite pinpoint this particular feeling. Maybe it is the beautiful 18th century city center (fun fact 2: supposedly Laplace urged Napoleon to spare Göttingen because Gauss might get hurt), maybe the lovely ring of late 19th century quarters surrounding it, perhaps the 50s Karstadt, the 70s Neues Rathaus, and the 90s malls. Certainly all of that a little. The city has also seen the typical post-WWII re-design towards cars as primary mobility solutions, which makes it a mess for the large number of bikes, pushing them to the sidewalks to collide with pedestrians (fun fact 3: I couldn’t remember when I had last seen an atomkraft-nein-danke flag but I did see one on my first trip to Göttingen). Göttingen has this feel of wealthy-but-reluctant-to-admit-it (as so much of West Germany). It’s filled with students making it appear modern and young and yet it’s history weighs heavily in places (bizarro Bismarck adoration in the Bismarckturm does not compute). Göttingen is also surrounded by a beautiful countryside with a gazillion potential destinations for the weekend, many having been popular retreats at some point of the city’s long history. Of course, for a mathematician, Göttingen is a particular attraction and yet it’s hard to ignore the great purge in 1933.

Göttingen has this particular, everything-is-finished vibe (with a no-room-for-change beat) which I find so typical of West German cities. It’s oddly appealing (especially after returning from SoCal) and yet slightly suffocating. If you want to live in a perfect example of West Germany, come stay in Göttingen. At the very least, you can stop by Gauss’s grave and since it’s a 5 minute walk from my home I expect you to stop by for a coffee after.

Today, celebrations of the peaceful revolution of 1989 may be in focus. But on November 9 we always remember more. 1918, 1923, 1938, 1989; I can’t remember one without the other.

Tiny blogging challenge

This year hasn’t exactly been great in terms of my blogging. Because life. After the Red Workbook concept tapered off I barely managed 1 post per month.

Still, I miss writing. So I’m setting myself a tiny blogging challenge for the few weeks remaining in 2014.

  • write 1 post per week
  • and spend less than 30 minutes on a post

just one per week?

Yes. I don’t want to take on a 1-post-a-day challenge because, well, I’d simply fail. I’m no Cathy O’Neill. So most likely I’ll write these posts on the weekend or possibly late at night.

One post per week seems reasonable. It’s realistic, I’ve done it in the past yet it’s far from what I’m currently able to do.

30 minutes per post?

Not a lot, I admit, but the averaging napping time of certain person. Given that my usual writing includes a procrastination phase of 5-6 months I’m expecting a change in quality. I’m just hoping for an improvement, given that more writing regularly should mean more practice.

about what?

I thought it might be prudent to have a couple of topics ready so that when I sit down (not unlikely on a Sunday at 11:30pm to make the deadline) I have a last resort for a topic to babble about.

  • write a post about the blogging challenge (score!)
  • LaTeX The Phantom Menace
  • MathJax best practices: webfonts for text
  • LaTeX something something dark side
  • LaTeX the markdown for math
  • Why you should care about MathML
  • Why you shouldn’t care about MathML

Note that these are not actually related to drafts or even proper ideas. They are just ideas I jotted down over the past few weeks.

It has not escaped our notice…

Just a quick post to show I’m still alive. One of the reasons why I haven’t gotten to write recently is that we moved (yet again) to the final-for-oh-I-don’t-know-who-knows-hopefully-a-few-or-more-years-that-would-be-nice-for-a-change destination.

And it seems my new neighborhood is trying to tell me something.

Street sign, Felix-Klein-Str., Göttingen

Street sign, Riemannstr., Göttingen

Street sign, Gaußstr., Göttingen

Oh well. I supposes that’s what you get for moving to the town where these folks spent very productive years.

ASCIIMathML to the rescue

Doug Schepers recently asked me for some advice for HTMLizing some mathematics. Doug is one of those exceptional people at the W3C who thrive in pushing the web and its standards forward. In this case, Doug was looking at this bit of audio engineering in the context of the Web Audio spec.

As you can see, that text file has some beautiful ascii-art mathematics. Of course, Doug wanted to code this up properly for the web which means using MathML and the question was: what’s the easiest way to do so?

It’s not hard to see why I suggested ASCIIMathML (or asciimath). Asciimath was written by Peter Jipsen with whom I happen to have two lucky personal connections — first, I luckily shared a room with Peter at BLAST 2010 (way before I got involved with MathJax, see these posts), second I was lucky enough to enjoy his hospitality a couple of times while we lived in LA, including Peter taking me surfing for the first time in my life — good times.

If I remember correctly, asciimath was born out of pure necessity — finding a way for college students to write mathematics on the web. These kids were accustomed to graphing calculator style input, and Peter, of course, believed that MathML was the right way for an output on the web — so in 2004 he started to write this beautiful JavaScript library to convert from one to the other.

Later on, David Lippman wrote a nice MathJax addon, which was ultimately re-written by David Cervone, and so nowadays you can use asciimathml in any browser by combining it with MathJax.

Why Asciimath is awesome

First off, if you know some TeX I would probably describe asciimath as “TeX without backslashes”. Because, really, why not write alpha or phi for %alpha, phi%? Similarly, why not just write sin for %sin%? (Oh, and let’s have a fun discussion about phi vs varphi, Unicode vs TeX. But not a problem, you can switch to whichever convention you like using MathJax.)

Second, if you know markdown, then I might describe asciimath as “markdown for math”. It’s not TeX in all its (infamous) glory or even MathJax’s TeX-like input with its many advantages for the web. It’s much more restricted and that’s by design — much like markdown is.

Given its target (MathML) and its general webbiness, asciimath works smoothly with Unicode, which adds to its readability and usability (and internationalization). Everyone will probably appreciate that -> and work interchangeably (both of which seem much saner to me than anything LaTeX would suggest). So f: A -> B and f: A → B produce identical MathML: %f: A -> B% and %f: A → B%.

Similarly, asciimath’s minimal approach does not need TeX’s cumbersome \begin{} \end{} environments, but many important tools are available in much simpler ascii/computing notation, e.g., ((a,b),(c,d)) for matrices: %((a,b),(c,d))%.

Making asciimath better

Personally, I think asciimath probably deserves the title “markdown for math” although I think the title will go to TeX-like input after all (but that’s another post).

What I’d really love to see is more people pushing asciimath further. The official ASCIIMathML repository is now hosted on MathJax’s GitHub account and we even grabbed a nice domain at to have an open page using Github pages for people to easily contribute enhancements to.

There’s a lot of low hanging fruit in the form of improving the quality of the MathML (e.g., a\\b should probably produce <mfrac bevelled="true"><mi>a</mi><mi>b</mi></mfrac> instead of the problematic <mi>a</mi><mo>/</mo><mi>b</mi>) and of course asciimath by design should probably not strive to be feature complete (i.e., generate any kind of MathML) which means there should be situations where asciimath will simply fail and, much like markdown with HTML, it could perhaps gracefully mix MathML and asciimath.

But in any case, it’s great to have this alternative to TeX-like inputs because TeX is ultimately holding math on the web back (but that’s another post, for another time).