Change spacing between paragraphs depending on style

Hi! Is it possible to change the “Space before” and “Space after” depending on what style will come after the paragraph? Thanks in advance

1 Like

Having the ability to change spacing between paragraphs depending on the preceding style seems like it would be useful, in particular when starting a 2nd paragraph of the same style after the 1st. It seems that in Writer there is already an acknowledgement that such functionality would be useful, as there is an option to “not add space between paragraphs of the same style”.

Is there a reason why this more nuanced functionality couldn’t or shouldn’t be implemented?

For me, the requirement to vary spacing between same style paragraphs suggests that the paragraphs have not equal value (significance). Therefore, they should have different styles (in my approach to styling, styles describe author’s significance; formatting and layout come later as a consequence of this significance). then it is easy to assign appropriate geometric configuration.

My reaction to your question is: have you abstracted enough the structure of your document? Have you thought deeply and thoroughly about your argumentation development? What kind of message is conveyed by the paragraphs?

After this “introspection”, you should end up with 3-4 categories, leading to 3-4 paragraph styles.


There is one case where my scheme does not hold: lists.
Commonly, a list instance is isolated from from the rest by increased spacing before and after the list. All list items are "equivalent", i.e. formatted by the same style. This could be handled by this single style with inter-spacing suppression. If your design does not reuire spacing between items, you're done.
But, if you want some spacing between items, you must create 3 styles: one for the first item with increased above spacing, one for running item with "standard" spacing, one for the last item with increased below spacing. Unfortunately, this results in added burden when you edit the list (you must pay special attention to the consistency of style sequence).
3 Likes

Perhaps the solution is to have several styles that inherit from a common one, where only the spacing is changed.

1 Like

This is commonly done when styles are grouped into “families” (cf. built Heading n inheriting from Heading). Unfortunately, there is a bug when paragraph styles are associated with a list style. In this case, inheritance no longer “fully” works (see tdf#68263). But this does not change my previous comment where I didn’t detail the procedure of style management.

Thanks, if I understand you correctly, this is the work around I’m using.

Thanks for the insight ajlittoz. Just for the sake of clarity, here’s an illustration showing the effect I want to achieve:

paragraph style A (significance A)
space below paragraph = 1.0 cm

paragraph style B (significance B)
space below paragraph = 0.5 cm

paragraph style B (significance B)
space below paragraph = 0.5 cm

paragraph style B (significance B)
space below paragraph = 1.0 cm

paragraph style X (significance X, where X stands for any other style than B)

I want the space of certain paragraphs to be different in relation to others of the same style (or same significance, as you might put it) and how I want them to be in relation to paragraphs of another style (or significance). Though it seems there is no functionality to adjust spacing between paragraphs depending on the adjacent style, I know I can work around this.

One way to do this is to create 2 versions of a style (or significance). Following my example, I might make 2 versions of style B, with different parameters for “space below paragraph”. Let’s call these 2 versions B1 and B2.

B1: space after paragraph = 0.5 cm
B2: space after paragraph = 1.0 cm

For the 3 consecutive style B paragraphs in my example, I could assign the 1st and 2nd B style paragraphs as B1, and the 3rd (and last) B style paragraph as B2. That would achieve the effect I want. This process might become quite labour intensive though, depending on the complexity of the document, and definitely prone to errors if any shuffling of paragraphs or adjustment of styles occurs while editing.

And so I still wonder if there is a reason (other than the perhaps considerable effort it would take) why, “more nuanced functionality couldn’t or shouldn’t be implemented” in how styles work in relation to each other?

The flaw in your approach is to consider only spacing below paragraph.

Paragraph box model has four settings, one for every “edge”:

  • horizontally Before and After text (in reading direction), i.e. left and right respectively for LTR text (commonly Western languages)
  • vertically Above and Below

Your purpose can be achieved by smart settings of Above spacing in your B and X styles because inter-paragraph distance is the sum of Below (first style) and Above (second style).

Personally, I am ready to accept small “distortions” in my graphical charter, i.e. not the exact distance I planned, against style proliferation. Otherwise it becomes difficult to maintain the collection, even with inheritance. Statistically, I end up with ~15 paragraph styles (not counting built-in families Heading n and Contents n which provide already 20 styles, but giving 2 “functions”), ~10 character styles, max. 5 frame styles, max 3 page styles per “part” in the document and 3 list styles.

If you’re curious, I can send you a description of my styles for technical documents.

As it is, you can’t. It is up to you to design appropriate values for these spacings.

The vertical spacing between two paragraphs is the sum of space_after_previous_style + space_before_next_style. Consequently, if you play smart with combinations, you may get something closer to your expectation.

In some limited way, you can tick Do not add space between paragraphs of the same style but this suppresses any vertical spacing between two identically styled paragraphs.

When designing a style set, remember that styles do not describe typographical aspects but rather establish a semantic markup as to the significance you, as an author, give to text. Therefore you have a one-to-one mapping between significance and style. If your styles are cleanly discriminant, there should be no (semantic) ambiguity of style sequence in your text. The “smart” configuration Ialluded to above can then “easily” be achieved.