Creating new MMD-LaTeX compile formats

Revicing this topic I know but I would love it is if it were possible to use any LaTeX class not only the few that ship with Scrivener. Most of my LaTex documents are intended to be in the Tufte Handout class; I know that the Tufte Book class is one of the shipped alterantives.

It is because of Tufte Handout that I have not been able to stop using LyX for the preparation/maintenance of those documents.

I’ve moved this to a new topic since it is about using Markdown to generate LaTeX while the other topic was about not using Markdown, specifically, and composing the .tex directly in Scrivener.

For tufte-handout this should be fairly simple to create, since as you note MultiMarkdown has an example setup for it. If you haven’t already, I suggest downloading that whole mmd6 archive and putting it into your texmf folder under the indicated path on that page. That will (a) stop Scrivener from dumping a bunch of .tex files into your compile output folder since it will detect they are already present, and (b) make it easier for you to develop your own derivatives.

While you are there, read through the short readme file as you will want to know how to set your .md file to use a particular LaTeX setup. As you can see it is very easy, just one metadata key will do everything you want.

So let’s use tufte-handout as example, first to in a basic way add support for an existing boilerplate, and then secondly to demonstrate how we can fork our own custom setups or even build our own from scratch.

Setting up Scrivener

  1. I’d recommend starting with one of the sample Formats, since those will do some legwork you may have to replicate otherwise. While “Book (Tufte)” might seem like a good starting point for Handout, I don’t know for sure about that as what sets it apart are some things specific to the Book document class. Book-Memoir is probably best as that is very generic—but I don’t know much about Handout, so do whatever is best.

  2. Once in the compile format designer, the first thing you’ll want to do is go into the LaTeX Options pane and change the document class to “None (Use Metadata)”.

    Note: you’ll see one of the options here is “Custom”. Have a look at the stock “Modern (Custom LaTeX)” to see how this can be used. While I prefer the file based approach because I have a whole setup with my coding editor for managing those, there are advantages to embedding the whole setup in the compile format, too—such as being able to distribute your creation with minimal instruction.

  3. Now select the Metadata pane to set that part up, and click the + button to add a key called “LaTeX Config”, just like the readme documented. For the value, put ‘tufte-handout’ to match the naming convention of the boilerplate files you installed earlier.

  4. Lastly, give the Format a good name and save it to “My Formats” so all your projects can use it.

That’s pretty much it for the minimal basic setup. If you save that and give it a test compile with some material set up for that document class, you should be seeing the desired results, and can tweak the other settings from there.

Creating a derivative boilerplate

All right so at this point you should have a vanilla MMD sample of the handout class working, but you’ll likely want to adjust it to your own purposes a bit; add your own macros, adjust the paper size, whatever. This is very easy to do once your wrap your head around the modular design these MMD .tex files use. Here is how I do it:

  1. Go into your texmf/tex/latex folder, wherever that may be, and create a subfolder for your own modifications.

  2. Copy the tufte-handout folder from the mmd6 folder into your own, and change the names of the files. Everything between the outer hyphens is the keyword for this setup, what you will supply to the “LaTeX Config” metadata key, so just keep that unique and consistent between all three files.

  3. As you go through those you’ll see they input a lot of stuff from other .tex files in the MMD distribution (mostly in the ‘shared’ subfolder). When I want to modify how one of those works, I usually just mirror the folder/file layout and rename the file, then change the \input{...} line to point to it. But that is all up to you of course. You can also just inline it if you don’t intend to keep the modular approach for your own stuff.

  4. And naturally, once you’ve done that, go back into your compile Format and change the Metadata to use the naming convention you established for the modified handout setup.

Normally you’d do things the other way around if the intention is to make your own forked version like this, but I figured I’d describe it in this order in case the vanilla settings are fine.

Wow, thanks.

Will make me a breif while to work through all that but it won’t be until next week as we have local council elections tomorrow (4th May 2023) and although not a candidate myself I have been heavily involved in promoting and supporting the Green Party candidate plus am slated to observe the count on Friday morning.

But if it means I can finally dump LyX and work entirely in Scrivener that will be wonderful.

1 Like