LaTeX header and begin document components missing in compile

I’ve been having this problem for a little while, but I am only now getting around to solving it.

When I try to compile my document—written in MMD— to LaTeX, Scrivener will output a folder of files, including a master file with the text, and a header, begin document, and footer file. The master file, however, does not have




lines in the resulting LaTeX file. Curiously, the master file DOES contain an


for the footer file.

I use a “custom” LaTeX format when I compile docs written in MMD that invokes standard packages I use, my bibliography file, and so forth. But I have tried this with the bog standard L&L LaTeX compile settings, and I’m getting a similar result (no \include{} at the top of the file).

What could be causing this? Ideas on what I must have toggled on at some point that’s causing this?

Are you using Scrivener 3 at this point? If so, in the compile overview screen, click on the Metadata tab on the right and then click the Preview button. Does that all look like it should?

If you haven’t upgraded yet, I can’t think of any combination of settings that would cause that result—there isn’t anything that would do that on purpose for sure. Myself I’d first check for MMD version on the disk, I’d try the basic “Memoir” option and see if that works. I’d try pasting in my preamble and footer content one tab tested at a time to ensure there are no problems with my content, etc.

So I’m hesitant to upgrade entirely to S3, for the reason that I’ve got these pre-sets and such to output fairly complicated markdown (figures, tables, headings, etc.) for academic papers. My settings were working at one point, and I’m a little hesitant to change until these things are off my plate.

That said, I like Styles, and drop-in figures automagically generating approopriate MD, and some of the other new features, and if the changeover were possible without TOO much frustration, I’d probably do it.

mmd --version gives 6.2.2

So I tried just a plain memoir document with the default L&L settings, and no header or begin-doc \include commands show up.

Is this an MMD 6 issue?

Not quite sure what you meant by:

Could you elaborate?


Yeah to digress a bit: I am very much an advocate for clearing one’s plate before making any dramatic software, tool or OS version changes, if at all possible—unless of course the deadline is so far off that the expense of learning new tools and patching around things that broke can be absorbed.

In practical terms, I recently updated the Scapple user manual project from v2 to v3 in about an hour—if that. Of course the grain of salt is that I already know version 3 inside out. So I wasn’t learning the new compile system on top of converting it. That said, we did strive to make the transition as easy as possible. Here is roughly what I did:

  1. Loaded the project in v3, let it upgrade.
  2. Opened the Compile window.
  3. Clicked the gear button below the Formats sidebar and opted to import my Scrivener 2 settings as a new format.
  4. All of my replacements, formatting pane settings, custom LaTeX setup—all of that imported without a single hitch.
  5. For the sake of aesthetics, I went into the Section Layout pane (what roughly serves as the Formatting pane did) and gave those “level 1+” entries some nicer names, like “Heading and Text”, or “Verbatim”.
  6. Saved my format.
  7. Assigned the section types Scrivener had generated for me during the upgrade to the new Layouts I just modified. (That might all be gibberish at the moment, but it’s a pretty straight-forward thing once you go through the 5-min tutorial section on the concept).
  8. Compiled.

The Scapple manual project uses quite a lot of Scrivener in fact, at least in terms of what v2 provided. It had a pretty involved compile setup, and wasn’t too basic in terms of LaTeX and MMD either. Most of what I had to do was simply telling v3 that I wanted to bring all of those settings in.

Of course we who use Markdown in the editor don’t have to worry as much about upgrades changing how the content appears or anything like that. A table in MMD, no matter how complex, is just a bunch of punctuation. Scrivener isn’t going to be touching any of that, and the only thing that does is the MMD engine itself—which isn’t changing.

At the least I’d say maybe give the demo a shot. Nothing will be harmed save an hour or two of playing around with it. The benefits could be substantial though depending on what you need. I’d like to think most of your transitional time would be spent on “ah-ha!” moments than frustration. :slight_smile:

Ah, that’s the problem. MMD6 changed the metadata keys used to refer to includes. Scrivener will be generating “latex input” keys, not the new ‘latex leader’ and ‘latex begin’ keys.

That’s an easy workaround: type in the metadata you need into the Meta-Data compile option pane, referring to these files where they will be. For example:

latex leader: mmd-scrivcustom-header

Scrivener will go on inserting the wrong keys, but MMD ignores them now so they shouldn’t hurt anything. In my testing it works fine.

I agree with you about not wanting to change software in the middle of something big, but I have no idea when these project will really be done (long story), and I have almost every confidence in you at L&L. Your experience with the Scapple manual seems indicative of the fact you’ve put lots of effort into making this pretty seamless. :smiley:

And I’d really like styles and drop-in graphics.

Hmm. So I did a quick import of the old project, and the same LaTeX problem keeps occurring—no header or begin-doc \include commands. I haven’t looked around much on MMD, but I have heard that there’s some large change with the way it handles LaTeX commands?

Yes, you would need to use the same metadata trick I posted above to get things working in v3. We’ll be getting it upgraded to MMD6 shortly, as soon as the flurry dies down a bit.

Do you mean the approach of putting LaTeX into HTML comments? If so, yes, that did change. Nontroppo posted some tips over here.

Oh to clear up one thing though, v2 has always supported drop-in graphics being converted to MMD. The main new thing we’ve added there is a general new thing to Scrivener, and that’s the ability to link to graphics from the binder, rather than ending up with two copies. That way you can keep your figures organised as files on a corkboard that are all tied back into the manuscript. I still use the file system for that though, I like having graphics readily available to Photoshop and GraphicConverter.

Apart from LaTeX raw input, also see: … t.txt#L296 — discusses the changes to the LaTeX templates and metadata

I tried this exactly as described, but in my master .tex file get


and an error “File ‘mmd-scrivcustom-header:’ not found”. Appending .tex to the header file doesn’t help, I still get the colon at the end and a file not found error.

Any ideas?

Hmm, that looks like a bug that crept into one of the more recent builds. Thanks for the report!

For now: compile to MultiMarkdown and then process to .tex on the command-line. We’ll be putting out a general bug fix patch for 3.0 pretty soon.

Hmm. I know I did something that got around this, but I’m not at home right now and on a work computer, so I can’t check what I did to my metadata to make compilation work with no prob. WIll try to check in later.

Well, I reproduced this one the first time I tried, and now no matter I do I can’t get it show up again. I’ll keep trying, but if anyone else spots a pattern let me know.

I’d appreciate it, as it’s the same every time for me! Even deleting the whole tex directory and re-compiling still appends the colon onto it.


So in the compile settings (because I have some particular stuff I want to do in my LaTeX output), I have created a compile format with a custom LaTeX template (my own header, begin, and footer, that puts in the packages that I want and use). In the Metadata panel (second pic), you can see the data I’ve entered. In the first pic, you can see what I mean by rolling my own LaTeX template.

I’m using Scriv 3.0 (75).

I wouldn’t think anything related to files would be involved. Scrivener, and for that matter MultiMarkdown itself, don’t really care much about what .tex files you have when typing in your own include codes or using the custom settings. It probably has more to do with some variation of syntax—are hyphens used, spaces in key names, etc.

Emma: maybe if you could export your format to a file and attach it I could have a look at it and see if I get the colons as well? Right-click on the format in the compile overview screen to do so (and feel free to PM me if you don’t want it shared publicly).

napaxton: I think your settings look good, but I’d double-check the placement of the “Insert Project Metadata Here” row. Perhaps in MMD6 it doesn’t matter, but it used to be important that stuff like “Title” and “Author” fall between what is now the ‘latex leader’ and before what is now the ‘latex begin’ keys.

Actually, most of my metadata are in a file/doc in the “Front Matter” ahead of the Draft group, and they have worked pretty nicely there. That metadata gets loaded first, then the stuff in the compile settings?

In any case, my rationale is that i can save the compile settings to work in a more “universal” fashion if I put project specific meta data in a Front Matter file. Or does that not matter?

Yeah, so long as it works!That’s a good way to go about it. You can also put project settings in the compile overview screen itself. There is a metadata tab over by contents, settings, etc. that also has a preview button you can click to see how all the metadata fits together. I like to use metadata files in the binder when a project has several different outputs. I can swap those out with the front matter setting, declare project universal stuff in the overview (author and such), and then document class and so on in the format itself.


It appears to be a MMD6 issue as I’ve reverted to MMD 5.4.0 and everything is working fine. Think I’ll wait a while before updating :slight_smile:


Hmm. While I’m glad it works, I don’t think it is strictly an MMD 6 issue, as I have MMD6 on my home machine.

I know I am running MMD 6, because I have my MMD installed via Homebrew, so I’ve got a fairly recent version (no more than a week old right now).