# "Keep with next paragraph" in two different section

Option "keep with next paragraph" doesn't work beteween paragraphs of two different sections, I mean the place, where is the boundary between both sections. Idk, maybe this is actually the correct thing, but I have a specific sections, whose content should stay together when going to the next page, and it must be two different sections. Both have always only one paragraph each. I guess there is no solution to it but I'm asking anyway.

edit retag close merge delete

Do you use the word "section" to mean a Writer section or in the common sense of "part of a chapter"?

Give the properties of your "sections" (number of coluimns, …) and the reason why you chose sections.

( 2020-07-29 19:09:27 +0200 )edit

I mean Writer section, sorry. I made a quick example in this document: 2sections.odt - two section without any additional changes and columns (I only used colors). Only the page is divided into three columns. As we can see at the end of column, the two paragraphs of these two sections are splited, despite using the option "keep with next par." The reason is possibility to showing and hiding these sections - the second one exactly, which forms "one piece" with the first.

( 2020-07-29 20:06:03 +0200 )edit

I don't see why you should need sections. If your sole reason is the background colour, create and use a specific paragraph style with the required Area attributes (or use direct formatting as is presently the case, but this is not the right way of using Writer). Then Keep with next paragraph will be effective because both paragraphs will be in the same text flow.

( 2020-07-29 20:17:18 +0200 )edit

But then I won't be able to unhide or hide this second section (I do this via macro btw) - it is the matter. Colors are only to distinguish the sections - they doesn't matter. I guess there are some way to make a macro, that updates the paragraph style and changes "hidden" option in font effects, but then I would have to do too many styles - different for every second section (there are more in my doc.) and to be honest, these "second sections" will contain more paragraphs with many different styles, that I will constantly use in many future edits. That's why, I wanted make this one text flow in two sections. "The first sections" will be always exposed and together with exposed "second sections", form one neat part - unfortunately at the end of pages/columns they don't. Ok, it probably cannot be done.

( 2020-07-29 22:29:31 +0200 )edit

Then you have a much "simpler" solution: hidden paragraph field. It is prefixed to "conditional" paragraphs (which keep their "natural" style with their own attributes) and controlled by a variable. Depending on the variable value, paragraph is shown or hidden. The simplest case is a single variable for all, but if your paragraphs resort to different semantic features, you can have one variable per topic to control the features individually.

If this corresponds to your use case, tell me and I'll give the recipe.

( 2020-07-30 07:52:05 +0200 )edit

Ok,it sounds interesting. If you can, please show me how to do that :)

( 2020-07-30 12:10:04 +0200 )edit

Sort by » oldest newest most voted

# How to use "hidden paragraph" feature

## First create a control variable

with Insert>Field>More Fields, Variables tab. Select Set Variable and enter a Name and a Value. Create as many variables as you have independent features to control.

This field is entered where the cursor is presently located. I therefore recommend that you write a set of paragraphs at start of your document like this:

<variable name>: <set variable field showing the value> - This variable controls xxx clauses and must be set to 0 or 1.


Give these paragraphs Hidden attribute so that they don't contribute to document result. Enable View>Formatting Marks and Tools>Options, LibreOffice Writer>View Hidden text (and perhaps Hidden paragraphs, see below).

Hidden text will display with dotted underline but does not print (consequently, it is not useful to give Invisible attribute to your "set variable* field). With such a setting, your variable definition paragraphs remain visible on screen and you don't lose your time trying to find them to enable/disable a feature.

## Next, tag your controlled paragraphs

At start of every controlled paragraph, Insert>Filed>more fields, Functions tab; select Hidden Paragraph and in Condition enter <variable name> != 1.

Take care that when the condition is "true", the paragraph is made hidden. This is somewhat contrary to the usual expectation where control variables set to 0 mean hidden text and visible otherwise. This is why I used != operator in the example.

Available operators are ==, !=, >, >=, < and <=. With < and the like, you can have "progressive concealing" where a higher number means more information disclosed. In this case, every paragraph uses a level in its condition, telling how public (lower numbers) it content is.

If Hidden paragraphs in not checked in the options, the screen faithfully displays what will be printed. If it is checked, the paragraph is always visible on screen (but not on print), unfortunately without any visual clue about its conditional state. Only a gray patch at the start of the paragraph tells there is a field there.

## How to change user configuration

Once everything is in place, double-click on the gray set-variable field in your special initial paragraph to pop-up a dialog where you can change the variable value.

Enjoy!

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!

In case you need clarification, edit your question (not an answer which is reserved for solutions) or comment the relevant answer.

more