Writer, TOC & Character Highlighting

I’m trying to find a way to get table of contents to show not just text but also the character highlighting that is assigned to whatever heading… is there an option to enable this?

No, you cannot automatically show the character highlighting that is assigned to the heading. The TOC entries are text fields with their own separate paragraph style

If you have assigned highlighting colours to different levels of headings, e.g. Heading 1 has Yellow, Heading 2 has Lime Green, etc. then you can modify the Contents 1 paragraph style in the Highlighting tab to Yellow, then Contents 2 to Lime Green. This will be persistent.

If you have applied different colours to different headings on the same level then it can be done manually but only immediately before printing or exporting to pdf as it will revert to the defined paragraph styles on next update to index.

  1. Right click the index, select Edit Index and untick the box Protected against manual changes
  2. Select the text that you want and apply the relevant highlight colour. Repeat for other entries
1 Like

In addition to @EarnestAl’s answer:

You may have applied character styles or direct formatting to your headings. Unfortunately, the TOC collection engine captures only heading text excluding any “decoration”. Consequently, “intra-heading” stylistic formatting is lost when the TOC is built.

Thanks, I think that solution is about as good as I’m going to get.

I can edit Contents 3 for example to change its highlight color which does work, but unfortunately this stretches the whole width of the TOC which is really not the look I’m after.

To highlight part of the TOC entries, apply a character style to it.

When you create the TOC (or edit it with a right-click), go to the Entries tab of the dialog.

  • select the appropriate Level
  • click on the E descriptor for the entry text
  • choose an existing Character style from the menu
  • do the same for N# (the descriptor is E# in releases prior to 7.6 – BTW you didn’t mention your OS name and LO version) if you want to highlight the number too
  • preferably, for aesthetic reason, choose the same character style (unless you want to format separately number and text)

As mentioned, you can choose only an existing character style, so create one beforehand in case you don’t use a built-in one (personally I don’t see any ad hoc one for this usage). Button Edit allows you to modify the selected character style without leaving the TOC dialog.