Wannabe Questions

I’m struggling to wrap my arms around this Scrivener>MMD>Latex>PDF “structured writing” process, and my general ignorance of things CSS, HMTL, XSLT, & Tex is making it hard. I’d really like to learn this process to add some polish to my documents: Too many years spent behind various word processing wheels have been most unsatisfactory, for the all the fuss and re-fuss it takes. (Thanks for the freedom, KB.) Let me also say I’ve been reading the MMD links here at scriv, and at Fletcher’s site and I seem to be getting a basic road map together that I’m hoping you folks can critique. My publishing goal is to be able to create technical reports in pdf form, and be able to use Scrivener to advantage in reordering sections without fussing with section numbers and the like.

So, as I understand it now, the “processing” goes something like this: A scriv document is exported using MMD>Latex which uses a CSS style sheet I’ve specified to create an XHMTL document that MMD then turns around and converts to a LaTeX document using an XSLT script I’ve specified. I then take this Latex document and process it with PDFlatex and I get my printer ready PDF. Voila! (I’m not sure but I think MMD does the Scriv+CSS>XHMTL+XSLT=Latex in one fell swoop. I need only supply the Scriv, the CSS, the XSLT and MMD does the rest of the work.)

Am I getting close? Missing some steps?

Followup Questions ( or What do I need to learn to make this happen):

Does this mean I need to learn to create CSS style sheets? If so, any good starter resources?
Do I need to be able to edit XHMTL/HMTL?
Likewise, do I need to learn to read and write XSLT scripts? I understand Flecher, AmberV and others have many available for use, but how does one pick one from the other?
Do I need to be versed in both CSS and XSLT or with either?
Do I need to load LaTeX (over a gig now!) on my system?
Where does TextMate, should one desire, fit into the “process” described above
I understand that in order to get a generated table of contents, one would need multiple trips thru the mill, but which mill would that be? Where does that loop occur?

Finally, would anyone care to give a list of all the software pieces that would need to be obtained and loaded onto my system in order to get this up and running? I think it is the following:

LaTeX (via MacTex or the like)
PDFlatex (also from MacTex)
… what else?

Many thanks in advance, and many apologies for asking too much. Brief little clues much appreciated.


You got most of this right, with one exception, though. MMD doesn’t make use of CSS when you convert to LaTeX. You can add a link to a CSS file or have the styles inserted directly into the XHTML document, but all of this is lost in the conversion. In other words, don’t bother with CSS if you want to create LaTeX documents with MultiMarkdown. :wink:

Here’s a flow chart, that - I hope - makes the conversion process clear:

You can select the XSLT file in Scrivener’s MultiMarkdown Settings. The default for MMD to LaTeX is memoir.xslt (and also xhtml2latex.xslt), but you can override this with the Meta-data field LaTeX XSLT.


A basic understanding of how XSLT works is necessary, if you want to modify the LaTeX output. CSS is only relevant to XHTML output.

Yes, absolutely. The MacTeX distribution is huge, but it’s also very complete and relatively recent. There are older, unmaintained distributions for Mac OS X (MacPorts, gwTeX …). They’re obviously much smaller, but beginners should generally stay away from them.

Once the conversion to LaTeX is complete, the .tex file must be compiled, which can be down from the command-line. A dedicated LaTeX editor (like TextMate or TeXShop) makes the whole procedure a little bit easier, but which LaTeX editor you want to use is up to you. The whole point of the Scrivener/MMD workflow is to spare you the hassle of editing LaTeX files, so the editor becomes just a GUI to start the compilation of your .tex file.

In your LaTeX editor? You have to open the .tex file created by Scrivener and press the “Compile” button. Multiple times if necessary. This procedure can also be automated in TeXShop.


Thank you so much, your response is huge. I got the MacText download last night and will work on the install, but alas a week of holiday approaches so it will be some time before I can truly digest. But by the looks of it, with your fine help, I’m a big step closer.

In your debt,


One small detail, but I think the default XSLT is actually memoir.xslt, which is built to be a flexible casual book format for a variety of purposes (not just memoirs). I like it better than the book class which is fairly thin on features. The xhtml2latex.xslt is the base element that all of the derivatives use to generate most of the content outside of what is necessary for the particulars of the classes they utilise. That is how it used to be anyway; perhaps things have changed.

To the original poster:
One other possible edit path you might consider is LyX, which can import a LaTeX file. It’s a lot more like a word processor (they like to use the phrase document processor) than TextMate or TeXShop, which simply load the LaTeX file and let you edit it raw. LyX will obscure the need to understand most of LaTeX’s particulars, and make the generation of PDFs really easy. You still need a full TeX distribution to use it. It is very much a structural editor. What you see in LyX is not necessarily what will print out. It uses some internal visual conventions that are meaningful to the user (like large and bold headings) but what actually gets printed out depends upon the class. That aside, it’s very much like working in a word processor where one heavily relies upon styles to define appearance. Making a PDF is as easy as clicking a button, and if you ever need to drop back to raw LaTeX it is pretty easy to do so, or you can just export one and abandon LyX. You aren’t locked in.

As suggested, you really don’t need to learn XHTML or CSS. The XHTML file only exists for very briefly in the execution chain, and unless you need to tweak how the LaTeX file is generated, you can safely consider it part of the automatic process. CSS is totally outside of this workflow and only necessary knowledge if you wish to publish for the web (though many auto-publishing systems like WordPress and Blogger have their own CSS stylesheets already prepared).

For me, the end goal with MMD is to get things as close to one-shot-export as possible. That means working 100% in Scrivener and when I’m done all I have to do is compile and generate a PDF. This is possible very easily if the defaults are fine. But if not, then it either means post-processing the file in TextMate or LyX or whatever, every time you compile—or learning XHTML and XSL. Both have fairly substantial learning curves, but as someone new to the entire thing, I would recommend dipping your toes into the former, first. Yes, to do one-shot-export the latter is the right path, but until you know the basics of LaTeX you won’t really know what to do with your XHTML/XSL technology. The easiest way to learn LaTeX is to use LyX to do what you want, and then either view the source as it is being edited (much like WordPerfect, except with LaTeX codes), or export a LaTeX file from there and observe what it did. In this manner you can learn the code without a pile of reference books, and from there you can become comfortable with what does what.

Once you have a basic understanding of commands and environments in LaTeX, you can go about learning how to implement your own modifications and additions using XHTML/XSL. The beautiful thing is that once you figure all of this out, it drops completely into the background. Once, I needed a generator that created BBCode files for the forum. I tore my hair out for a bit writing that, but now that it is written I never have to bother with the details again. When I need a BBCode export, it’s all automatic and requires no fiddling.

I’d compare the structural Scrivener+MMD workflow to the word processor workflow is this: With structural you’ll have a big up front learning curve and production period getting this the way you like them, but from that point on you are all set. For some people you might even be set for life. Word processors employ familiar interfaces and utilise software that everyone is familiar with. If you want bold you press Cmd-B, you don’t have to learn that is bold and that <xsl:template match=“html:strong”>…</xsl:template> will capture it and that \textbf{…} is how you make things bold in LaTeX. You just press cmd-B. However, you have to process and post-process files every single time. Compiling is only the first step in a long process of converting formats to stylesheets and battling with RTF incompatibilities and missing fonts and so on. Both methods have their hassles. Word processors spread theirs out and make them something you’ll have to bother with all the time at a low-level. MMD and LaTeX are a huge headache in the start and relatively mindless forever after (unless you need to change something, naturally).

Thank you, Amber, I’ve corrected my mistake. :smiley:

That works surprisingly well, I’ve tried this with memoir.xslt and the results are just great.

EDIT: I’ve attached two screenshots showing the changes in Document > Settings… that are necessary to use LyX with PDF (xelatex) instead of PDF (pdflatex).