Scrivener to LaTeX - basic questions

Hello all,

I have a couple of basic questions with regards to setting up a Scrivener / LaTeX workflow for academic work.

I’ve been experimenting with variations on the structured outline to give me parts, chapters and sections, and have fiddled with some of the markdown options in Scrivener at the compile stage.

Once compiled, I’ve been opening the LaTeX file in TeXShop, and then typesetting to see the result of my experiments in final PDF form.

I’m now at the stage where I would like to change some of the default format, but I am not quite sure of where to go next. I understand that I can:

  • Add / edit some of the metadata directly in Sciverner (via a “metadata” document, or through the compile options), though I have little knowledge of metadata syntax or use.
  • Edit the LaTeX code itself (something I’d like to avoid if possible)
  • Create / Edit things called “XSLT files” for my own requirements.

However, how and where I use each of these options to, say, specify a two column paper, or change labelling of Parts to Chapters etc, has me thoroughly confused.

In addition, I don’t understand where Scrivener is getting its default format for MultiMarkdown -> LaTeX, and whether or not it is possible to edit or load different XSLT files (or if that is in fact the best option).

I’d certainly appreciate some guidance from those in the know on the ‘next steps’.

Many thanks,


That will often get you far in the right direction. Since it sounds like you are willing, and desire, to tweak things a bit beyond vanilla, so you might want to download the MultiMarkdown distribution and install it into your Application Support folder. Scrivener will use an alternate copy that is placed here, and this will make it easier for you to find the right XSLT, and add your own changes to the system. It’s all done in Perl and XSLT, so it’s possible to make changes at all levels of the process. While on the MMD site, check out the documentation page on available meta-data. Chances are, there are a few fields you’d like to use on a regular basis, like Copyright, Date, Title, and Author.

Assigning which formatter the MMD file uses is done with meta-data. You can add meta-data keys and values in the “Meta-Data” option pane in compile. Add a key for “LaTeX XSLT” and for its value, type in “article.xslt” to see how this can radically change your output with a single variable. Visit the XSLT folder in the distribution you installed to see all available options. Note not all of these are meant to be used directly. Some are basic “library” style translations which are meant to be included by higher level translation files. If you load up article.xslt, you’ll see it includes memoir.xslt, and memoir.xslt includes xhtml2latex.xslt. It’s good to know about this chain, because if you want to tweak something specific about the output, you can find the original to base your derivative off of. The way chained includes work with XSLT, the root file overrides any declarations it includes. So if you write a simple XSLT that has one template match in it, and that match is defined in memoir.xslt, the system will use your definition for that one match, but for everything else it will defer to the included files. This way you can edit core attributes of the exporter without touching the original distribution.

The next meta-data key that you’ll find handy is one that Scrivener adds for you by default, “Base Header Level”. This is a numeric offset value which establishes the highest level that will be used when converting hierarchy to chapters, sections, etc. A value of 1 is default, and corresponds to Part, so if you have no parts and wish to go straight to chapters, you can bump this up to 2. So with those two meta-data keys you can make the two most common high-level tweaks really easily.

article.xslt is a good file to examine for best practices. This is a very simple file that doesn’t actually adjust any of the underlying LaTeX but supplies some alternate preamble to change the look of the LaTeX document. That’s the most basic form of customisation; just fiddling with the containment boilerplate text that the actual document gets placed within. Changing the way the document LaTeX is generated is a little more complicated, and for that you’ll want to consult how things are done in the xhtml2latex.xslt file. For example, here is how a section rule is converted:

[code]<xsl:template match=“html:hr”>
xsl:text\vskip 2em
\hrule height 0.4pt
\vskip 2em


As you can see, the match is for html:hr, which is what a series of hyphens in your document will be converted to. Everything inside the xsl:text element will be output to the file, so if you wish to add a symbol here instead of a line, you would copy and paste this directive from the xhmlt2latex.xslt into your custom XSLT, include a primary XSLT, and then set up Scrivener to use your custom file. Everything will be stock except for your changes to the html:hr match.

What I’ve done is slowly built up a customisation file over the years. Whenever I come across something I don’t quite like as stock, I’ll copy and paste it into this file and adjust it there. Then I include that file in all of my smaller “wrapper” style files that are more like articles.xslt. This way the core universal outputs I prefer are used across all of the document classes I prefer. The only exception to this are large custom projects. With those I’ll make a special XSLT just for it that includes document class and output customisations in one package. The user manual is an example of such a file.

Thank you for your detailed reply Ioa. It is very much appreciated.

So just to make sure I understand this, Scrivener will default to using an installed MMD distribution in /Application Support instead of the one that is contained in the package contents of Scrivener, and that I’m guessing it currently uses by default?

I see I have some work cut out for me (stand by for a future request for help on including citations and bibliographies).


That is correct. Scrivener checks your ~/Library/Application\ Support/ folder for a MultiMarkdown/bin folder and if one is present it runs those scripts instead of the provided copy included in the bundle. You could edit that one too, but it’s more difficult and you have to remember to back up your modifications otherwise they’ll get blown away each time you upgrade Scrivener.