Frequently asked questions - Writer

    From The Document Foundation Wiki
    < Faq‎ | Writer
    Note pin.svg

    Note:
    This tutorial assumes that you already know how to create a new paragraph style and how to modify existing styles.

    How to adapt the presentation of the text depending on the outline?

    You want the text to shift automatically following the outline level. Example of the expected output:


    copie d'écran texte aligné sur niveaux de titre avec retraits différents
    Adaptation of indents according to the outline level


    It is possible to have this effect automatically using Conditional Styles. This functionality allows a single style to take on the attributes of other styles depending on the context.

    For example, used in the header of a page, the Text Body style could take the attributes of the Header Style. We don’t recommend such “extreme” usage, because it can cause confusion. However, the feature is quite suitable for the automatic indentation we would like to use here.

    In this example, the text will use only one conditional style (the titles use Heading 1, Heading 2, and Heading 3 respectively). The text style applied is automatically adapted to the context: when the text is in “level 2,” a predefined layout in another style is applied. The same applies for level 3, etc.

    This is very handy, because you don’t have to bother with the layout when entering text. You choose the “conditional” style and, when you apply the titles (i.e. the Headings), the layout adapts by itself. We can achieve this in three steps.

    Step one: create two ordinary, indented paragraph styles

    To follow the above example, you need to create two styles which are “ordinary,” paragraph styles with only an indent defined before the text:

    • create two new ordinary, body text styles and call them Text Level 2 and Text Level 3 (chose any names that you like);
    • when you are creating Text Level 2, set its Before text Indent under Indents & Spacing tab to 0.5"; and
    • when you are creating Text Level 3, set its Before text indentation to 1.0".

    These two styles are not directly applied in the document.

    Step two: create one conditional paragraph style

    Now we create the conditional paragraph style that will be applied to the text following these steps:

    • in the Styles & Formatting panel (View ▸ Styles ▸ Styles & Formatting or press F11), right-click on the Text Body paragraph-style, then chose New;
    • under the Organizer tab, give a name to the style;
    • under the Condition tab, check Conditional Style;
    • in the Context list, select 2nd Outline Level, in the Paragraph Styles chose Text Level 2;
    • click on Apply and then OK; and
    • repeat the previous step for the third level with the style Text Level 3.


    copie d'écran dialogue création style, onglet Condition
    Creation of a conditional style

    Step three: modify the heading styles

    You can update the title styles "Heading 2" and "Heading 3" to assign them an indentation (0.5 and 1.0).


    Note pin.svg

    Note:

    • the Condition tab is only available during the style creation; and
    • when changing the level of a heading in the text (for example, you move the paragraph from Heading 1 to Heading 2, the context is not updated automatically and the conditional style is not automatically adapted. Two solutions:
      1. reapply the style by double clicking on the Style window; or
      2. if there are several paragraphs involved, use the Edit ▸ Search & Replace menu, click on More Options and check Search for styles, in the Search for and Replace with lists, select the conditional style name and click on Replace all.
    • Download an example document.