Semantics Markup, Latex without MMD, and Scrivener

I have found that I can very easily use Latex with Scrivener, using my own markup (very much like the Semantic markup of Ulysses.) This allows me to use any Latex package I want; set it up the way I want it; without getting into the business of style sheets, MMD, etc.

Like the semantic markup of Ulysses, the markup I coin, can mean different things in different contexts (for example: while exporting to Latex, my markup can mean one thing; while exporting to Word, another.)

Using Latex without MMD

So, to set up your project to use Latex, just drop a page in Scrivener, and make this your very first page. If, for example, you are using the sffms package (which I use, and is perfect for short story & novel,) just paste this on this page:

%First Page%
\author{Your Name}
\title{Your story title}

Then, create a Last page for your project (this should be the very last page,) with just one line of content:

%This is the last page%

And, that’s basically it. All your content pages go in between the First Page and the Last Page. You simply compile your project as a text file (note: no export to MMD,) with a tex extension, and compile it in TextShop to get a perfect Latex document.

Using your own (semantic) Mark Up

You can coin any markup that is convenient to you; and then simply use the Replacement option in compile setting to change the meaning of your tags. For example, I have two compile settings: one for Latex, the other for rtf. Taking the example of italics, I want italics to me marked up as \emph{TheItalicWord} when compiling to Latex ; and as TheItalicWord, when compiling to Word(rtf) – this is because, I can do a AutoFormat in Word, and Word flips anything tagged as TheItalicWord to regular italics.

My mark up for italics is: [b] i]TheItalicWord[i [/b]

And, This is what my Replacement option looks like in my two compile settings:

i] with \emph{
[i with }

i] with _
[i with _

You get the idea: just coin any starting and ending tags, and use Scrivener’s replacement option to make it mean whatever you feel like. That’s what Ulysses does doesn’t it? I have set up my own tags for quite a few Latex tags–and I get excellent results. It turned out to be so easy-- that I almost got sentimental (for a quite a while I researched many other products, including Ulysses; and finally found the Scrivener can do a much better job at Semantic markup & Latex, then even Ulysses.)

I hope this is useful to you


Excellent post; thanks for putting this together. You could also enable smart quotes while writing, and then set up replacements for “ -> `` and ” -> ‘’ and etc. You’ll probably want to also escape a few common characters with replacements as well, like &.

There are a few other tricks you can use. Use the Formatting pane to assign binder titles to LaTeX headers. Since Scrivener allows multi-level rules, you could go from part down to subsubsection, with everything below that point being emitted as an sss. Meanwhile you should be able to create a custom meta-data field for the section label and emit that in the title suffix as well, like so:

For some reason it isn’t evaluating though; I thought we fixed that. Hmm.

Well, at least the title part works. Just add “\section{” for the prefix and “}” for the suffix.

Also take a look at Separators. Those can be awfully handy for inserting procedural items. In fact MMD inserts a \pagebreak command when using the MMD->LaTeX command, if you set any of those to page break. Similar ideas could be used here, such as inserting a nice divider between text sections.

One thing that is already on the table for consideration is allowing you to adjust the prefix and suffix for footnotes in plain-text. This would allow you to use Scrivener’s built-in footnote feature to write footnotes, and then compile them with \footnote{} syntax. I’m not sure what the status of that feature request is at though.

You will love the $@ token in Scrivener’s ‘Replacements’ dialog. :smiley:
See Ioa’s explanation here.

Yes. Thanks for bringing that one up as well. That is an invaluable trick when constructing your own expansion syntax with replacements. Should cut your list down quite a bit!