LaTeX/PanDoc tutorials

I could ask this in a new post, but I am curious if anyone has a good tutorial or example of using LaTeX or PanDoc with Scrivener. I did many searches and found some articles, but nothing clear-cut. It seems these tools are mostly Linux-based, and that use base is used to a completely different way of doing things.

Just to install Pandoc and the bit to automate Pandoc already required installing Ruby and then several other modules using gem etc.

I want to do things like add in a TOC, update the headers, fonts, change the page size, add drop caps and chapter graphics etc. It seems like once you have the method down all you need is to tweak your scripts based on the genre you are writing for, but to get to that point you might need a new university degree.

1 Like

Since we have an entire subforum devoted to using LaTeX and related tools with Scrivener, I thought your post might get a better response there. So I moved it.

You might also want to read the relevant sections in the Scrivener manual.

Scrivener+Pandoc to output to LaTeX/PDF/docx is very doable, without Linux (that is, with Mac or Windows) and without Ruby scripts. What is your machine type, and I take it you are already familiar with LaTeX?

Thanks for moving the question.

I used LaTeX in the late 80’s early 90’s at uni, so I need to learn it again. :smiley:

I guess the answer to configuring Scrivener and LaTeX is in the help file, I will try that again. The last time I looked, I did not see instructions to help me get it going, but I probably just missed it.

Well, I compiled MultiMarkDown → LaTeX, then ran pdflatex on the main .lex file, and that produced a PDF file. Now I have to figure out how to customize the LaTeX Header, Begin Document and Footer files (I made a copy of the custom LaTeX format. Hopefully, I am on the correct path.

I did see the comment about Pandoc. I will try that again as well.

The great thing about Pandoc is that you can write in Markdown, include LaTeX only when absolutely necessary (e.g. equations and symbols), and then output to PDF and docx without having to mess around with the standard messy LaTeX interface. Of course you can also output to LaTeX, if you need/want. But since moving from LaTeX to docx is a real pain, there is great virtue in writing in Markdown and using Pandoc to compile to the file format you need. I wrote a whole book draft in Scrivener with the targeted output LaTeX. Big mistake. Publisher demanded a docx file at the end. Now I’m rewriting (for independent reasons) and am doing it in Markdown and using Pandoc to compile to whichever format I need.

I will find and post below the thread here that helped me most when I was using Scrivener as a rich text editor for LaTeX.

Here’s the thread that helped get me up to speed using Scrivener as a composer for LaTeX. As @AmberV explained there, Pandoc isn’t involved here. The Scrivener template is set up to produce a .tex document which I then pasted into Overleaf to compile to pdf.

As I say, now I use Scrivener as a Markdown editor and have Scrivener call upon Pandoc to compile to any output format I want.

As a first step, I recommend you create a new project based on the “General Non-Fiction (LaTeX)” template. Read the outstanding/clear document at the very top of the Binder which explains how to use the template. Compiling results in a *.tex file you run through a LaTeX compiler (or whatever they are called). I’ve used texmaker for years. There are others.

You can inspect the Scrivener compiler settings for how they do this magic. You have full freedom to tweak these settings into your own preferences, including other LaTeX doc classes.

I can’t help with using PanDoc as I’ve never, for the stuff I create and publish to clients, needed to move away from that described above. Yes, many “tweaks” in for creating the *.tex file have been very useful.

Edit: My tweaks were to add an automatic Table of Contents. Index, fonts, etc.

1 Like

To add to @jpkell — the advantage of Pandoc is the flexibility it affords, given that markdown can be cross-compiled and is supported by so many other tools. In Pandoc you can see the default latex template like so:

pandoc -D latex > ~/Desktop/default.tex
open ~/Desktop/default.tex

You’ll see tex code interspersed with Pandoc’s template language. The template language allows you to use pandoc variables to modify the output. You can edit this file then pass you modified version. My modifications can be seen here:

Which are targeted to academics who need author + affiliations + correspondence etc. at document start

Pandoc also allows you to use metadata to flexibly add additional fragments of LaTeX either within the latex template heading or you can use latex fragments in the main document body.

My workflow uses Ruby to better manage Pandoc settings but this is not required, it is just a workflow improvement as I use Pandoc for everything from signed letters to presentations to grant applications to academic papers. The ruby module allows me to change one line of metadata and totally transforms the outputs.

2 Likes

Wow. Thanks guys. Lots of information. I will continue on my quest to better understand this world. I am a programmer, thus used to having to learn new things like this. I was, however, trying to find a simple path to get what I am looking for without being an expert in all of this.

I did not look at the non-fiction templates in Scrivener because my published book is a contemporary romance book, and the one I am currently working on is fantasy. Each of those requires different formatting to fit the specified genre.

I will admit that I did not pay much attention to Pandoc because markdown is such a simplistic markup. That makes it easy to use, but it did not look like I could use it to add custom chapter breaks, for instance.

I have much to learn.

Specifically to come back to this query:

Yeah, that’s probably the easiest way of doing it, particularly if you want a handy self-contained compile Format you can just archive and restore into Scrivener over the years. The alternative is to make the .tex files for these yourself and stash them in your texmf folder, so that MMD’s \input{...} calls find them. The rest is all naming convention. I did write a short tutorial on how to create your own MMD setups, like you see represented as Formats in the compile sidebar. There is another posting here that pretty much covers the same ground, but does go into a little more detail about separators, what you might find interesting for novel writing, if you want a fancy scene break, or even just a vspace.

Pandoc is undeniably more flexible, but I wouldn’t underestimate how much you can do with MMD’s pretty basic system as described. The user manual PDF is after all an example of how far that can go, as well as how far the Memoir-Book class can go (although I will admit I did come close to stressing its limits here and there—it only barely tolerates the package I use for chapter-ToCs).

On that, I would say that the project template isn’t necessarily glued to non-fiction. It certainly does cater to it, having examples for how equations, figures and other things can be done, but at a higher level of examination, it could be used for a wide variety of purposes.

One important caveat to bear in mind with that template though is that it is not Pandoc based. It is a demonstration of how we can “teach” Scrivener to create a specific file format via compile settings. It only makes .tex files in other words. If you want .epub or .docx down the line for proofing, it’ll be more difficult to get there, whereas with Markdown it’ll likely just be a switch in the compiler and maybe a little tweaking to get the output looking like you want it to.

My recommendation is to first make sure that what you want to do cannot be done straight from Scrivener. Scrivener is incredible, and it can do incredible things on its own. Good luck!

1 Like

i tried to get Scrivener to do everything for me. It is great in most things, but just falls short on a few things it was not designed to do, so I don’t think you can blame it. It does provide interfaces into things like pandoc and latex, many other systems don’t. I tried Campfire and it’s a very nice polished interface, the character and place development is awsome etc., but you can only compile to their PDF and edoc and the export function leaves a lot to be desired. With Scrivener you just have to learn how all this stuff works and do loads of reading and experimenting. If I figure out an easy way to get my workflow going I might put in the work to create a blog post/video.

1 Like

I tried several things last night and got a bit more done directly using the MS Word output from Scrivener, but there are things I just won’t be able to do.

I am trying all sorts of things to try and understand the best path to take. All you need is for one thing to simply not be possible given the path you take to stop that in its tracks.

My hope is to use Scrivener as much as possible as an editor, using styles, and so on. Then have the compile add things like drop caps, table of contents and do other things that I have not seen in Scrivener, like advanced font settings to change the spacing for a specific look.

If you look around the forum, you will find many ways of doing this. In my case, this is how I am doing it these days, using Quarto/Pandoc.

P.s.: Ruby is required. (No gems, just Ruby). On Windows, this means installing it.

See also ScrivQ | A template to control Quarto, export multiple files, manage bibliography and easily create cross-references

As I said above, I tweaked the Scrivener template to do TOC, index, fonts, etc using LaTeX controls set in Scrivener template to enable automation. I am assuming drop caps also can be done in LaTeX by a command setting in the Scrivener template—but i never have done that.

And I recommend you be careful about over use of Scrivener styles and let the compiler and LaTeX do the hard work of formatting.

Edit: Scrivener does not work like Microsoft Word.