Post-processing of .tex files from within Scrivener

I posted a query about being able to see the PDF of the LaTeX corresponding to the MMD source code as a document all within the same Scrivener project (using split-screen) here:

https://forum.literatureandlatte.com/t/compiled-draft-as-document-in-project/11325/1

and now that I have seen what that looks like (MMD and PDF’d LaTeX in one Scrivener view omg! it looks so natural) I want more…

My normal workflow is compile to LaTeX, open in TextMate, compile the .tex from there (which does multiple passes, BiBTeX and LaTeX2PDF magic etc), and view in Skim.

I’m just wondering if there is a way to pipe the source file into all that post-Scrivener processing (perhaps in a shell script) from within Scrivener itself as part of the compile process… (I know, I’m greedy, but this is soooo cool…)

Cheers,
Mike

You’d need to take the shell script route. The basic steps will be to download MultiMarkdown and install it so you can more easily edit the scripts it is composed of. Scrivener will automatically use the installation if it is placed in a ~/Library/Application Support/MultiMarkdown folder. Within that folder, you’ll find a ‘bin’ directory, and within that you’ll find the script called “mmd2LaTeX.pl” that is used to convert an MMD file to a .tex file. This is the architect script, it sets up a few defaults (such as memoir.xslt if none other is specified), and then pipes the data around to different scripts, finally producing a .tex file. So to add post-processing you’d want to insert it into that script.

The only catch in this is that when you compile you’ll be unable to specify the filename as “something.pdf”. The best you can do is “something.pdf.tex”, so you’ll need to either write a folder AppleScript or some other utility that converts “.pdf.tex” to “.pdf” when the compile lands.

Of course, the risk of working this way is that you are completely out of the loop. For documents nearing completion, this may not be a problem, but in the early phases you’ll probably want those warning messages, overfills, missing images, missing cross-references, etc. And if you have any errors that make it impossible for pdflatex to produce a PDF, I’m not sure how good the error reporting will be within Scrivener. So to work around that you could compile to a plain MMD file, open that in TextMate, and produce the .tex file from there (if you have the MMD bundle installed, which you should!).

Brilliant, that’s exactly what I was looking for. I’ll experiment with incorporating a latexmk command in that script and see what I get (and where latexmk’s error messages go…)

Cheers,
Mike