Custom cross-reference format in LibreOffice Writer?


I would like to insert a cross-reference with full context, but I would like it to look like “chapter 1, section 2, subsection 3” instead of “1.2.3”.

Of course I would also like for it to retain the format when I move the cross-referenced item.

How to do it?

Quick answer: unfortunately, there is no way to isolate the numbering parts so that you can “decorate them”.

However I found a very dirty trick to get “chapter x section y” (without the commas) in cross-reference. But this dramatically impacts the heading numbering which becomes:

Chapter 1 Heading for chapter one
  Section 1 First section
    lorem ipsum
  Section 2 Second section
    lorem ipsum
Chapter 2 Heading for chapter two
  See Chapter 1 Section 2 for details

Tools>Chapter Numbering is customised with various Separator Before and Show sublevels is set to 1 otherwise it does not work. Note also you can’t change case of the separator when it is inserted as a cross-reference. The separator itself becomes present in the heading and the TOC too.

When you insert a cross-reference to a heading, use Number (full context) in Insert reference to instead of the usual Chapter.

It may be possible to improve on that (removing the separators from headings and TOC) by assigning a double numbering to your headings: the traditional Tools>Numbering to keep maximum versatility on displayed numbering and to keep TOC auto construction, plus a second hidden “decorated” numbering as above for use with cross-references. This would be implemented with a dedicated list style. I have not explored this path but, beware, it will be extremely tricky to avoid losing sync with chapter numbering. It is also tricky because any paragraph can have only oone number assigned to it. Therefore, it is likely that you’ll need some dummy hidden paragraph after any Heading n.

Thanks, looks complicated, but I’ll give it a try.