Style hierarchy for examples, theorems, lemmas

Hi, what I’m trying to get in a book about school physics is writing a example style using the “style hierarchy” with its specific meaning, for writing something like this
EXAMPLE 1.1: Example Title
Question Text
SOLUTION: solution text
End of Example
I suggest something like this (but really i don’t know a convenient way)
style EXAMPLE inherit NONE
style EXAMPLE_TITLE inherit EXAMPLE
style EXAMPLE_QUESTION_TEXT inherit EXAMPLE
style EXAMPLE_SOLUTION_TEXT inherit EXAMPLE
Please suggest a hierarchy tree on doing that task.

Note first that styles are primarily metadata annotations about your text semantics.

A paragraph style tells Writer (or other parsing tools) that such paragraph is a heading, non-specific text (as opposed to explicitly tagged paragraphs), a header, a footnote, … You can freely add to the built-in styles by creating “Example” or “Theorem”.

A character style is used to depart from paragraph styling by giving a different “value” to a word like Emphasis, Strong Emphasis, “math symbol”, “variable”, “foreign word”, “irony”, “trademark”, …

A page style defines a “geometry” and hosts attributes like header and footer.

A frame style holds attributes, such as wrap properties, borders, …, and parameters for positioning the frame within the page (yes, even if the frame is anchored to paragraph or character).

A list style defines both a multi-level sequence number and the format/appearance of this number. It confers the list attribute to any paragraph to which it is attached.

Styles are the correct way to give structure to your text. You must beforehand think deeply about what you want to convey to your reader and define your semantic categories. Avoid the pitfall of being too detailed; find the correct balance between no (or nearly no) and excessive classification. Not counting the Heading n family (document outline), if you end up with more than ~15 paragraph styles, something is wrong in your view of the document.

Let’s get back to your case.

  • As already mentioned, Heading n will be use for the outline (chapter, sub-chapter, sub-sub-…).
  • Text Body is intended for the bulk discourse.

You have examples and theorems (lemmas are kind of ancillary theorems and don’t require a specific style; you’ll use the same styles as for theorems because there is no semantic difference between theorems and lemmas from authorship point of view). If you want to make a visual difference between them, you must design separate styles; otherwise you can use the same style family.

I assume there are good reason to make a distinction between examples and theorems (e.g. a different indent or some lateral border to clearly delimit example extent).

I’d derive Example Body from Text Body so that a change in font face is automatically forwarded. Example Body would have a left indent and perhaps a left border with an adequate spacing. Don’t ever “touch” any attribute you want to share with Text Body. Any action in Example Body will override the corresponding attribute. Even if you set it to the same value as in Text Body, the fact that you set it is an override. Revert to “transparent state” is not trivial and rather counter-intuitive for a newbie.

Depending on how you want to make the example stand out of surrounding text, you can derive Example Title either from Text Body, keeping the same font face as ordinary text, or from Heading (note the style name without number, it is the ancestor of all Heading n) to use the same font face as all the chapter divisions, making the example title like another minor chapter subdivision.

Remember that styling is a matter of personal taste. There is no absolute truth when aesthetics come into play. My suggestion sums up to:

Default Paragraph Style
   |
   +--- Heading ---+--- Heading 1
   |               +--- Heading 2
   |               +--- Example Title
   |
   +--- Text Body ---+--- Example
                     +--- Theorem

To create a derived style, right-click on a style name in the style side pane and New. The new style will be configured in “transparent state”, i.e. it is identical to the parent style. Change the attributes which must be different. They become “overrides”.

2 Likes

This answer is not acceptable in my situation because probably theorems, examples and lamas has a different style in one book.

As an experience user you are, you derive the “Example Title” object from “Heading” object. I feel there is an internal different in “Heading” from “Text Body” that i can not see (but both have the same parent). For example maybe headings have more attributes like “chapter counting” that paragraphs don’t. Please delight me.

I emphasized styling as semantic annotation. When you write your text, you usually compose it as some flowing, consistent, continuous text interspersed with intermediate “titles” to make explicit you are describing various topics or “ideas”. The “titles” are there to “guide” the reader into the book structure or outline. Therefore, the important metadata attribute is “heading/outline”.

This is why I derive all heading-like styles from Heading.

In the “standard” style hierarchy, some styles are there only as intermediate nodes in the tree and should not be used for any text. They exist mainly to provide common defaults for their children:

  • Default Paragraph Style: the common ancestor of all styles; never use it for any text; define here the common font face and size
  • Heading: common ancestor for all “outline” styles, Title (for book title in cover page), Subtitle (idem), Heading n family (for chapter, sub-chapter, …); usually sets a different font face (sans serif vs. serif)
  • Header and Footer: ancestor for the footer and header specialised styles
  • Index: ancestor for the TOC, index, tables (of figures, illustrations, …)
  • Text Body is an exception to the above rule, standard style for document text; also ancestor for all text-related styles
  • Table Contents is also an exception, used for cell contents in tables; ancestor for table-related styles


These styles are roots for sub-trees in the style hierarchy. By customising them, you change the appearance of all dependent styles. You can then change dramatically the appearance of your book in a matter of seconds without the need to go through the text and check what you did is right.

The key is a consistent and rigorous semantic marking of your text with judiciously chosen styles.

Note a very important point. I never mentioned bold, colour, indents, spacing, fonts, … in the styling procedure. You simply annotate your text to give it structure. When it comes to formatting, you customise the styles with your preferred fonts, weight, size, border, whatever, …

Due to the limited typographical variants, the same rendering may apply to different semantic styles. But, don’t merge the styles into a single one because you’d change the semantics. For example, italics are used for foreign words and also for emphasis. Emphasis and foreign origin are not the same but they display the same. This is usually not important because a reader can make the difference from context. Nevertheless, use two different character styles, built-in Emphasis and your user-created Foreign. In addition, you can configure Foreign so that you disable spell-checking for so-styled sequences.

Built-in styles are provided as a starting point. They are not reserved or “sacred”. Being offered “out-of-the-shelf”, they are some kind of tradeoff and certainly won’t fully satisfy anybody with targeted needs. Don’t hesitate to customise them. They are done for that.

To avoid conflicts, display the styles hierarchically when customising them. You do that by selecting Hierarchical from the drop-down menu at bottom of the style side pane.

2 Likes

In my point of view (for my text) I have to suggest a structure for “example” or “theorem” style like this:

Default Paragraph Style
   | 
   |
   +--- Text Body ---+--- Example
                              |
                              + --Title of Example
                              + --Body of Example
                                        |
                                        +--Body of equation
                                        +--Body of solution

              
                     

As previously mentioned, there is no absolute truth. Feel free to adopt the relationship which fits best your problem, workflow and habit.

The relationship is not important per se. It comes into play only when you tune your formatting once you have semantically tagged your text with styles. Ask yourself the right questions:

  • When I modify Example, do I expect the change to extend also to Title of Example, Body of Example and all styles below?
  • Where do I want the change cascade to stop?
  • Which are my “leading” styles? The ones which will give the distinctive look to my document (there should never be more than 5)
  • What are the distinct formatting “areas”? These will define the set of “leading” styles.

The answers are personal. Of course, have a look to existing books. Analyse their formatting, evaluate it and adapt to your case.

3 Likes