"keep with next paragraph" is failing

I’m trying to keep a numbered paragraph with the next paragraph but it’s breaking across a page boundary.

I’ve checked this post and the issues diagnosed there don’t seem to apply to me.

Bottom of page 2 here shows the issue. I’ve checked Body Text and all styles superior to the relevant style.

Any suggestions gladly received.

Foundation_CIO_model_redacted.odt (13.5 KB)

I think the behaviour is caused by an excess of Keep with next paragraph. All your styles except Body Text have this attribute enabled. Your sample contains only paragraphs with the attribute, save for the first line which is Body Text.

The net effect is to create a huge connected block all over the document. The first empty Body Text paragraph is outside this block and appears alone on its page. A page break results from the lock of the block which is flushed to page 2.

Writer will output as much of this block as possible on page 2 and split at bottom of page. The rest of the block appears on page 3, though you’d like the “(2)” paragraph to be kept with subsequent ones because you, the author, grant a higher significance to it. However this significance is not hinted at in your styling: all styles dderived from Legislation have Keep with next paragraph, making them indistinguishable.

My suggestion is to disable Keep with next paragraph in Legislation level 2+ which seems to be the detail level, though you are applying it to several levels. It is likely that you’ll meet again the issue in some contexts.

Managing automatically such “monster lists” is next to impossible. You must decide where page breaks are acceptable. Eventually, if the event is “exceptional”, you can manually add Keep with next paragraph or insert a page break (my preference because it does not involve tweaking inconsistently styling and there is a visual clue for it) to fix aesthetic “accidents”, noting somewhere you direct formatted this “accident”.

Direct formatting is the cause of formatting hell when it is used routinely, but exceptional usage in well-defined circumstances is acceptable (but you must remain aware you did it).

2 Likes

Note @eteb3 that after disabling Keep with next paragraph in Legislation level 2+ you will need to re-enable it in Legislation Level + emphasis as it inherits from its parent.

1 Like

There appears to me to be a bug in this feature. I understand perfectly your explanation. I’ve faced it many times. The problem I’m facing–and which I expect the original poster was dealing with–is that if you change one paragraph to keep with the next paragraph, it changes all of the paragraphs to that, even if you don’t update the style of the original paragraph. This feature has become pretty much unusable for me, which is unfortunate since it is the preferred method for controlling page breaks without using forced page breaks.

Using Fedora 45 on both an older desktop and a recent Lenovo laptop. LO version 26.8.3.1

If you want one paragraph to have different attributes to others, then you should create a new style for that paragraph.
.

Generally, reserve Keep with next paragraph for headings and captions. Don’t use it on the main body paragraphs like Body Text

You can use Widow and Orphan control, now renamed to manage paragraphs, if that is insufficient, then use a manual page break Ctrl+Enter.

If you have chapters then you can specify a page break before the chapter heading

So what you’re saying is that this is now a “feature” and not a “bug.” Very unfortunate in my opinion.

You should read the chapter on Styles in the Writer Guide, download from LibreOffice Bookshelf.
.

There is a difference between working with styles and direct formatting as encouraged by Word. If you don’t want to work using styles but would rather burden yourself down with the difficulty of managing direct formatting then you can do that. Instead of altering the style, click in the paragraph then click Format > Paragraph > Text Flow and tick the box Keep with next paragraph. That setting will apply only to that paragraph unless you enter a paragraph return after it and carry on typing because it will contain the direct formatting of the previous paragraph. You can avoid that by entering the paragraph return and immediately pressing Ctrl+M to remove direct formatting.

Yes, I’m quite familiar with working with styles and I do that all the time. But sometimes direct formatting for a given paragraph is useful. But here’s the rub and why I’m talking about a bug: changing the “keep with the next paragraph” in a given paragraph–even without updating the style afterwards–is causing the other paragraphs to change to “keep with next paragraph.” That doesn’t happen if I use direct formatting to change the font attributes, indents and spacing or anything else, just “keep with the next paragraph.” I haven’t analysed yet if there are exceptions; I just know it keeps happening to me and fouling up my formatting until I finally give up and insert a hard break.

And just to avoid second guessing, I’ve used Word maybe 3 times in my life. I’ve been an OpenOffice/ LibreOffice user for decades.

It worked for my test, the red paragraph is direct formatted
KeepWithNextParagraphDF_138726.odt (36.0 KB)

Well, all I can say is I’m glad it works for you. Doesn’t for me and I’ve been using this formatting feature for many years.

Just one more thought. I went back and checked a document I’ve been working on today. I changed the first paragraph to “Keep with the next paragraph” and it immediately changed the other 2 paragraphs to the same thing. I then removed that feature from your document, added it back in to the first paragraph, and the problem did not occur. I have no explanation for this, but it happens to me on two very different computers, though both are running Fedora 45, Gnome 51.1.