MMD & LaTeX: Poetry and Verse in Scrivener

MMD & LaTeX: Poetry and Verse in Scrivener

The easiest way to create a block of text that looks like verse is to append two spaces after each line of verse. This tells MultiMarkdown to insert a
after each line, which in turn will be converted into a ‘\’ in LaTeX, both of which serve the same function – a new line without creating a new paragraph.

I'VE seen a dying eye Run round and round a room In search of something, as it seemed, Then cloudier become; And then, obscure with fog, And then be soldered down, Without disclosing what it be, 'T were blessed to have seen.

However, this is not the best practice in LaTeX terms. In most LaTeX classes, there is a special environment for verse style formatting, which sets the text in a different manner from paragraphs. Where the above example will indent the first line in LaTeX, a section of poetry inside of a verse environment will not be so indented.

This might be one area that Fletcher could take a look at, as the usage of MMD in a literary context differs from a technical context a great deal. People who are writing books of poetry, and authors who use song in their writings would benefit from a way to quickly indicate blocks of verse text.

Barring the inclusion of some special syntax, you can create your own verse blocks with the use of some very simple XHTML, straight in Scrivener:

<div class="verse">
I'VE seen a dying eye

Run round and round a room

In search of something, as it seemed,

Then cloudier become;

And then, obscure with fog,

And then be soldered down,

Without disclosing what it be,

'T were blessed to have seen.


to the end of every line will, as described above, transfer as ‘\’ in LaTeX, which is proper usage inside a verse environment. Unfortunately, this is not the prettiest thing to see in your Scrivener document. Exporting this from Scrivener in its default state will result in nothing special happening, because the XSLTs which transform the XHTML into LaTeX do not “see” this special class. Modification to xhtml2latex.xslt will be required. Be sure to back up your original version first! See how annotations are handled for an example of how this could done.

Even then, that only covers the most basic and generalised situations. Actual poetry usually requires a level of attention to typography that exceeds normal book formatting. See chapter 15 of this document (PDF) for addressing these complexities in LaTeX. There is no good way to do this from Scrivener, as each poem requires special, unique attention to spacing. Something which will need to be done in the LaTeX document itself.

One solution would be to use the code block syntax to indicate poetry, and then use a different XSLT when converting to LaTeX.

The codeblock syntax means that each line is indented with a tab. Normally, this creates a verbatim environment in LaTeX.

A separate XSLT configuration could reinterpret a code block as a verse environment. A search and replace in the XSLT could convert newlines into “\newline” to indicate line endings, as required in verse (that is also the syntax for a regular “hard return”).

I welcome such a submission from someone who would like to use MMD and LaTeX to format poetry in a little better environment than the verbatim. It may be a while (if ever) before I get around to doing this myself.

I’m actually currently evaluating Scrivener for finishing my novel-in-verse and I’d like to know what the options are in the current install for getting correctly-lineating LaTeX output. I need to have the output file as PDF. (I notice that the export-to-text does include the line breaks correctly.)

Where are these XSLT style sheets for the app? Can I edit those directly myself?


Scrivener includes the latest version of MMD within its application bundle. This can be accessed by right-clicking on the Scrivener application itself, and selecting Show Package Contents. Once in there, the path to MMD is Contents/MacOS/MultiMarkdown. The XSLTs are located in this directory, as are the Perl scripts which use them.

However, I recommend visiting the MultiMarkdown webpage, and downloading the zip file, following instructions on where to put it. It will include an identical distribution to the one found in Scrivener (at the time of this writing). The nice thing about this is that Scrivener will check for the presence of this directory before consulting its own system, which it uses as a backup in case the user does not have their own in place. You can edit the scripts and XSLT files in the Library folder, without worrying about damaging the pristine version in Scrivener.

By default, MMD to LaTeX export in Scrivener uses the memoir class, and so the XSLTs regarding that class will be your best bet for adjusting the appearance and semantics of verse blocks. Do a search for memoir class documentation on this forum. It includes a lot options right in the class, specifically to aid in the construction of verse prose. You will not be able to access these directly from Scrivener without modification, as there is no way to put LaTeX commands into an MMD file (the commands will all be escaped, and rendered literally in the PDF).

Using these techniques, you can highly extend Scrivener’s export potential. For all intents and purposes, Scrivener has a fully programmable export system via Perl, XHTML, and XSLTs.

Thank you very very much!

Actually, the installer was scrapped due to major limitations in Apple’s Installer program. It was just easier to let users install the software manually, and this allows one .zip archive to work for all systems.

Any of the “poetry” XSLT files allow for you to manually set where lines end, without appearing like a code example when you export to LaTeX.

Thank you!

Thanks for the correction. I fixed the original post.