MMD, LaTeX and the like

Not sure if this should go here or in tips/tricks. It’s more of a meta question.

Most of my writing is music related, and when I’m writing about music, I generally have notation examples. In the past I’ve done some sort of graphic that’s placed within the body of the work. Recently I’ve been usinglilypond. As such, it’s possible to embed lilypond code within LaTeX. I know MMD isn’t in the windows version yet. But just how much control do people have over the LaTeX code produced by MMD?

Control is extremely articulate, and once you know how it creates a LaTeX document, you can see why. What it does is take an XHTML file, and then run it through a raft of XSL scripts which are working in text mode to take an XML structure (the XHTML) and turn it into a plain-text format. As such, you can exert full control all the way to the point of it no longer being a LaTeX file at all, and these techniques can be used to expand the “language” of MMD if necessary, too (the Scrivener manual uses a roughly 500 line set of overrides at the XSLT level to produce the PDF result you see in one shot).

The upcoming major revision of MMD will be quite different in this regard as it will go straight from MMD to LaTeX—all of the default syntax generators will be in C and not possible to externally modify, except by stepping back and using the slower but more customisable Perl+XSLT route, via the helper scripts that will be distributed with it.

For Lilypond, you’d probably only need to wrap the code in an XHTML comment so it gets dumped verbatim into the .tex file. Otherwise any character special to LaTeX will get escaped and probably break the code.

Gotcha. Sounds useful. :slight_smile: