Writer’s paragraph spacing model

I wonder if someone could help shed light on the rationale behind the standard paragraph spacing model in Writer.

In MS Word, Apple’s Pages, and CSS, the margins of consecutive paragraphs collapse, i.e., they are not additive but only the larger of the two counts. For example, if Heading 1 has a “Spacing below” of 24 pt, then it doesn’t matter whether the following element’s “Spacing above” is 12 or 16 points because the value is ignored (since it’s ≤24). I find this model to be practical and intuitive.

In LibreOffice Writer, by contrast, the margins of consecutive paragraphs are additive by default. This complicates styling, as you’re basically forced to use only one of the “Spacing above” or “Spacing below” properties. For example, creating a style for a bulleted list requires at least four distinct styles: (1) the first item, (2) the middle items, (3) the last item, and (4) the sole item in a single-item list. With collapsing margins, all you would need is one style that can apply to all items.

In Writer’s Compatibility Options, there’s a setting labeled “Add spacing between paragraphs and tables”, which is enabled by default. Disabling this setting causes margins to collapse in LO as well.

Inside an ODT file saved by Writer, paragraph spacing is stored in margin-* properties (which are intended to collapse) instead of padding-* properties (which are additive). This is regardless of whether the mentioned setting is on or off.

So, the “Add spacing between paragraphs and tables” seems to be just a presentational quirks mode in Writer. It causes the document to be laid out differently than the markup in the file would suggest.

This is baffling to me. Why are additive margins the default, particularly since the presentation is not even reflected in the markup?

In the (very confusing) documentation for the various compatibility options, it says that the setting in question “specifies whether to add Microsoft Word-compatible spacing between paragraphs and tables in LibreOffice Writer text documents”. But when the setting is enabled, the document is precisely incompatible with Word; I get additive spacing in LO and collapsing spacing in Word.

A little Googling tells me that, historically, Word has indeed employed additive spacing, but that hasn’t been the case since Word 2000, where they switched to the HTML/CSS model.

Can it really be the case that LO ships with this inconvenient and incompatible box model enabled by default simply because MS Word used it in the 1990s? Or are there some styling situations that are so difficult to deal with using collapsing margins that the quirks mode is actually considered preferable?

Intuition is only an excuse for not trying to escape from one’s routine. Indeed Writer has its own paragraph box model which is neither Word’s nor CSS’s.

I consider collapsing spacing between paragraphs can’t be resolved with a simple on/off setting.One author may be satisfied with it, another one would like the taller while a third one the smaller. Then collapsing spacing would require a sophisticatd control to satisfy everybody.

That said, let’s examine the Writer paragraph model.

image

In this diagram, gUw is the useable width in the page (once margins have been removed). Since you’re interested by the vertical issue, let’s focus on this axis.

Spacing above pMt and below pMb are equivalent to top and bottom margins in HTML/CSS box model.

You also have border and shadow which are always present, even if their widths are zero. They act as a boundary, making anything inside independent from what happens outside. There is another no-print area inside the border: padding which is also always taken into account, even when there is no border. Hatched area contains paragraph text.

In paragraph style configuration, you find two check boxes to collapse elements:

  • in Indents & Spacing tab: you can completely remove spacing between two paragraphs of the same style
  • in Borders tab: you can merge the border with next (same) paragraph which causes vertical padding to be removed as well.

You can play with both settings to achieve various effects. It is not perfect but you really have a very powerful tool in your hands. But don’t call it intuitive or unintuitive; it just follows another box model.

If you disagree with this box model, please describe another one and argument about its advantages and inconveniences against a collection of use-cases.

Wrong! Switch to another mental model. I base all my layout on both above and below and base my effective spacing on the sum of preceding below + following above. It may look at first complicated but in the end you have some added versatility compared to spacing on a single side only.

For lists, I agree you need 4 styles, unfortunately. However, collapsing margins won’t fit everybody’s needs if you still want some spacing around middle items (unless perhaps you use the [border] padding trick to add uncollapsible spacing).

I can’t shed light on the rationale behind Writer box model because I am neither a developer nor a contributor to ODF, but once I understood the model, I am quite satisfied with it (except the spacing collapse is unusable because it is too simplistic). Apart from some pending bugs, I can achieve the layout I desire.

2 Likes

Thanks for the advice, but with 15+ years of OOo & LO experience, I already know how to work with the default spacing behaviour. That wasn’t my question.

I apologize for using the word “intuitive”. Let’s not get hung up on that.

Indeed Writer has its own paragraph box model which is neither Word’s nor CSS’s.

What makes you say that? Looking at the ODF specification, it seems to me that it uses the CSS box model. The ODF spec refers to the XSL spec, which in turns refers to the CSS spec. It’s just that Writer renders the margins in a non-standard way by default due to the compatibility option I mentioned.

I consider collapsing spacing between paragraphs can’t be resolved with a simple on/off setting.

I don’t understand. There is a simple on/off setting. The one I described, in Settings > Writer > Compatibility.

I’m puzzled as to

  • why it’s on by default since the additive margins mode doesn’t match the ODF spec (if I understand it correctly) and is arguably inferior to the collapsing margin mode
  • why it’s presented as a compatibility option, when it actually results in incompatibility with everything else.

For lists, I agree you need 4 styles, unfortunately. However, collapsing margins won’t fit everybody’s needs if you still want some spacing around middle items

Collapsing margins do not preclude spacing around the middle items. That’s precisely what they make easy. Let’s say I want 4 mm para spacing and 2 mm list item spacing. With the CSS model, I can set 4 mm spacing (above & below) for my paragraph style and 2 mm (above & below) for my list item style and be done with it. List items will end up 2 mm apart, and the list as a whole will be separated by 4 mm from adjoining paragraphs.

Sorry for not being precise. Presently, in Writer, it is all on or all off, i.e. either you have what paragraph style offers, or no spacing at all (not the CSS minimum). And, yes, this is unacceptable.

For your puzzling questions, I have no idea. First thing I do is to remove the compatibility mode because I prefer to have spacing between identical paragraphs.

Indeed, ODF uses CSS box model. Not collapsing is likely either hystorical thing, or because it is rather complex in CSS. @Regina might tell.