Conditional text fields in sub-documents managed by the master document?

Hi all,

I’m about to embark on a series of specification documents, each of which will contain a selection from a set of modules of content. So I plan to set up a master document per spec that includes the sub-documents as needed.

So far no problem. However, what I’d like to know is if I can include conditional text in each sub-document, where the field variable is set in each master document. For example, can I have a product name field variable in the sub-document that renders to an actual name in each master document, by defining the variable content there?

More complex still, could I write conditionalised paragraphs - one for each spec - in a sub-document, and the master document then shows the correct one depending on the active field? Something like this:

Installation guide
{{install=win}{On Windows, you do this…}
{{install=mac}{On MacOS, you do this…}
{{install=linux}{On Linux, you do this…}

And then for a Linux document, I specify install=Linux in the master document?

Has anyone done this on scale successfully? I imagine it would get messy with a lot of fields, but I’d rather not update 10 separate documents when they’re 80% identical.

Thanks in advance for any ideas and encouragement :wink:

This can be done but requires some care to get it right.

Unless I’m wrong, control variables can only contain numeric values (at least, I never succeeded in storing string values). Consequently, you must establish a convention to designate your variant, e.g. win=0, mac=1, linux=2, …

At the very beginning of your master document, create and initialise your variables with Insert>Field>More Fields, Variables tab, Set variable Type. I recommend you put a single variable initialisation per paragraph for ease of maintenance. Add some explanatory text about the variable role and values, again for your own documentation.

Create a custom paragraph style for these initialisations with attribute “hidden”. Configure Tools>Options, LibreOffice Writer>View` to display Hidden text (it will be decorated on screen with dotted underline instead of being hidden which will allow you to change variable values easily; hidden text doesn’t print anyway).

Don’t duplicate the initialisations in the subdocuments. Having them in the master makes them visible in all subdocs.

I also recommend you enable View>Formatting Marks. Whether you also enabled View>Field Hidden Paragraphs depends on whether you want to have an immediate feedback on the effect or need to edit the to-be-hidden paragraphs.

When you have a conditional paragraph, at its beginning Insert>Field>More Fields, Functions tab, Hidden Paragraph Type where you use a Condition like v==0 to hide the paragraph when the condition is true.

This means to display the paragraph only when the variable has a specific value your condition must be negated as v!=0. Beware! this is the common pitfall.

PS: A last advice

When you’re embarking for such a job, it is highly preferable to format everything with styles. Strictly forbid any direct formatting like Ctrl+B to embolden words. If you’re familiar with M$ Word, this app only offers paragraph styles. Writer is richer with character, page, frame and list styles which allow to get rid of all direct formatting. Direct formatting is always the source of nightmare formatting.

2 Likes

Thanks very much for this!! I agree that hidden documentation of the fields will make my life much easier.

I am now fully embarked on defining a template for all documents in the series, including list definitions. But this seems to be problematic. There is a complete set of predefined list styles, but they have no bullets or numbering, so I tried to edit them. But when I do this, the indentation is reverted to 0. But this will be a new question…

I’ll follow up here if I discover anything regarding master documents and conditions. Thanks again.

1 Like

By default the List n or Numbering n are not associated with bullets or numbering. You must do it explicitly. Rules for indenting are completely different when a paragraph style is configured for bullet/numbering. It is effectively better to cover the topic in another question.

It’s strange because I can see in the dialogues for each level that the indents are defined, but they are not applied once I’ve added a bullet. This makes no sense. But I found the 7.2 Writer Guide so I’ll do a bit of RTFM before formulating a question.

(As a tech writer, I’ve launched a few “RTFM, please” admonishments myself, so I can’t be guilty of that crime myself, can I…)

Formatting lists requires two styles: one paragraph style like List n or Numbering n* and one list style like Bullet ⋅ or Numbering 123. The styles are linked by selecting the list style in Outline & List (formerly Outline & Numbering) tab of the paragraph style. This is not done in the “factory” configuration., probably because the appearance of the number/bullet is a personal choice.

This is the worst design of anything I have seen in years. Perhaps if the documentation had a diagram showing how all the indents and spacing adds up, it would be slightly easier to understand what is going on. There’s no excuse for this - why not a basic default design that works out of the box, and then the user can adjust as needed? I mean, a bulleted style without bullets, and a numbering style without numbers?

New question coming up…

This is exactly how Writer is configured out-of-the-box: the List n paragraph styles are intended for bullet lists and Numbering n for numbered lists. They are provided without specific bullet/number so that users can choose the one they want.
When you link a paragraph style to a list style (IMHO, this name is ill-chosen because these styles describe the bullet/number properties, not a list by itself), left indent is no longer controlled by the Indents & Spacing tab in the paragraph style but by the Position tab in the list tab.
From disastrous personal experience, you better not mix paragraph and list indents: this ends up in an unmanageable, not correctable mess! Even right indent (which is supposed to have nothing to do with list indent) cannot be altered from the 0 value!

They are provided without specific bullet/number so that users can choose the one they want.

They could be provided with a standard bullet/number system (eg 1,2,3;a,b,c;i,ii,iii) indented as standard and then choose a different one if they want. I would have been happy to change the bullet symbols but keep all default indents - this would take me ten minutes. All software has defaults that you can change if you need to.

I have a funny feeling I’m at the “unmanageable mess” stage already. I have no idea if I’ve mixed paragraph indents and list indents. I did get it to work for the first three bullet levels, for list [bullet], continued, start and end, but I had to fight with each one manually, constantly opening the style definition for one list style that does work to try to copy it.

What makes no sense to me is the whole ‘outline’ concept. I set each level of list to the logical outline (1 for top-level, 2 for second-level, etc.) but whenever I edit the list style, I have all ten outline levels in front of me!

I am completely blocked on numbering lists now, simply cannot get them to do what is standard 99.99% of the time - restart the numbering at a new list. Thus is born another question :slight_smile: