Long and Short Binder Titles option and LaTeX Savequotes from the Quotchap package

I’ve noticed a few Wish List postings here lately, and it reminded me of two LaTeX utilities that I learned of and thought may be useful for future Scrivener users and community at large.

  1. First is the ability to designate long and short Chapter and Section titles, presumably within the Binder itself. For LaTeX, a description of the utility of having long and short versions of each Chapter and Section title is outlined on the web at My section title is too wide for the page header. In LaTeX, there are slightly different \chapter and \section commands, with each allowing for a total of three (3) (‘verbose’, ‘middling’ [optional] and ‘terse’) versions for each \chapter and \section title.The above web page outlines a brief description of where and when each title version is utilized. I found it interesting that LaTeX can allow for different titles in the page header for odd versus even numbered pages (I hope I’ve read that right!). I attempted to incorporate the LaTeX style of multiple titles in my Scrivener+LaTeX project, but gave up after 2 days, so here I am adding it to the Wish List. The following is a clip of one of my page headers with a title that is too long to fit comfortably on the top of the page:

along with the corresponding entry as it appears in the Table of Contents:

By allowing multiple versions for each title in Scrivener’s Binder, I’d have more control over what appears at the top of each page, what appears in the Table of Contents, what appears in the page header for odd versus even numbered pages, etc. .

  1. Second, is the ability to use the savequote function, available in The (LaTeX) The quotchap package, “for adding quotations in the upper left corner of the … chapter head pages” as shown in the following “Dry run …” clip from one of my chapter head pages:

that was created using the following LaTeX code:

\begin{savequote}[80mm]
“Dry run …\\ A dry run is a testing process\\where the effects of a possible failure\\are intentionally mitigated.”\footnotemark
\qauthor{\VerseCite{enwiki:1020392510}}
\end{savequote}

The catch here is that for the “Dry run …” quotation to appear as it does in the “upper left corner of the … chapter head page” for Chapter 4, I had to include the \begin{savequote}[80mm] ... \end{savequote} code at the very end of the \section immediately preceding Chapter 4 - “Dry Run”, e.g. at the very end of Chapter 3. (This violates the Scrivener principle of being able to easily move entire chapters and/or sections anywhere within the Binder, independently and separate from of all other chapters and/or sections.) The reason for this is that LaTeX requires the \begin{savequote}[80mm] ... \end{savequote} code to immediately precede the initial \chapter{ } command, in this case \chapter{Dry Run}. I could use the Title Options field in Section Layouts to include the \begin{savequote}[80mm] ... \end{savequote} code prior to execution of each \chapter{ } command, but then I’d have the identical quotation at the beginning of each and every Chapter. What I need is to be able to specify a unique quotation (NOT an Epigraph!) for each Chapter where I’d like to have one appear. At the moment, I don’t see how that can be done in this latest Scrivener version.

If I missed something that would enable me to accomplish what I’ve outlined in 1) and 2) above, I’m all ears.

Thanks for reading,
scrive
:thinking:

You can use <$title> for one and a custom metadata field for the other. You could use a formatted section type for the quotes you want in upper left, too. No need for LaTeX for either of them.

Hi drmajorbob,

Thanks for the tips.

Are there any examples of how to use a custom metadata field for, say, the ‘terse’ title version for each \chapter and \section title?

I am currently using the following LaTeX command in the Section Prefix of the Section Layouts to position the Binder title in the top-center of each page:

\fancyhead[C]{<$title>}

I can easily create a tersetitle metadata field to use instead of \fancyhead[C]{<$title>}, e.g. \fancyhead[C]{<$custom:tersetitle>}.

The vast majority of my Binder titles, however, are short enough that I won’t need to define a tersetitle for most of my 230 Binder titles. If I have, say, a half dozen Binder titles that are too long, that leaves 224 Binder titles for which I’d need to copy and paste the identical Binder title into the tersetitle metadata field. That’s a bit of overhead and maintenance I’d like to avoid, particularly if I want or need to change Binder titles that are already short enough to fit and don’t need a unique tersetitle. I could construct a LaTeX if/then statement to avoid having to enter the 224 Binder titles, but then I’m back to using LaTeX.

As for using a formatted section type in lieu of using the savequote function from the quotchap LaTeX package, I did a quick search in L&L Community Forum for formatted section type but did not see much in the way of an example that I could follow. The user manual had “No Results found” when I searched for formatted section type. There’s a lot more searching I can do to find a Scrivener substitute for the savequote function, but I thought I’d check with you first to see if you had any specifics.

Any thoughts?

Thanks again for your suggestion.
scrive
:thinking:

Here’s a video: using Scrivener metadata to compile a terse title

A quotation introducing a section is an epigraph, even if you invented the quote. Here’s a workflow showing epigraphs and synopses. It doesn’t format the way you did in your screenshot, but that’s a minor detail. Give your epigraphs a section type, assign a section layout to it, and format that layout to look the way you want it to.

a synopsis + epigraph compile

1 Like

On the second matter, have you experimented with the Prefix tab in the Section Layouts pane? That is where you can insert material above the heading line. The LaTeX template itself uses the Prefix field in a different way, to attach additional stuff after the title lines, but with some shuffling around you could change how that works. To take the stock “Chapter” layout as an example, it uses the Prefix to add a \label. So what you could do is remove the Title Prefix and Suffix, and move that into the prefix field as well, doing something like:

% Your pre-epigraph stuff here
\chapter{<$title>}
\label{scrivauto:<$linkID>}

Then you would just disable the Title checkbox for the Layout, since we’re already handling that in the prefix, and also disable Place prefix after title, in the Prefix tab.

1 Like

Um, which sounds like a good thing.

1 Like

I skipped over this part of your requirements earlier, but the solution from @AmberV fills the bill, I think.

1 Like

Hi drmajorbob, AmberV and gr,

Thank you everyone for ALL your tips and suggestions!!

There is a LOT here I’ll need to digest … likely enough to keep me out of trouble for at least a few days. Wow!

I’ve been working with Scrivener for over two years. After all of your tips, links, and suggestions, I feel as if I’m just getting started.

Many, many thanks!
scrive
:thinking:

Hi AmberV,

It Worked! … it worked! Thank you for your suggestion.

I may have been close, e.g.:

I could use the Title Options field in Section Layouts to include the \begin{savequote}[80mm] ... \end{savequote} code prior to execution of each \chapter{ } command, but then I’d have the identical quotation at the beginning of each and every Chapter.

but close was not close enough. Without your help, it may have taken me weeks, if not months to get this to work. I am grateful considering the time limitations I am operating under.

I was actually a bit surprised at how well this has worked on a number of levels:

  1. I can specify individual, unique ‘savequotes’ for each and every item in the Binder, and at the same time, I can
  2. Tailor the style of the ‘savequotes’ across each type of Binder item, e.g. Chapters, Sections, and Subsections, and lastly, I can
  3. Move Binder items wherever I want or need without having to think about modifying other Binder items in the process.

As such, I’d like to document this so that if anyone else tries to implement the same savequote function in The (LaTeX) quotchap package, they don’t have to spin their wheels as I did.

I’d like to link whatever sections in the Scrivener user manual where this may be addressed. I did not see a reference in the manual to how we did this, but if there is one, I’d like to reference the appropriate section in the user manual.

If not, I’ll just document what I think may be helpful to anyone else who might be looking to insert a pre-Chapter snippet of code as your suggestion allowed for.

Thank you again for your suggestion … now I need to return to how to implement the First item in my original posting … how to accommodate multiple Binder titles for those titles that are too long to use at various points in my Scrivener+LaTeX project.

Thanks again,
scrive (Yea!)
:thinking:

1 Like

As for the documentation, are you looking for §24.2, on Section Layouts? More specifically, §24.2.6 – 7 addresses the Prefix and Suffix tabs, where it has this to say:

With plain text formats, this can be useful for inserting markup around
entire sections. The prefix will be previewed in the layout’s tile, in the
compile overview screen.

A number of examples on how document data can be introduced into these tabs, via placeholders, are given in the following subsection from those.


As for the first problem, I think @drmajorbob has the right idea, of having different custom metadata fields for alternate title lengths. From the previous solution, you already have the ingredients for inserting these custom values into the section layout, with <$custom:FieldName>.

Some form of conditional logic on the LaTeX side, to handle when the field is empty, may be needed, and all of that can be inserted into the Prefix, or defined as a test in the preamble and called upon more simply in the prefix. That’s an implementation detail I’d have to do quite a bit of personal research on to give any practical examples of, though.

As far as Scrivener goes: you have the preamble sections in Front Matter to set up stuff, and section layouts with their various points of insertion to act upon that setup.

And it may be worth considering, if this is something that only happens once or twice throughout the entire book, that the overhead of creating an adaptive system based on metadata and conditional logic may be overkill. Sometimes the simplest solution is best in cases like this, where one has a special Section Layout they use and assign manually, to these special-case items. When to switch to a more automated approach would be a matter of decided at which point it becomes more overhead to manually assign Layouts in the inspector and reduce the flexibility of the document in doing so.

The balance between simplicity and complexity is what defines life and is key to how life progresses. Advances in life (and in software) are determined by the ability of whatever changes occur by not only the balance between the benefits and costs that the changes engender, but by the sustainability of the change both short and long term.

Of the many amazing Gifts that Scrivener bestowed onto the world for writers is the wonderful balance it achieved between the freedom to use the world of words to express thoughts, and the complexity of the software within the backdrop of where our society currently exists with the currency and utility that our global software lexicon and consciousness currently represents.

I cannot agree with you more that there needs to be a balance between the utility of every line of code and the complexity that the line brings to the object. With almost 18 thousand lines of code, I constantly need to consider the utility versus complexity of every new feature I may adopt into my project. My adoption of the ‘savequotes’ methodology (as one of a world of techniques to entice the reader to read on in what otherwise might be a dreadful subject to discuss) may not seem like much to others, but in the larger scheme is just an example of how the Scrivener software is expressing it’s unique balance between the utility and complexity to allow writers to express and communicate their message.

I have NOT spent the better part of two years learning and working with Scrivener+LaTeX and the larger Scrivener community believing that I would eventually run into roadblocks that would limit my ability to express the thoughts and messages I wanted to convey. The Gift that Scrivener brings is the ability to continue to grow with the software as the story that is my message continues to grow. That is the power that Scrivener brings to the table.

Thank you again for your support, as well as the support of the larger Scrivener community, as I continue to research and express my story, as is the story of the thousands of other writers that have adopted Scrivener to express their thoughts and ideas.

scrive
:thinking:

1 Like

I’ve been able to implement the First part of my Jan 9 posting to

designate long and short Chapter and Section titles

with the help of tips and suggestions from drmajorbob, AmberV and gr. The following are screen shots that show the Full Title as it appears in the Table of Contents:

followed by the corresponding Short Title at the top of the Subsection page (Global fossilized carbon emissions…) that appears just above the matching Full Title at the beginning of the Subsection (7.13.2) text (Global fossilized carbon emissions 1800–2014):

The Short Title is a Scrivener Custom Metadata variable that relies on a simple LaTeX If\Else\fi macro to ignore any Short Title metadata that is empty, thus avoiding the need to backfill all Short Titles that match the corresponding Full Titles.

Once I’ve caught up on my sleep, I will endeavor to document how I emulated both the LaTeX long and short Chapter and Section titles, as well as the savequote function in The (LaTeX) quotchap package in my Scrivener project as I mentioned earlier. (More accurately, perhaps, I should say that what I did was implement the above LaTeX functions within the Scrivener framework.)

I’d like to thank everyone for their assistance, tips and suggestion in my drive to implement the above features within Scrivener+LaTeX.

scrive
:thinking:

As a small point of style, I would suggest you drop the added ellipses in shortened running heads. I think it is the norm not to flag the shortening in any way and this certainly makes for a cleaner design. Adding ellipses is a bit antithetical anyway insofar as it lengthens the shortening!

1 Like

Hi gr,

Thanks for the tip.

I added the ellipses by hand, so deleting them eliminates a housekeeping chore.

Thanks again,
scrive
:thinking:

Here is the documentation I mentioned I would create for:

First - implementing the long and short Chapter and Section titles, and
Second - adding the ability to use the savequote function, available in The (LaTeX) quotchap package, “for adding quotations in the upper left corner of the … chapter head pages”.


First - I followed these steps to implement the long and short Chapter and Section titles:

  1. I added Short Title as a new metadata field on the Edit custom metadata screen with the following options: Type: Text, Alignment: Left, and Wrap text checked.

  1. I added the following LaTeX \selecttitle \newcommand code as a ‘Front Matter’ item to my Scrivener project:

\makeatletter
\newcommand{\selecttitle}[2]{%
\if\relax\detokenize{#1}\relax%
#2
\else%
\hspace{7mm}#1
\fi}
\makeatother

The \selecttitle command is used to select the Short Title if one exists, or select the normal, Long title if the Short Title does not exist.

  1. While highlighting the Chapter Section Layout on the Section Layouts screen, I commented out the \fancyhead[C]{<$title>} line of code (by inserting a %) and inserted the following new line of code, just below the above existing line of code: \fancyhead[C]{\selecttitle{<$custom:Short Title>}{<$title>}}
% \fancyhead[C]{<$title>}   <- Old code-commented out 
\fancyhead[C]{\selecttitle{<$custom:Short Title>}{<$title>}}  <- New code

in the Section Prefix field screen.

  1. I repeated step 3. above for the following 6 Section Layouts:
  • Part
  • Acronym Items
  • Chapter w/ Text
  • Section
  • Subsection
  • Subsubsection
  1. I then reviewed my Binder titles, and where the Binder title was too long to neatly fit in the page header, e.g.:

I entered a Short Title into the metadata field to substitute for the normal, Long title that would normally appear in the Table of Contents and the Section title.

In my project, there were half a dozen Binder titles that were too long to neatly fit within the page header. For those half dozen, I entered an abbreviated Short Title into the corresponding metadata field.

The Short Titles were then ready to fit and neatly print within the page header.


Second - I followed these steps to add the savequote function for adding quotations in the upper left corner of the … chapter head pages

  1. I added Chapter Quote on the Edit custom metadata screen with the following options: Type: Text, Alignment: Left, and Wrap text checked.

  1. I commented out the \chapter{ code (by inserting a %) in the Section Layouts - Title Options - Title Prefix field, e.g.:

  1. While highlighting the Chapter Section Layout on the Section Layouts screen, I inserted the following two lines of code, just above the following existing line of code: \label{scrivauto:<$linkID>}
{<$custom:Chapter Quote>}.   <- New code
\chapter{<$title>}           <- New code
\label{scrivauto:<$linkID>}  <- Existing code

in the Section Prefix field screen.

  1. As AmberV suggested: “Then you would just disable the Title checkbox for the Layout, since we’re already handling that in the prefix, and also disable Place prefix after title, in the Prefix tab.”

  2. Lastly, I entered the quote and cite shown below into the Chapter Quote metadata field, bracketing the top and bottom of the quote with the following LaTeX lines of code:

Top bracket - \begin{savequote}[103mm]
Bottom bracket - \end{savequote}

where 103mm was the desired printed width of the Chapter Quote.

Now compile, typeset, print and enjoy!
scrive
:thinking:

P.S. I’ve become a bit bleary eyed as I finished the above documentation, so let me know if there is something that is not quite right and I’ll have a look to see if I missed something. Cheers!

Didn’t you leave out how the TXT export turns into something else?

1 Like

Hi drmajorbob,

Thanks for your question.

Are you referring to how I use the TeXShop app to typeset the Scrivener output < projectfile >.txt text file into a PDF?

If so, the reason I’ve not mentioned anything about that final typesetting step is because nothing I have done to implement the Short Title, nor to implement the savequote Chapter Quote feature has affected the typesetting step in any way, except of course how the final PDF now shows the Short Titles and the Chapters now show the Chapter Quote. But otherwise, nothing in the typesetting step has changed.

If what you are asking for is a detailed explanation of how the compiled Scrivener < projectfile >.txt text file is actually typeset, even though that step has not changed, that is another story.

If there is a desire on the part of users here on this forum to have the typesetting step (as mentioned, I use the TeXShop app) explained in similar detail as to how I outlined the implementation of Short Titles and Chapter Quotes, I’d be willing to do so, but I will need to dedicate some time for the task.

If so, in and of itself, that is not a problem, except that I need to first spend some time to work on the subject matter that brought me to Scrivener+LaTeX in the first place, work that I have delayed for the last few weeks while chasing down the LaTeX features, et al. that I detailed above.

Let me know if this is what you are referring to. If you and others would benefit from a detailed explanation on the steps I use (there are many ways) to typeset LaTeX, let me know and I will endeavor to set aside time to do so.

Again, thanks for your question,
scrive
:thinking:

TexShop is all I needed to hear, I suppose.

I’ve personally seen no need to delve in to LaTeX.

1 Like