How to suppress Part in MMD > LaTeX Book (Memoir)

rd
rdevriese
Posts: 2
Joined: Sat Nov 28, 2020 2:14 am
Platform: Windows

Sat Nov 28, 2020 2:32 am Post

Hello,

I'm using Scrivener 3 for Windows beta and compiling for MMD > LaTeX using Book (Memoir) format. I've configured Project Setting's Default Types by Structure such that Chapter is associated with Level 1 folders, Section associated with Level 2 folders, etc. Folder groups and Files are configured accordingly. Part does not appear anywhere in the configuration. The generated .tex is converting Level 1 folders to LaTeX \Part and Level 2 folders to \Chapter. My expectation was that Level 1 folders should map to LaTeX \Chapter Level 2 should map to \Section.

I am using the Book format because I want a separate title page and TOC. Also, I've verified the document compiles correctly if I compile to plain text and use the LaTeX (Memoir Book) format--generated output is as expected. Can you please provide guidance for what I am doing wrong, or is this the expected behavior.

Thanks so much for assistance.

User avatar
AmberV
Posts: 24515
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Ourense, Galiza
Contact:

Tue Dec 01, 2020 2:51 pm Post

One thing to be aware of with Scrivener’s Markdown output of your outline structure is that it pretty much completely ignores section types and has no idea what you mean when you change the name of things from “part” to “chapter”. In a more traditional use of the software, you would indeed create a whole pack of hierarchically named section types like that and then assign them to each individual level, and then go into compile and pair up each level of your outline to a different layout to make it act like a certain thing… it’s what most of the tutorials will describe as being necessary.

But, with Markdown it is a great deal more straightforward because that system already has a concept of actual hierarchy built into it, we don’t need to fabricate the notion from scratch with dozens of settings. Scrivener+Markdown users can often get away with having only one or two section layouts total: one with a heading and one without. In Markdown, hierarchical heading structure looks like this:

Code: Select all

# One

## Two

### Three

## Two

## Two

# One


By default, MultiMarkdown turns that into:

Code: Select all

\part{One}
\chapter{Two}
\section{Three}
...etc...


Scrivener, by default, is going to map your outline hierarchy in the draft directly to hash-based depth. Barring cases where you wouldn’t want all draft structure to come out as hierarchy, this result is generally always correct. I.e. if you don’t need parts, one does not do something like this:

Code: Select all

## One

### Two


I mean, you can, but it’s not best practice. It’s better for the outline structure to be abstract. A single hash doesn’t mean “part”, it simply means the highest organisational unit in the output.[1]

So to satisfy the problem of cases where the highest unit is what might be effectively created at h2 or h3 by default, MultiMarkdown (and Pandoc) have mechanisms for essentially shifting the value of hashes downward. You still have Scrivener generating one hash for the highest unit, but you tell MMD that the highest unit is actually 2.

To fix it:

  1. Go into File ▸ Compile....
  2. In the Metadata tab on the right hand side, note the table of metadata keys (you’ll probably see “Author” and “Title” already here at the least). Click the + button below this to add a new one.
  3. Call it “Base Header Level”[2], and supply it with a value of “2” (which for LaTeX will mean \chapter level is highest.)

So that’s how to fix it, if you intend to always work this way, you may want to consider making this metadata adjustment to the compile format instead of the project settings. In fact, if you examine the Article (Memoir) stock example, you’ll find I’ve already boosted the base header level to “2”, since that setup doesn’t even use parts.

[1] For the sake of completion though, refer to §24.2.4, Title Options, in the user manual PDF, scrolling down to pg. 621, where the Number of hashes option is addressed. With this, you actually could fabricate a manually controlled type/layout hierarchy like an RTF-based Scrivener user would. But it would generally be a waste of time to do that since we get this for free. This is better used for odd cases where your draft outline structure doesn’t match “reality”; it could also be used to adopt a much more detailed outlining style than there is necessary structure to express on output.
[2] Here is the MMD documentation on the setting.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

rd
rdevriese
Posts: 2
Joined: Sat Nov 28, 2020 2:14 am
Platform: Windows

Tue Dec 01, 2020 6:10 pm Post

Hello Amber. Thanks so much for your very detailed explanation which resolves most of my confusion. The current document I am creating relied on using folder names as headings. Am I correct that to use the solution you have provided I should add the headings directly to the content area using the # to mark the hierarchy and mostly use section layouts without heading?

User avatar
AmberV
Posts: 24515
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Ourense, Galiza
Contact:

Wed Dec 02, 2020 2:10 pm Post

Adjusting the base header level is a MultiMarkdown setting, to reiterate. It changes how MMD interprets the quantity of hashes per heading, which is how you skip having parts by making 1 = 2. This trick can work on a plain .md file that you execute multimarkdown.exe against in shell, it really has nothing to do with Scrivener or how you use it to generate (or not) headings.

So the only part where Scrivener comes into the picture is where you plug in the metadata so that it is printed into the .md file correctly. It might not be a bad idea to compile with the plain MultiMarkdown setting to an .md file, set that aside, then follow the steps above and compile to another .md file. Open both of them up and examine the difference.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles