How to use heading numbers with dynamically hierarchical headings?

I’m trying to convert a document from text to a supposedly more versatile format, .odt. One of the problems with the previous document was that I couldn’t use markdown headers because I frequently used more than the maximum depth of headers (not least because I always use the web view rather than page view).

The most relevant answer was

Unfortunately, this doesn’t work for my documentation. That is because it solely applies to headings 1 to 10, which excludes Heading 0 (the master/default heading style).

Consequently, does anyone know of a solution that allows #Writer to dynamically number the stylistically hierarchically equivalent headings (H0s) based upon either a non-stylistic manual designation or, better yet, their indentation?

There is no such Heading 0. Heading (without any suffix) is the root of the Heading n styles. It breaks the dependence from Default Paragraph Style, usually defining a font shared by all headings (this font can alternatively be set by Tools>Options>LibreOffice Writer>Basic Fonts (Western), Heading category). Heading is an “internal technical” style which should not be used for any headings. It is not associated with any level.

I still don’t understand from what you start and where you want to go (your end result). From your screenshot, it looks you have a .txt file which you want to Writer-format. If this is the case, there are many things to look at.
The first of them is “paragraph re-creation”. This means you must remove every paragraph break at end of line which is not a “logical” and really significant paragraph break. You must also remove all empty paragraphs (= empty lines). A well behaved Writer document must not contain empty paragraph at all. If their purpose is vertical spacing, this is much better handled through Indents & Spacing in paragraph style configuration.
Once this is done, you style your paragraphs, removing tabs or space indentation (once again, left/right and first-line indent are better handled by paragraph style configuration).
And this should be enough. I don’t see any possible automation to the process.

I may be still out of your track. In this case, don’t hesitate to contact me by private mail (click on the icon beside my name to access Message service) so that we can discuss on more specific points, eventually sharing your initial document.

1 Like

@ajlittoz,

Could you elaborate why this shouldn’t be used? I am just interested. However, relevant to the question, I could have just said that I wanted to create a custom style with these properties. I simply chose the root Heading because its hierarchy isn’t static, like h1 to h10 are.

That’s exactly what I want. That’s because I want to be able to use more than 10 levels of indentation. I always use web view for my Writer documents because they’re designed solely for computer use. This means that I’m constrained to A4 aspect ratios (and thus horizontal space). In fact, the 16:9 aspect ratio most common nowadays for PC monitors is great for longitudinal indentation.

.md/.html, like .odt and .docx use a predefined amount of heading classes:

# Heading

body body body body body body body
body body body body body body body

## Heading

body body body body body body body
body body body body body body body

### Heading

body body body body body body body
body body body body body body body

whereas pure text allows for infinite categorization:

Heading:

    body body body body body body body
    body body body body body body body

    Heading:

        body body body body body body body
        body body body body body body body

        Heading:

            body body body body body body body
            body body body body body body body

I realize that this may demonstrate that .txt fits my immediate need in this regard, but I want to use .odt because it has an impressive feature set.

AL computer code, and documents with indexes like RFC 6350 - vCard Format Specification, demonstrate this well. I find indentation rather than heading text size to more easily demonstrate document hierarchy, and many agree. However, Writer appears unable to cater for this. Am I correct, and regardless, does a solution exist?


Thanks loads, but would you mind discussing it here? I’ve no problem sharing some documents that use this style publicly, so I’d like to have this discussion in the public record for others’ sake.


Yeah, I only used it to make which I was referring to more clear.

This may be the first issue. Writer is primarily intended to format and lay out printed documents (or equivalent, i.e. documents which are spread over limited-size “pages” with well-defined dimensions). An HTML “page” has no intrinsic dimensions. Contents is reflown whenever window geometry changes. In a sense, HTML is “dynamic” while ODF is “static” where some page style constrains text within a fixed geometry.

If you require the dynamic behaviour of HTML, Writer is not your best tool. Writer can output HTML with CSS but code quality is not optimal (you can get much more concise page descriptions with hand-coding or using dedicated applications). Nevertheless, nearly all Writer formatting facilities can be translated without the need to know HTML encoding.

Are you sure? An outline of more than 10 levels is very difficult to grasp intellectually. Perhaps your design is not yet mature enough. A good argumentation must be synthetic and convincing. My most “wild” documents have no more than 5-6 levels and, usually I limit my TOC to 4 levels.

The 10-limit, though arbitrary, seems to be generic in Writer. Headings and lists use the same underlying engine. This engine has been set to 10 levels.

There are two ways to handle your request:

  • compile LO yourself and increase the limit (most difficult and isolates you from mainstream evolution)
  • mix headings and lists: this will give you unlimited levels (through addition of custom list styles) by quanta of 10 levels but numbering cannot be merged between headings and list styles, each is limited to 10 levels in its turn; also TOC will never exceed 10 levels

Text level-indentation

If you want your text to be indented depending on level, this can be simulated (within the 10-limit) by associating your Text Body (the standard discourse paragraph style) with a dedicated list style with a space bullet. Thus you define the left indent per level in the list style configuration and set the paragraph level by typing n-1 Tab at start of paragraph. Demoting one level is done with Shift+Tab.

But if you want numbered lists within your indented block, this becomes a bit complicated because you must created as many list styles as used levels (because the indents will depend on the initial indent of the “block”). And if you change the surrounding level, you’ll have to change either the paragraph style (if there is a fixed association with a list style) or the list style (in direct formatting context).

Paragraph (and character) styles are organised hierarchically.

Default Paragraph Style is the primary style. It defines global (personal) defaults for the document. These defaults are inherited by all other styles.

Below it, there are several styles (Caption, Header & Footer), Heading, Index, Text Body, *note and others) which split the formatting realm into “families”. Forced attributes in these secondary styles override those in Default Paragraph Style to give a distinctive look to the “family”.

The hierarchy can continue below these styles to create more and more specific contexts.

Just the same as Default Paragraph Style should not be used to style text (because of its role of defining defaults shared by all other styles), some secondary styles should also not be used because they are not really indicative of a specific usage: Caption (those below it are attached to dedicated captions), Header & Footer (no distinction between header and footer but nice to set default for both), Heading (not attached to any heading level), Index (too generic, sets default for TOC and other “tables of …”).

The notable exceptions are Table Contents, but you’d probably create custom styles for various semantically different tables, and Text Body for indistinct discourse. But as soon as you consider your paragraph is not “indistinct” but has a special “value” (comment, annotation, citation, quotation, explanation, …), a dedicated paragraph style (inheriting from Text Body) should be created and assigned.

Apart from its formatting effect, a style is a meta-markup in your text providing information about author’s significance of this paragraph of word. Using a semantic approach to styling, you better control your document and you make possible tremendously powerful formatting and layout by clearly separating appearance from contents, spread over logical components (e.g. you have no italic text but ironical, foreign, important or secondary paragraph or words; you control each “theme” separately, even if they look the same according to your graphical charter).

1 Like