Managing chapter/section LaTeX Title features from within Scrivener

After close to three years working with Scrivener+LaTeX, I’ve become more familiar with the software and my focus is gradually shifting toward formatting. The Scrivener+LaTeX combination of software has proved exceedingly flexible, and has greatly facilitated my limited writing skills.

My current interest is to implement two LaTeX features as to:

1) How titles appear in the Table Of Contents (TOC) and

2) How titles are displayed in the TOC versus how they appear in the Body of the document.

For those less familiar with the Scrivener → LaTeX workflow, there are a few work-flow terms I use:

pre-Scrivener-complied code → Scrivener compiler → post-Scrivener-complied code ( = pre-LaTeX-complied code )

with the next step being:

pre-LaTeX-complied code → LaTeX compiler → post-LaTeX-complied code

1) On page 863 of the Mac Scrivener User Manual, regarding Unnumbered Chapters and Unnumbered Sections, it states:

I experimented with two separate approaches to implement Unnumbered Chapters and Unnumbered Sections.

First, in Scrivener I manually added an asterisk (*) inside the pre-Scrivener-compiled Chapter and a Section Titles. My goal was to see if Scrivener magically would add an asterisk to the \chapter{ and \section{ commands in the post-Scrivener-complied code (e.g. change the LaTeX commands to \chapter*{ and \section*{ respectively in the pre-LaTeX-compiled code).

In the resulting post-Scrivener-compiled output, Scrivener did not add an asterisk to either of the \chapter{ or \section{ commands in the post-Scrivener-compiled (pre-LaTeX-compiled) code! (No surprise there…) (See Footnote below)

Just to check, I then manually added an asterisk inside the \chapter{ and \section{ commands in the post-Scrivener-compiled (pre-LaTeX-compiled) code. In each case, I wanted to see if the resulting post-LaTeX-complied titles were UNnumbered, as they should be. Scrivener did in fact create an UNnumbered Chapter and Section, thus confirming the LaTeX option to generate UNnumbered Chapters and UNnumbered Sections by inserting the asterisk (*) inside the \chapter{ and \section{ commands.

Second, after poking around a bit, I also checked to see if there was a Scrivener option to assign an Unnumbered Chapter and an Unnumbered Section to a Chapter and Section from within Scrivener.

In the Scrivener Project Format screen, I noticed there were options for both Unnumbered Chapter and Unnumbered Section Layouts:

However, the same options did not exist in the ProjectProject Settings...Section Types screen:

So, I manually added both an Unnumbered Chapter and an Unnumbered Section to the Section Types hoping that would allow me to create an Unnumbered Chapter and an Unnumbered Section:

I proceeded to assign the Unnumbered Chapter and Unnumbered Section Section Types to a Scrivener Chapter and a Section respectively. I then compiled the Scrivener project and checked the post-Scrivener-compiled output to see if it had added an asterisk toward the end of either the \chapter{ or \section{ commands in the post-Scrivener-compiled (pre-LaTeX-complied) code! Scrivener did not.

So I am back at square one with regards to implementing the LaTeX Unnumbered Chapter and Unnumbered Section from within Scrivener. ;-(

2) As outlined in a message posted on SE: LaTeX - Different section names in TOC from body, there exists a LaTeX option to specify separate titles for the TOC versus the Body of the document for the same Chapter and Section by adjusting each LaTeX command code as follows:


As a test, I entered the above code changes for a Chapter title and a Section title from within Scrivener to see if the post-Scrivener-compiled code would result in separate titles for the TOC verses the body of the document (I was doubtful). The Scrivener compiler did not make the hoped-for adjustment to the code.

Note: I of course could have manually made the above changes to the post-Scrivener-compiled (pre-LaTeX-complied) code that is generated after I compile my Scrivener project file. I am, however, throughly averse to doing so as it would represent a significant change to the workflow that sustains Scrivener as the original, and only, source document. I could also have implemented a Scrivener Replacement scheme whereby I include a unique code within Scrivener to indicate the presence of [<Title-in-the-ToC-for-the-Chapter>] {<Title-in-the-Body-for-the-same-Chapter>} coding in order to have Scrivener then create separate TOC versus Body titles, but my failing memory would likely forget what I did, resulting in mass confusion and delirium on my part as a result. Not a good option.

Instead, I’m listing these two items here for possible consideration as a possible feature for Scrivener+LaTeX users like myself to have the added degree of flexibility when working with Scrivener+LaTeX to:

  1. Access the Unnumbered Chapter and Unnumbered Section features within LaTeX, and

  2. Access the separate [<Title-in-the-ToC>] versus {<Title-in-the-Body} features within LaTeX.

Thanks for reading,

Footnote: In a posting on L&L on Aug '12 by AmberV, they mention that:

While there, you might notice that Fletcher has coded in what appears to be, preliminary support for an automatic switch to \chapter*{etc}. If the chapter name “Ends With an Asterisk*”, then it triggers the part of the rule that uses \chapter* instead of \chapter.

I realize that the above statement was made in conjunction with the MultiMarkdown-Support-Mac package from GitHub, (which I am not inclined to incorporate into my existing project). However, as it has been over a decade since AmberV’s post, I thought perhaps the feature to recognize an asterisk toward the end of a Scrivener Chapter and/or Section Title might have been incorporated into the most current version of Scrivener. It apparently has not.

Turns out that Scrivener has already handsomely handled all that I was looking for in my last posting, shown above.

The memory slows after almost seven decades … I had already laid the groundwork to answer my own question about two years ago … but forgot all about it!

The key was to edit the Section Types that I had originally created, outlined in my posting above, to reflect the expansion of LaTeX features I was looking for, e.g. to enable the LaTeX code:

  1. To create separate TOC versus Body titles for the document chapter, I merely needed to make the following adjustments to the Scrivener code for a new TOC/Body Title Chapter Section Layout located in the Section prefix: \chapter[<$custom:TOC Title>]{<$title>}.

The full code in the Section Prefix for the TOC/Body Title Chapter Section Layout now looks like:

and to enable the LaTeX code for the:

2-a) Unnumbered Chapter and Unnumbered Section features within LaTeX, I only needed to adjust the \chapter and \section commands in the respective Section prefix by adding the necessary asterisk (*) to the end of each command, e.g. changing the \chapter command to \chapter* and the \section command to \section*.

The full code in the Section Prefix for the Unnumbered Chapter Section Layout now looks like:

2-b) For the Unnumbered Section the \section command, now \section*, is instead located under Formatting which now looks like:

For completeness, you may have noticed that I needed to add a new Custom Metadata field, called TOC Title, to complete the creation of the TOC/Body Title Chapter Section Layout mentioned in 1. above, as displayed in the Section prefix as: \chapter[<$custom:TOC Title>]{<$title>}.

Apologies to those who took the trouble to read through my earlier post, only to provide my own response a few hours later as my memory recovered.

I am constantly amazed at how flexible and comprehensive Scrivener has proven to be.


1 Like

After sleeping on my memory gaff, I’ve wondered how it might be possible to more easily reveal a bit more of the wonderful flexibility Scrivener affords …

Perhaps in some future rendition of Scrivener, I wonder if it might it may be possible to have an even larger, expanded search capability than the one that already exists … to include ALL user-definable fields.

The user-defined fields that come to mind include those available in the Project Settings... screen:

and the Edit Format... screens:

I realize that this may be a heavy lift depending on the software used to code Scrivener, and of limited utility for most users. There is also the question of what to include as a user-defined field.

Those of us with projects spread out over multiple years (and across other dimensions), such an expanded search could further help to reveal the splendid flexibility that Scrivener already provides.

Thanks for reading,