Binder Headings to LaTeX

User avatar
Venares
Posts: 57
Joined: Wed Dec 05, 2012 10:33 am
Platform: Mac + iOS
Location: NRW, Germany
Contact:

Fri Feb 08, 2019 10:50 am Post

Has there been basic changes between Scrivener 2 and 3 which do affect the Latex output? In Scrivener 2 the binder headings would be translated in Latex subsections - but the aren't in Scrivener 3 - any idea what I am missing?

User avatar
AmberV
Posts: 23255
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Santiago de Compostela, Galiza
Contact:

Fri Feb 08, 2019 1:29 pm Post

You could say so. Both MultiMarkdown and the compiler have been completely rewritten. The former to a close but slightly different specification (CommonMark), and the latter a fundamental redesign that goes all the way down to how you work in the binder.

You should go through the compiler migration tutorial if you have not. It’s from the perspective of using Scrivener to create formatted text rather than Markdown, but those details can be skipped over. The big changes are how sections of text are semantically tagged in the writing area, and how compile settings are now semantics-based instead of “this file is level 4 and has a text page icon, so it acts like a glossary entry”. Now it is simply flagged as a “Glossary Entry”, and your compile settings determine how that is formatted.

Given that understanding, take a look at the “Basic MultiMarkdown” compile Format and click the Assign Section Layouts... button below the preview column. There are three simple Layouts, one with a heading, one with just text and the third has both heading and text. If you need something else, double-click the Format to duplicate and edit it.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

User avatar
Venares
Posts: 57
Joined: Wed Dec 05, 2012 10:33 am
Platform: Mac + iOS
Location: NRW, Germany
Contact:

Fri Feb 08, 2019 2:18 pm Post

oh great :shock: , I'll get into reading now and come back later :D .

User avatar
Venares
Posts: 57
Joined: Wed Dec 05, 2012 10:33 am
Platform: Mac + iOS
Location: NRW, Germany
Contact:

Fri Feb 08, 2019 2:54 pm Post

Great :D it works, I just missed to assign layouts (somehow I thought I could ignore this for a while) - now it is working and your new conception of compile / layouts and structure-based vs Project-specific types looks promising to me! :idea: Thanks a lot!

User avatar
AmberV
Posts: 23255
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Santiago de Compostela, Galiza
Contact:

Fri Feb 08, 2019 3:08 pm Post

Great! Yeah by default stuff compiles “as-is”, which you can think of as the most basic way of using Scrivener. No settings, just type into the draft folder and then get a file stitched out of the stuff you typed. Presumably one would type in their own “## Headings ##” if they wanted to work that way.

But Layouts in general are great for this way of writing! If you want to see an advanced example of Scrivener+MMD+LaTeX, grab a copy of the user manual project as a .zip file.

You’ll see I have over a dozen Section Types, ranging from generic stuff like “Section” (which prints the title + text), to variants of that, such as “Chapter + ToC” for those longer chapters with their own table of contents, to very specific Types that I generally only apply by hand as needed, like “Interface Description”, that takes the text and title and formats it into a MultiMarkdown description block:

Code: Select all

Path ▸ To ▸ Menu Command... (KeyboardShortcut)
: Body of binder item.
:
: Paragraph two...


Thus my binder is actually an editable representation of a dictionary list, being used to format preference labels, menus, and so forth. In the writing interface it’s just another binder item with a title and some text though—and thus if I want to do something other than dictionary lists with “Interface Descriptions”, I can easily do so by changing how they compile.

Also look into Styles, which can be used to create your own “syntax”, with their prefix/suffix fields. I use a lot of that as well (in fact the above example is a combination of a Section Layout that designs the text layout, and a Style that is applied to each paragraph which has a prefix of “:”).

Hope you enjoy the update! I consider it to be one of the best platforms out there for constructing long complex works with technical markup.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

User avatar
Venares
Posts: 57
Joined: Wed Dec 05, 2012 10:33 am
Platform: Mac + iOS
Location: NRW, Germany
Contact:

Mon Feb 11, 2019 6:47 am Post

You’ll see I have over a dozen Section Types, ranging from generic stuff like “Section” (which prints the title + text),


Can you elaborate on this?

What I am still trying to figure out: Is there a way to use a binder item for the Latex command \title{} ? At the moment I have my custom MMD to Latex formate and there I edit the Latex-Options. But by doing this I have to edit the Latex-Options for every new project. Is there a more convenient way?

User avatar
AmberV
Posts: 23255
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Santiago de Compostela, Galiza
Contact:

Mon Feb 11, 2019 1:00 pm Post

Can you elaborate on this?


I might have been a bit brief on that; we’ve really got two different topics going on here in your response.

To start with the first: the Section Type itself in Scrivener is just a name. You can think of them as being a bit like styles for the outline itself—where in this case the style doesn’t change the formatting or visual appearance in any way, it just marks the content as being a thing, and no more. We don’t get around to saying what a Type acts like (as a component of the book) until we assign it a Layout in compile settings (what that middle preview pane is for).

Once you’re assigning Layouts, the effects of them should be pretty obvious. To use the “Basic MultiMarkdown” compile Format as an example, we have one called “Text Section with Heading”, that produces output like this:

Code: Select all

# Section Title #

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


This is a simplification as the quantity of hashmarks will be modified depending on the outline level in the Draft folder (there are advanced settings that can circumvent that assumption, but this the basic usage). So Scrivener would print an item, using this Layout, that is indented to level three in the Draft folder like this:

Code: Select all

### Section Title ###

Lorem ipsum dolor sit amet...


And the default conversion between a level three heading in MMD to LaTeX is:

Code: Select all

\section{Section Title}
\label{sectiontitle}

Lorem ipsum dolor sit amet{\ldots}


What I am still trying to figure out: Is there a way to use a binder item for the Latex command \title{} ?


To answer this question directly: no, that’s not how MultiMarkdown itself works, so it wouldn’t be appropriate for us to do anything different. A very simple MMD document looks something like the below. You would get similar yourself if you compiled to “MultiMarkdown” directly instead of having Scrivener automatically convert this result into a LaTeX file.

I highly recommend learning this from the foundations up, instead of trying to figure out how all of this goes from A to Z without ever looking at B thru X. It’ll just be easier if you can see exactly what Scrivener creates (the first example below), and then what MultiMarkdown does from that (second example). Without that knowledge you may be picking at a problem for hours, trying to “fix” it from Scrivener and not realising Scrivener never does anything at that level of production.

Code: Select all

Title: Cover Page Title
Author: Your Name

# The First Binder Item #

And the text of that item.

## An item nested below the first item ##

And so forth...


And MultiMarkdown turns this into:

Code: Select all

\def\mytitle{Cover Page Title}
\def\myauthor{Your Name}

\part{The First Binder Item }
\label{thefirstbinderitem}

And the text of that item.

\chapter{An item nested below the first item }
\label{anitemnestedbelowthefirstitem}

And so forth{\ldots}

\end{document}


Internally, \title is set to \mytitle in the stock preamble.

So when I say “text + title”, I mean the title of the binder item that produces these values; sorry for the confusion, I didn’t mean to conflate that with the document title. As noted above, the LaTeX structural break that gets used for that depends on the indent level of the item. This is shown in the above two examples by the part and chapter breaks.

The \title command, on the other hand, is used for the cover page—as a title for the whole work. With default settings and a workflow based on MultiMarkdown’s LaTeX template system (which Scrivener uses), this is all automatic. It uses the project’s Title, as set at the very top of the compile overview’s Metadata tab. Looking a little closer, you’ll see two default MMD metadata keys, “Title” and “Author”. If you check those you’ll see they are pulling data from Scrivener placeholders. Those, as you might expect, are set by the Title and Authors fields. You could of course type in something else into the MMD metadata area for “Title”, other than the placeholder, making the setting above it effectively useless.

To answer your initial question indirectly, yes you can establish the document Title from a binder item—but by using the appropriate MMD compliant mechanism, as explained above: metadata fields. The difference is that with the right setup you can type them into the editor rather than setting them up in the compile format pane. Refer to §21.6, MMD & Pandoc Metadata, in the user manual PDF, for full details on the different methods you can use to set up metadata.

For the most part the different methods are there to give you choices, but the different approaches do have their individual advantages, and all of them can be combined together in more complicated scenarios to best harness those advantages, or to establish clear roles between them (Format = layout-related metadata; Compile settings = document metadata that doesn’t change; “Metadata” file = compile-group specific metadata, or stuff that changes frequently).
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

User avatar
Venares
Posts: 57
Joined: Wed Dec 05, 2012 10:33 am
Platform: Mac + iOS
Location: NRW, Germany
Contact:

Mon Feb 11, 2019 2:27 pm Post

I highly recommend learning this from the foundations up, instead of trying to figure out how all of this goes from A to Z without ever looking at B thru X. It’ll just be easier if you can see exactly what Scrivener creates (the first example below), and then what MultiMarkdown does from that (second example). Without that knowledge you may be picking at a problem for hours, trying to “fix” it from Scrivener and not realising Scrivener never does anything at that level of production.


Yeah, I am guilty of this. I am trying to finish a paper until tomorrow and to fix my MMD to LaTex workflow to be apt for Scrivener 3 at the same time - no good idea of course. But with your given advice I am ready to compile the paper and to dive into the named chapters the day after tomorrow. Thanks a lot for your patience, complex informations and help!

User avatar
AmberV
Posts: 23255
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Santiago de Compostela, Galiza
Contact:

Mon Feb 11, 2019 3:10 pm Post

Yikes! Nothing like adding a little spice to one’s deadline. ;)
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles