Pandoc can be used with MultiMarkdown. I posted some notes on usage a while back. I’m not sure if all of that is still up to date, as the maker of Pandoc was at that time still adding support for the MultiMarkdown dialect, and I believe it is more robust than it used to be (and it wasn’t too shabby before, I recall turning the Scapple user manual into an ePub using Pandoc with only around half an hour of tweaks, mainly to strip out highly specialised LaTeX outputs and replace them with HTML/CSS formatting).
Perhaps I was not explaining the background well enough before. MultiMarkdown itself has the capability to type in footnotes using its syntax, like so: [^1], and a line with the content somewhere else:
[^1]: Here is the text you'll see at the bottom of the page where the fn1 footnote ID is referenced.
However with Scrivener you needn’t do that yourself. When compiling to any MMD based format, it will convert all footnotes (Inspector Footnotes and Inline Footnotes alike) into MMD syntax such as the above example. If you select a compile format that invokes the MMD engine and produces a target file format (such as LaTeX). MMD will do its best to turn these footnotes into the proper form in the output file, such as \footnote{Here is the text you’ll see at the bottom of the page where the fn1 footnote ID is referenced.}. So again, there is no syntax in the editor, no noise as you put it. There is no need to generate footnote syntax into the compiler, either. All of this should just automatically work for you if you’re using the MMD workflow.
[size=200]Customising MultiMarkdown with XSLT[/size]
Okay, as to XSLT, you could probably fix this with a simple search and replace in the sample XSLT file that is distributed with the post-processing scripting package for MMD, but I’ll describe building a modular file that only overrides the citation functions in the main LaTeX generator file.
First, if necessary, download the official Mac Support support package. This will contain scripts and examples for using XSLT files, which will be installed into your ~/Library/Application Support/MultiMarkdown folder. Just in case you were wondering, Scrivener checks for the presence of this folder when you compile. If it is found, it will use this folder for post-processing instead of its normal built-in system. If you have not done so, you should probably also install the most recent version of MMD (again, Scrivener will defer to a system installation if one is found).
So, navigate to the MultiMarkdown folder mentioned above, and drill down into the “XSLT” folder. The key generator file for LaTeX is xhtml2latex.xslt. Rather that customising that directly, I would recommend using a wrapper file, similar to what you would see if you open the memoir.xslt file—if you aren’t aware of how this works, basically you can tell one XSLT file to use another, and in the host file you can override how the initial file works (kind of like how CSS works if you’re familiar with that)—so it’s a great way to customise the default LaTeX output without risking the originals. It also keeps your modifications modular and easier to maintain. You’ll want to use the main xhtml2latex.xslt file as your reference—that is where you will look up how \citep is output, and then copy and paste the necessary XSL code structure that into an override file modelled after the memoir file.
If you search for \citep in the ‘xhtml2latex.xslt’ document, you will find it is referenced in three places:
- Within the handler for anchor elements, which are what MMD uses for footnote and citation markers in the HTML output.
- For external citations.
- For standard citations.
The latter two are simple, you would only need to copy those two xsl:template elements and their child instructions into the override file. The first one is a little more complicated because it is located within a logical case argument that checks against numerous different anchor classes. For that you would need to copy and paste the whole template match structure for a[@href], only changing the part where those anchors classed as ‘citation’ are output (there may be a more efficient way of doing that, but I’m only somewhat fluent in XSL, whatever the case my method certainly won’t hurt anything).
I have attached a very simple example which uses the memoir.xslt layout as a starting point, but has modified all \citep output to \autocite. Once you have placed that file in your …MultiMarkdown/XSLT folder, here is what you will need to do in Scrivener (assuming MMD to LaTeX output):
- In the Compatibility compile pane check off “Use XSLT post-processing”.
- In the Meta-Data compile pane, add a key called “LaTeX XSLT” and for its value you would type in the xslt filename (you can omit the extension). So using this example file as-is, you would type in ‘natlib’ as the value.
When you use the XSLT workflow, you are no longer using the standard LaTeX generator. If you’ve just been using stock output so far, this is going to be a somewhat academic point. The output is the same, it just uses a completely different mechanism for producing it, whereby it first converts the MMD file to HTML, and then uses the XSL language to process the HTML file into LaTeX. What this means in practice is that the typical methods for adjusting the preamble and footer will no longer be relevant. In fact you may notice when you tick off the XSLT checkbox, the LaTeX Options panel is completely removed from the compiler. To customise the preamble at this point, you either need to insert your own “LaTeX Input” and “LaTeX Footer” lines into the meta-data block, which should point to the boilerplate .tex files that establish the preamble and footer. You’ll probably want to do that anyway, as the default XSLT generated output will not be a complete .tex file, but just the stuff within the \begin{document} environment. But you can of course also just paste that output into an existing .tex boilerplate.
As you can see, it takes a little wiring to get all of this working, because the process is infinitely more flexible than the easier methods. However the result is, like I say, full control at that point. You can generate custom syntax to expand MMD’s stock tools, radically alter the type of TeX document produced, and even go so far as to produce document formats that are not even LaTeX files.
natlib.zip (1.79 KB)