Sorry, forgot to answer your question on raw LaTeX. Embed it in an HTML comment, like so:
<!-- \begin{description} -->
Anything inside of a comment will be passed through verbatim to the .tex file. This is true for both MMD3 and 2. You might consider using Replacements for common codes you need to fire off. Replacements let you add your own custom replacement tokens to the compiler. It basically just works like a real-time Project Replace, without affecting the project itself, only the compiled product.
I suggest using a Binder item named “Meta-Data” at the very top of your compile. If Scrivener discovers one of these while using any of the MMD compile formats, it will tack that on to whatever meta-data is defined in the compile pane. So the easiest way to do that is do a quick compile to MultiMarkdown plain, then copy and paste the top part of the resulting text file into your project. The other thing this solves is Scrivener automatically adding “Format:complete”, which MMD3 doesn’t use and having it can mess things up in some cases. Oh, and clear out the compile pane once you do that, to avoid duplication since the Meta-Data file will be appended. No worries about getting it back in, in the next version you’ll be able to paste raw meta-data blocks into this table and have them converted to the key-value system used in the pane.
The next version of Scrivener won’t have full MMD3 integration, but it will have a few useful additions. The meta-data pane will allow re-ordering of keys you’ve added, and there will be a checkbox to disable the “Format:complete” bit. The beta for these changes should be hitting the forum soon-ish. Still wrapping up a few loose ends, but definitely grab it once it is up as it will make MMD3 easier, and will have some interesting new features, too—along with the standard bug fixes and such.
Hi Everyone. I also have a bunch of questions about using multimarkdown in Scrivener. So I hope it’s ok that I pile on! I’m writing my dissertation right now. And I can be quite challenged when it comes to the technical side. I need things really plainly spoken, with baby steps. So I really will appreciate any help and pointers.
I love Scrivener, and I have been using it for maybe 6 months (more or less on a surface level). I have discovered that it would be highly useful for me to be able to write a single document, from which I could produce either an rtf (or word) file, or a pdf through LaTeX. And from what I gather, this is exactly what multimarkdown can do. Because of this revelation, I am on the cusp of changing the entire way I write; but before I make the switch, I really need help understanding all of this.
And now for the baby steps. I apologize in advance for the simplicity of these questions.
First: how much of MMD should I use when writing? I understand that Scrivener will take care of some of it, like footnotes. Does that mean that I can basically write as normal–keeping every chapter, section and subsection in its own folder or file–and just use MMD syntax for bold and italics (Plus, leave a space between paragraphs, without indents)? Is it really as simple as that to produce a document that can be compiled either as rtf or LaTeX/pdf?
Second: I recently got an iPad. I’m planning to do quite a bit of writing on it (doing some travelling this summer). For Scrivener integration I will be using the Notebooks app (which I think is a great app). I really like the ability MMD gives me to be able to format text from the iPad. But does this mean that I now need to write everything, including footnotes, in MMD? Or can I write footnotes on the iPad in MMD, but on the computer just use Scrivener for footnoting?
Third: how do I indent paragraphs using MMD? Apparently a tab won’t do. (There is probably a very easy way to handle this)
Last: I use bookends for my citations manager. If I place the citation key within the text in Scrivener, can this same key be used for either an rtf or LaTeX file?
Firstly, the RTF format in the version of MMD that Scrivener uses is a little simplistic. However, in MMD3, there will be a much better solution: an ODT format. It uses the “Flat XML” standard for this, which can be opened up in supported word processors (LibreOffice, an OpenOffice fork, is one such). The nice thing about this method is that it handles styles. That is, headers will really be headers—which can make reformatting the document much easier: just edit the stylesheet in the word processor. From there you can save to .doc/x or .rtf to communicate with the rest of the world.
Scrivener doesn’t yet embed MMD3, that will be coming in time but is probably a few months off as of yet. We are still working on the details of it. But the nice thing about all of this is that the MMD format itself is the same—so you can start writing now with the anticipation of switching to MMD3 later and taking advantage of its superior word processor workflow.
I figured that should be stated up front though. Most people in the MMD camp only use the RTF for quick proofs and such. If you need it for more, like I say, MMD3 will be a better route.
As much as you need, would be the flippant answer. A novel, for instance, would likely have very little special formatting at all—and it would be possible to work in MMD with almost no preparation or foreknowledge. Like you say, you can just write normally and use Scrivener normally too. The main difference is that MMD, being a plain-text format, needs an extra space between paragraphs, as you point out. Even that can be sidestepped by using Scrivener’s compiler setting to convert pseudo-spacing to actual spacing, in the Text Options compile pane.
If you intend to really jump into MMD with gusto though, I’d recommend getting used to hitting Enter twice after each paragraph. The compile option is good for stuff that has already been written one way—but might produce formatting glitches here and there. That’s just preference though—I’d rather have something in Scrivener that is essentially just a plain-text document in how it has been typed up. If one is careful about their RTF settings, this feature could be used reliably as a surrogate.
As for the rest: yes, your outline structure can be turned into actual headings in LaTeX (or fonts that look like headings as is typical for most RTF) and so the binder and the compile settings can be used precisely how you are familiar with it. A folder with five files can be a chapter with five sections.
Bold and italics will need to be in MMD format. As you note, footnotes can be generated “for free” like headers are. Likewise, embedded or linked graphics will be converted to MMD’s image syntax, and you can caption them by typing in the caption on the same “line” as the image, in double-quotes. So like:
<GRAPHIC> "This is the caption."
Cross-references, if you need them, should also be done in MMD (although you can freely combine Scrivener Links with them—that won’t hurt the compile as links are discarded—that is what I do so that I can cross-ref within the editor as easily as a reader might in the final hyperlinked PDF). Those are easy to do; just type in the name of the section you wish to reference to (it will need its title visible for that to work), and wrap it in brackets.
[code][Section Name]
-or-
[what the reader sees][Section Name][/code]
You can speed up title entry by typing in part of the section name and then hitting Ctrl-Esc in Scrivener.
So in general, yes, it really is that simple. Where it gets more complex is if you want to, in an automatic way, change the base formatting. That’s where it gets a little more intense as the formatting engine is based on a scripting language called XSLT. This is what produces the LaTeX file, and so modifying the XSLT scripts for your compilation will adjust the output of your document.
Fortunately, thanks to how LaTeX handles the separation of form from content, you don’t often need to mess with XSLT.
Actually, what I would do is use Scrivener’s inline footnote syncing feature. Any text that looks like this in a synced iPad file:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua{{And here is the content of the footnote}}.
Will turn into a Scrivener footnote (inline), and thus consequently turn into an MMD footnote when you compile. You’ll need to switch to using an inline workflow, but this technique gives you round-trip editorial control as you can create new footnotes or edit existing ones in a plain-text environment like the iPad. Incidentally you can do the same for inline comments to yourself, using double parentheses.
That aside, you could type the footnotes in manually on the iPad using MMD. Scrivener would just pass them through to the compiler and in most cases there would be no conflict mixing manually written footnotes with automatically generated ones. Scrivener tags them generically as [b][^fn#][/b] and [b][^en#][/b] for inline and inspector footnotes, respectively. For each footnote it increments the counter. So as long as you avoid that particular formation, you won’t create footnotes with overlapping IDs on accident.
Your mileage may vary, but personally I find keying in some of MMD’s codes to be painfully awkward on the iPad. Square brackets and the caret symbol, all needed for a footnote, are buried in the keyboard. iPad apps that feature customisable keyboard extensions definitely do help here (not sure if Notebooks does that) as do external keyboards of course. Curly braces are little better, but at least you only need to shift out of the standard keyboard twice.
Correct, a line prefixed with a tab in MMD is a code line, or a verbatim environment in LaTeX parlance; fixed-width font and all.
What type of indentation are you attempting? First-line indent is done by default in LaTeX, and the RTF output can be customised with CSS. But if all you need is a block indent, like a block quote—well you could just use the block quote environment for that if you don’t need it for anything else. Block quotes in MMD are like quoting someone in an e-mail: just put a [b]>[/b] in front of the paragraph.
Let me know if that is inadequate though. I had to design an indentation environment because I needed full typesetting within an indented region, not just paragraphs—so I have a ready solution but it is a bit more involved in that it uses the XSLT modification stuff I spoke of earlier.
Hmm, that’s a good question. I’m not as familiar with these aspects. While using a standard placeholder and RTF scan via Bookends would be the normal way of going about this—I don’t think that will work too well with LaTeX. MMD does have a citation syntax (BibTeX, which Bookends might support), so you might experiment with combining that and Bookends’ techniques.
Thank you so much for your thoughtful and helpful answers.
As for the paragraph indentation, I wasn’t thinking anything complicated–just standard stuff. But you mentioned that RTF can be customized with “CSS”? (I feel silly, but I don’t know what that is)
On the issue of Bookends and citation keys, I’ll do some testing, and if I can come up with anything, I’ll post it here.
If I have any more questions, I hope you won’t mind if I come back for help.
This is most trivia at this point, since MMD is shifting away from RTF, but here you go:
CSS stands for Cascading Style Sheets. It’s a simple formatting language that is most often used with HTML—these days, when you look at a web page, you are nearly always looking at CSS when it comes to the appearance of things. Simple though it may be, it’s quite powerful, and fairly easy to learn because most of its controls are plain English. The harder part is knowing which elements do what; that takes a little web design knowledge. For instance, ‘p’ is ‘paragraph’ in HTML. All paragraphs in your document are marked as “p”. So in CSS, you can do something like:
p {
text-transform: uppercase;
font: 12pt "Times New Roman";
color: red;
}
And there you have 12pt TNR red text transformed to uppercase when you look at it in a browser. This doesn’t change the text itself, that is just “p” and will always remain that way—the stylesheet can be swapped out with another one that does something completely different with “p”. This is why web designers like CSS. You can change a whole web site’s look and feel with a couple of files.
This is related to RTF in MMD2 because it can optionally create an RTF file using a simple converter tool to generate one off of an HTML file. Internally, everything in MMD2 goes to HTML first, and then various scripts turn it into other files, like .tex. It makes the HTML file, CSS styles it, and then the tool converts it to RTF.
This isn’t the default mode. The latest version of MMD2 shipped with a very simple RTF generating XSLT which doesn’t use any of the above. In some ways it is even more basic than the HTML->RTF convertor it used before—but in other ways it is nicer because it does make an attempt at creating a properly formed RTF file, rather than doing the kind of “snapshot” conversion it used to. The advantage of the old method is that you could use CSS to automatically format the RTF, if you so pleased.
So like I say, I wouldn’t bother too much with all of that unless you need to customise RTFs tomorrow. MMD3 has a better word processor output—but you’ll be doing your styling in the word processor using its stylesheets—not as a part of the compile process or anything.
Thanks Ioa. That is a lot of information. I guess I’m glad MMD3 is coming soon. Do you happen to have a rough time estimate?
By the way, I’ve taken the plunge, and I’m writing in MMD now (basic stuff), and I can utilize the syncing between Scrivener and my iPad. Truly awesome! I love it.
As per my above question on whether Bookends can be used to:
(1) copy citation keys within the MMD Scrivener project,
(2) from this same project produce either an RTF or LaTeX document, and
(3) be able to use these citations keys (in the RTF or LaTeX file) to produce a document with full bibliographic formatting.
It looks like you can do this! This was a big deal for me. So for anyone interested, this is what I think you need to do: set Bookends to copy citations for BibTeX, and use this format when copying citation keys into your Scrivener document. It should look something like this: \autocite{Adams:2004p705} . When you export your Scrivener project MMD->LaTeX, BibTeX will have no problem turning these into citations/bibliography (as long as you have your .bib file set up with the same key you have in Bookends, which you can easily do). And when you export your project to RTf (MMD->RTF), in your compile settings, under “Replacements,” set it up so that “\autocite” is replaced by nothing (leave it blank). This will remove every “\autocite” in the RTF file, which will enable Bookends to scan it. That, basically, should do it. {EDIT: I spoke too soon. See my post below ]
I have, however, run into a few snags with other aspects of the MMD->RTF conversion. First, I wrote something on my iPad as a test, synced it back to Scrivener, and now I get the following error message when I try to compile as RTF:
runtime error: file XSLT/xhtml2rtf.xslt line 322 element param
Unexpected XSLT element ‘param’.
runtime error: file XSLT/xhtml2rtf.xslt line 323 element value-of
Variable ‘newLeft’ has not been declared.
xmlXPathCompiledEval: evaluation failed
runtime error: file XSLT/xhtml2rtf.xslt line 323 element value-of
XPath evaluation returned no result.
I don’t know what to make of this.
Second, I’m getting weird formatting issues. The RTF files seem to have the following blunders: First, the space between a word in bold type and the word directly after it disappears (so it becomes one word, like so: boldword). Second, when I open the file in microsoft Word, quotation marks are replaced by this symbol: î (as in ìThe Critique of Pure Reasonî), and footnote numbers disappear in the footnote (but remain in the main text). Curiously, neither of these seem to happen when I open it in Mellel. Third, special characters are also transformed; for example: “Arne Grøn” becomes “Arne Gr√∏n” (in Word), and “Arne Grøn” (in Mellel).
Are there easy fixes for these things? Will some of this be taken care of with MMD3?
Please Disregard my above “solution” to inserting BibTeX commands into MMD. False! I’m not very advanced with this stuff, and I’m still learning. After running more experiments, I’ve found it doesn’t work (i.e., I can’t smoothly export to either LaTeX or RTF). And I have no idea how to make it work at this point. When I export to LaTeX, this:
\autocite[43]{cask1}
turns into this:
$\backslash$autocite[43]{cask1}
I suppose you can FIND/REPLACE to replace $\backslash$ for \ and } for }. Alas! And when I export to RTF, if I use the compile settings in Scrivener to remove \autocite, I’m left with this: [43]{cask1}. The problem is the page number, [43], which cannot be read by Bookends (Bookends uses a different format for reading specific page numbers). So I guess it’s back to square one.
EDIT: UPDATE:
In case anyone is interested! After a number of hours digging for an answer, here is the only solution I have been able to find (as some pointed out in this forum). To prevent MMD from “escaping” the backslash key (as it does in the example I provide above), you need to surround this: \autocite[43]{cask1} with: . MMD will then leave it alone in the conversion to LaTeX.
But typing around a citation not only gets old fast (if you have a lot of citations), it also gets in the way of scanning those citations in the RTF document. So, I tried to set up my compile settings in Scrivener to add these for me, but only when I export to LaTeX (so they won’t be added when I convert to RTF). In other words, under the FIND/REPLACE menu, I replace \autocite with .
It almost works! The first replacement works great, but for some reason, the last replace, } --> still has issues in the conversion to LaTeX. It comes out looking like this: } --$>$.
Does anyone know why this is happening? According to my calculations (ha! I’ve always wanted to say that) it shouldn’t be–it doesn’t happen when I add the syntax directly into Scrivener.
Hi all,
I am figuring out how to get a nice Scrivener → LaTeX integration with inline images that can be referenced. In this thread I found the trick to add captions to the inline image, as described by Amber:
Took me a while to figure out that I was missing the space between the inline image and the “Caption”, but now it seems to get parsed correctly and I get MMD code which seems fine:

However, if I convert the MMD file to LaTeX (mmd2tex) or compile directly to LaTeX the figure caption is the filename “image.png” and not the “Caption”. The manually added “Caption” is just ignored. I also wonder, how to add a reference to the image within Scrivener. The label in the tex output is left empty. Here the code I get in LaTeX
Yes, this is indeed a compatibility issue with MMD3. The manner in which Scrivener produces the image tag is MMD2 compliant, where the caption was placed where the title attribute was declared, in quotes after the image source. The stuff inside the brackets was always the alt and id attributes, and thus used for labelling and linking. So cross-referencing in Scrivener is always a matter of referring to the graphic’s filename.
MMD3 switched this all around. The various spots in the image tag syntax alter depending on the image’s context (inline or on a paragraph by itself), and the stuff in quotes after the source is now the title in all cases, the stuff in front if it isn’t inline is used for the caption. So in other words, the only way to get a caption is to put the image on a paragraph by itself and supply the caption in the bracketed portion. The caption then becomes the thing you cross-ref to.
While I think in some ways the new method fits in better with the rest (cross-refs and hyperlinks, after all, use the first bracketed area for visible text, and in MMD2 images they did not), it’s a change that is somewhat of a bother to me, since I now have many years of MMD files that are set up wrong and incompatible with MMD3. It also means MMD is no longer compatible with Markdown.
There was a brief discussion on the matter a while back, but it seems most people don’t care (or know to go to GitHub to discuss it). So from what I understand, the way MMD3 works now is the way it always will. When Scrivener introduces 3.0 compatibility, it will produce the proper syntax without you needing to change anything in the manuscript. It will use the same “Caption” syntax.
For now though, if you want to use MMD3, you’ll need to type in your images by hand, and use the Scrivener link method to enable image generation automation during compile. If you just type in the image name by itself then Scrivener will not export the graphic into the compile folder, but if you select the image name and link it to a like-named graphic in the Binder, that graphic will placed in the compile output folder.
Hi AmberV,
thanks o lot for your clarifications. I wasn’t aware of the incompatibilities of MMD2 and MMD3. MMD3 seems much better for using your own LaTeX templates to work with the nice Scrivener interface. However, I already spent a lot of time trying to set it up, as the documentation of MMD is by far not as good as the Scrivener documentation.
Anyways, using a Scrivener Link (I did not think about Scrivener Links before) and the

syntax works well. The only issue is that the label is empty: \label{}, but that is again not your pair of shoes, as it is MMD again.
I am thinking of using the Compile --> Replacements feature of Scrivener more extensively. I see the potential to replace some of the extended MMD features, by defining my own tags that are then replaced by pure latex code (placed in HTML comments).
Hmm, you might want to bring that up on the MMD GitHub board as an issue. What’s the point of having LaTeX figures and captions if they aren’t labelled? It sounds like it is trying to add one, but failing somehow. Usually it’s pretty good about not emitting junk code like empty \labels. If it doesn’t need it, it just don’t do anything.
Replacements are great. I use a lot of them myself for this sort of thing. Do note the advanced section in the user manual which demonstrates how you can use variables in replacements to effectively wrap complex code around a provided string. Good for stuff where you need a curly brace on each side of something you supply in the Scrivener editor. Also if you don’t use inline annotations for anything, you can change the comment delimiter in the Footnotes/Comments compile option pane to put HTML comment code around the annotation. Hence: they are an easy way to type in raw LaTeX without much fuss in Scrivener.
Thanks again for your answer and the hint with the extended replacements. Great stuff.
In some coding project I was using regular expressions to do automated find and replace. Very powerful, just a little hard to grasp the syntax. An advantage compared to your replacement with variables is that it can use more than one variable. I just imagine a replacement string with three variables: the Scrivener link to the image, its caption and its label. And the \begin{figure}…\end{figure} stuff you can just write for yourself as you like it. Please regard this as a feature request.
I will also address my issue to the MMD board. By the way, I did not find this on the GitHub site, but I found a Google Group. Is that what you mean? http://groups.google.com/group/multimarkdown
Regular expressions would indeed be cool; I think it might be on the long-term list for general all around improvement of searching. I’ll put Replacements on the list of potentials since that is a form of search & replace.
![This is a caption, which permits internal *Markup*.][fig:myLabel]
[fig:myLabel]: scrivenerlink
yields this LaTeX:
\begin{figure}[htbp]
\centering
\includegraphics[keepaspectratio,width=\textwidth,height=0.75\textheight]{scrivenerlink.jpg}
\caption{This is a caption, which permits internal \emph{Markup}.}
\label{fig:mylabel}
\end{figure}