[This may be a Multimarkdown bug but I think it’s caused by how Scrivener “instructs” Multimarkdown.]
Context/setup
I’m compiling my Scrivener Project into LaTeX with Scrivener LaTeX options set to “None/Use Meta-Data”.
I want to save the Scrivener-produced LaTeX file into a directory with other LaTeX files, one of which then calls the Scrivener-produced LaTeX file as part of a bigger project. This is why I only want a snippet and not a full document with preamble and end.
Expected behavior
Scrivener should produce a “LaTeX snippet” with content only, i.e. without preamble and end.
Observed behavior
The result correctly does not contain a preamble, but it does contain an “\end{document}” tag. This results in the project ignoring any LaTeX code being called after the Scrivener-produced file. Concretely, I had to search for hours why my LaTeX project wouldn’t include a bibliography…
Proposed solution
When Scrivener produces a LaTeX document with “None/Use Meta-Data”, ensure it does not add the “\end{document}” tag.
Scrivener’s job stops at the production of a plain-text file using MultiMarkdown conventions for meta-data, headings and a few other components, after which it feeds the file to MMD and waits for a result. You can compile with the plain MMD option and examine the file that Scrivener generates, looking for problems within it. As you’ll note, nowhere in that file will you find an string (unless you typed it in yourself), and that’s the only possible way in which Scrivener could inject raw LateX into the output. That’s a good trick to keep in mind in general, when debugging an undesirable output. Plain MMD = Scrivener’s side of the equation; anything that results from the processing of that file into the end format is MMD’s side of the equation.
So what the “None” option does is hand over full control of the design and structure of the document, and as implied, that is done with meta-data. The structure of your meta-data determines the document. A snippet should not, by definition, have a title. If a document has been provided with a title, then MMD takes that as a signal that this is a document. If there are no “complete document” defining meta-data fields applied, then it will drop to snippet mode. This is true for all formats MMD can produce, not just LaTeX. Snippet mode will give you HTML meant to be inserted between body tags, but if you throw a title meta-data into the MMD file you’ll get a complete HTML5 page.
The “None” mode can also be used to define an elaborate set of inclusions to build a complete document. It is not simply “I want nothing”, it is “don’t automate any of this, I want control”. With that you can build your own Memoir subclass or you can strip out all structure and just export a snippet, and everything in between.