Scrivener, MMD, and LaTeX problem(s)

Hello everyone,
I would like to be able to use Scrivener to export (through the Compile Draft command) my writing into LaTeX using MMD > LaTeX option. However, I would like the resulting .tex file to EXCLUDE the preamble entirely. The reason I want to do this is because I prefer to use a “skeleton file” in TexShop that contains my own preamble and “calls in” other .tex files (like the one I want to export from Scrivener) using the \include{} command in LaTeX.

I realize that one option is to simply export from Scrivener in plain text format. However, I really like the footnote interface in Scrivener and I like how Scrivener automatically converts quote marks (") into the appropriate `` and ‘’ for LaTeX. So, if possible, I’d like to continue using the MMD > LaTeX option if possible, only without the lengthy preamble.

I read on the boards that using the latex-snippet.xslt file would do what I want. To that end, I downloaded the full MMD from Fletcher Penney and installed it in ~/Library/Application Support/MultiMarkdown (I’m running Mac OS 10.4.11).

When I tried to “compile draft” using the MMD > LaTeX option (without doing anything with latex-snippet.xslt), I got the following error message:

Undefined subroutine &MultiMarkdown::Support::ProcessMMD2LaTeX called at /Users/rperson/Library/Application Support/MultiMarkdown/bin/ line 47, <> chunk 1.

When I remove the MultiMarkdown from my Application Support folder, it compiles without a problem. But, if I understand correctly, I need the full installation in Application Support in order to use latex-snippet.xslt

So here are my two main questions:

  1. What’s going on with the error message from and how might we fix that?

  2. Once that’s taken care of, what do I do to utilize latex-snippet.xslt in such a way that I can produce .tex files without a preamble?

Any help on this would be GREATLY appreciated!

First, you are right in wanting to use latex-snippet.xslt. That is exactly what it is for.

There is definitely something weird going on with your distribution, I think. Try this: edit the script and add the following to line 46

die "$MMDPath";

Then attempt to compile from Scrivener again. It will fail, and the error message should return something along these lines:

/Users/avaesca/Library/Application Support/MultiMarkdown at /Users/avaesca/Library/Application Support/MultiMarkdown/bin/ line 46, <> chunk 1.

The path listing before “… at …” is $MMDPath, so if you get nothing there or it is an invalid path, that might explain why it is not finding the subroutine. Either something weird is going on with the environment setup system, or the version you downloaded had a bad bug in it (I’m using MMD 2.0b6)

Once this does get resolve: To use an alternate xslt, just access the MultiMarkdown settings in the File menu of Scrivener and insert a new meta-data field called “LaTeX XSLT”. In the text entry area on the right, type in latex-snippet.xslt. Now this project will always export in snippet mode without any preamble. This is a per project setting. If you want to make this the default behaviour for your MMD distribution, edit (in bin/MultiMarkdown), line ~74, you should see a line that declares “memoir.xslt” as the default format. If you do not declare a LaTeX XSLT meta-data field in your projects, this is what it falls back to. Simply change this to “latex-snippet.xslt” and you’re good to go.

One last question: does your preferred preamble change a lot? If it is just a static boilerplate you might wish to investigate creating your own XSLT. Try taking a look at one of the simpler examples, like article.xslt. It’s pretty easy to figure out where to insert your own preamble and so on. You can simply duplicate article, call it whatever you like, insert your custom stuff, and then set that as the default XSLT. From then on every LaTeX file you compile out of Scrivener will be 99.9% ready.

Thanks, AmberV. You’re awesome! Keith said you’d be a huge help, and he was right. I’ll give this a try this weekend and report back on the results. As to your final question, my preambles do change a bit, depending on whether my output is an article, the whole dissertation (which requires some arcane formatting rules by my university), or just a draft of a chapter, etc. So hopefully the latex-snippet stuff will work and I’ll be all set!

Thanks again!

No problem! The steps I’ve posted are mostly just analysis and a shot in the dark. If $MMDPath is getting set, we might have to consult Fletcher on what is going on, but another step you can take (and it is a good one to know for a number of debugging reasons) is to compile a plain MultiMarkdown file out of Scrivener and then attempt to execute the MMD scripts from the command line:

% bin/ compiled_mmd_file.txt

At the very least, this can speed up the debugging process as you don’t have to keep waiting for Scrivener to re-compile the Draft. The above command should produce a compiled_mmd_file.tex in the MMD directory.

The only caveat is that Scrivener is using the STDIN clause in that script, and using the file based method would fall back to the else clause which is a different piece of code; though similar enough that the problem should be reproducible. If not there might be something odd in the integration between Scrivener in MMD.

But to repeat I’m having no problems with 2.0b6 and Scrivener 1.5.1, so we should be able to figure out what is wrong.

One other thing I just thought to check:

[code]% ls -l bin/MultiMarkdown

-rw-r–r--@ 1 avaesca avaesca 12472 17 Jul 09:07[/code]

Run that command from the MMD directory and see if you get similar or identical details.

OK, not really sure what all of this stuff means, but I’ve done everything you suggested. Here’s what happend:

  1. Action: Included the die “$MMDPath”; where you indicated.
/Users/rperson/Library/Application Support/MultiMarkdown at /Users/rperson/Library/Application Support/MultiMarkdown/bin/ line 46, <> chunk 1.

Dunno what that was supposed to teach us, but I’m guessing you do.

  1. Action: Exported from Scrivener into MMD (no problems there), placed it in the MMD directory, ran the following in the Terminal:
perl bin/ test.txt


Undefined subroutine &MultiMarkdown::Support::ProcessMMD2LaTeX called at bin/ line 68.
  1. Action: Ran the following in Terminal
ls -l bin/MultiMarkdown


total 32 -rw-r--r-- 1 rperson rperson 12472 Jul 17 12:07

Don’t really know what any of this means, although I did notice the result in step 3 was missing the “@” that appears in your output. Not sure if that means anything.

For what it’s worth, I too am using Scrivener 1.5.1. I’m not sure where to find the version number of MMD, but it’s the most recent version available on Fletcher’s site (I re-downloaded it today). The frustrating thing is that my friend just installed both Scrivener and MMD and hers is working fine (although she is using OS 10.5).

Any ideas?

Okay, sorry about all of the obscurity and such, but all of the results you posted are “in the green”. MMD is finding itself correctly, the support files are readable and the file size is correct, indicating you are using the latest version (you can find that out by running the script with the --version flag, but unless that file hasn’t changed, I’m sure you’re fine on that score). The @ sign is fine, that is a special OS X flag which indicates a file has extended attributes; spotlight meta-data and so on. The lack of it would have no impact on the script itself.

The only real clue that I see here is what you said toward the end. I wonder if perhaps there is a compatibility issue with the version of Perl that is installed in 10.4. That would seem odd to me; it’s been a number of years since I’ve really been into Perl scripting, but I think most everything going on here is fairly standard.

I think this is going to be something that Fletcher might need to look in to. I’d post your problem in the MMD Google group, and link to this forum thread for back reference so he can see what we’ve attempted to discover thus far.

I’m sure that if there is a problem with MMD 2.0b6 and OS 10.4, he’d like to hear about it.

from a terminal window do a

perl --version

I don’t have a .4 machine but the current .5 version is 5.8.8. If your version is not 5.8 there may be an issue with your perl version.

5.6 and 5.8 do have substantial differences. Off the top of my head it sounds like you are 5.6 as there were some changes to how sub routines needed to be defined. Not that I can remember those differences, but they exist. Either way AmberV’s suggestion of going to fletcher is probably the best bet.

Thanks, guys. Looks like the version of Perl I’m running is the following:

This is perl, v5.8.6 built for darwin-thread-multi-2level (with 5 registered patches, see perl -V for more detail)

I’ll go ahead and see what Fletcher things about all of this. Thanks again for all your help so far!

This discussion has moved to the MultiMarkdown discussion list. It appears to have been a perl version incompatibility, which I think has been fixed. Still working out a kink or two, but I think it should be set.

Just wanted to report a happy resolution to the problem. Many thanks to Keith for directing me to this forum, to AmberV for her help sorting things out, and especially to Fletcher for working so patiently to get the MMD/Perl issues fixed.

Everything works great now, including my original desire to produce LaTeX output in Scrivener without the preamble. Thanks, everyone!

Hi Rob, great to hear you got it all straightened out. Thanks to AmberV and Fletcher, too, as I was out of my depth on this one. :slight_smile:
All the best,