Writer orphan/widow control for sections of code

Hello,

I’m writing a technical document in Writer, which has pre-formatted sections of text in it. Most of these are a couple of lines of either assembly or C programming code. For these sections I have created a separate style which sets a mono-spaced font as well as tabs to make the formatting of the code look correct.

The only issue I’m having is that each line of code ends in a newline, which then acts as an end of the section. A 10 line code section is interpreted by Writer as 10 one-line sections, which means that the orphan/widow control does not kick in.

What can I do to make the code sections adhere to the orphan/widow control settings for the style I’m using?

Orphan/widow control is effective on a paragraph basis. In your case, your code lines are in fact one-line paragraphs, thus causing widow/orphan control to become irrelevant.

What you need is make your code snippets to be a single paragraph. You can do this by typing Shift+Enter (newline) instead of Enter (end of paragraph) at each line end except the last.

If you paste your code snippets, you must do it manually unless you have installed AltSearch extension.

To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

Thank you - this solved my problem. Much appreciated!