Does KEEP WITH NEXT work with Section prefix/suffix? (part 1)

With the goal of saving space, I am not starting new chapters on new pages but instead separating them with spaces. The first sample below shows how it’s supposed to look when the new chapter shows up at the top of the page, and the second sample shows how it’s supposed to look mid-page.
So far, so good.

I created the spaces before the Chapter Title in the compiler Section Layout with two paragraph returns in the Title Options>Prefix box.

Invariably, there are places where the Chapter Title falls at the beginning of a page, without its blank line padding, which stays on the previous page. See Sample 3.

How do I make the padding in front of the Chapter Title stay with it? I’ve tried turning on Keep With Next in the Section Layout, but it doesn’t work.


I’ll answer both parts of this topic here.

This is an interesting challenge - one that I think Scrivener is nearly up to, but not quite. With a couple of modifications on my end, I think we should be able to get this working, though. There are a few of limitations you are running into:

  1. Keep with next will not work well with empty paragraphs, and cannot work well with empty paragraphs. This is part of the problem you are running into with the spacing above your sections. However, this can easily be worked around - you simply enter a single space character into the empty paragraph so that it is no longer empty, and KWN will work fine with it.

  2. You can’t assign KWN to separators. Therefore, to get the spaces above your sections working with KWN, you should set the separators to single returns, and then add a return and space characters as the Section Prefix. You can then set the size of this empty line using line spacing, setting it to “Exact” (e.g. 60pts). This point we run into our second issue: you cannot assign Keep with Next in the Section Layout Prefix or Suffix text areas. This is an oversight that has been fixed for the next update.

(1) and (2) address your spacing issue.

  1. Keep with Next is a complex layout process and currently only supports two successive paragraphs of KWN. It checks a paragraph to see if it should be kept with the next and, if so, checks to see if the next paragraph fits on the page. If not, it moves the current paragraph down. It also checks to see if the next paragraph should be kept-with-next if it fits on the page, and if moves both paragraphs down if the next paragraph has KWN applied too and the third paragraph in the sequence won’t fit. But there the checks end.

In your case, you have the following setup:

  1. Blank space - needs KWN to stay with chapter title.
  2. Title - needs KWN to stay with sequence separator.
  3. Sequence separator - needs KWN to stay with scene.

So, you have three successive KWN paragraphs, breaking the current hard limit of two.

I have made some modifications to the code so that it should now check up to a hard limit of five successive KWN paragraphs.

Could you possibly email me your project (zipped up) so that I can test these changes and also the best approach?

Many thanks,

Wouldn’t all of this be easier if, instead of using empty lines (or lines with invisible space characters), you created a style in the compile settings for chapter titles, setting the paragraph spacing before and/or after it to something large-ish? Then you really only have one line (the chapter title) to keep with the first paragraph of the chapter…

Edit: I fiddled with this myself, and found the following:
First, you don’t need a style if you don’t want to create one; just format the title font in compile, setting paragraph spacing to be something like 50 points before.
Second, there seems to be a bug in the Section Layouts->New Pages setting that suppresses this “before” paragraph spacing if the “Pad top of page with:” is set to zero. Set it to 1, and the 50 points before each chapter title will then show up in the compiled output when titles end up being the first text on a new page.

Second edit: It appears that the bug workaround only fixes the issue for the first chapter if it has no text before it. If the second chapter in my testing scenario would fall at the very end of a page, the next page starts with it at the very top of that next page, rather than having it display a lot of vertical space.

I’m beginning to think this isn’t so much a bug as something that’s expected, so that paragraph spacing doesn’t create gaps at the beginnings of new pages… Looks like Keith’s solution is the best one after all… Please excuse my interruption… :unamused:

Keith might have a different response than mine, but my experience with other page layout programs, like PageMaker and InDesign, tells me that the space-before feature doesn’t work at the top of a new page. Think about it, if you use a 14 point space-before to separate a subhead from the previous section, and in the course of the layout this subhead lands at the top of a page, you wouldn’t want that blank line at the top margin.

In my case, I do, for the chapter titles.

I’ve just sent a sample to your email address.

Strange, I can’t find it in our support queue. Could you please send it again? Thanks.

Okay, sent it again. I used this address:

Something about my zip file is blocking uploading. I’m sending another that should work.


Hi David,

I’m afraid I’m still not seeing it in our support queue (I’ve checked the spam too). One thing you could try: if you have Dropbox, put the file in there, and then Ctrl-click on the file and create a public link. You can then email us the link instead of the file itself. That should definitely come through. The email address you are using is correct.

All the best,

Okay, I just sent you an email with the Dropbox links.