How can I keep italicized words in headings from changing to regular text in table-of-contents?

I have headings that contain certain words that are italicized (scientific names). This works fine in the section headings, but in the table of contents, the entire entry is in regular text (without italics). If I change the TOC contents style to italics, then the entire entry is in italics.

Is there a way to keep the same words italicized in the TOC as in the section headings?

Unfortunately not.

The TOC engine collects only raw text from the heading paragraph. All formatting, be it character style or direct formatting, note anchor, index entry, …) is wiped off before synthesis of the new paragraphs forming the TOC.

I also need this and found no automatic way of doing it.

For the TOC (it still fails with fields), recent versions of LibO can do that automatically… sort of. If you are not seeing the italics, manually update the TOC with right click → update index. Weird thing is: this only works if the italics was applied as direct formatting! If you used a character style to apply the italics, it will be ignored. See also:

Bug 87604 - Table of Contents should retain direct formatting (and character style)

Reading this and similar reports, my impression is that a better solution for this problem will never be implemented… :frowning:

@RGB-es: we strongly advocate use of styles and condemn direct formatting. In the present solution (workaround?) as I read it from the bug report, only some (not all) direct formatting is transferred to the TOC. This goes against the “official” philosophy. One of the comments alluded/suggested a list of checkboxes so that user could select which attributes to transfer. But I feel this is very complicated because it could in the end be available on a level basis (per Heading n instead of global settings).

The only attribute which should not be transferred is font size change IMHO. In my case, I need to change fontface for technical words so that they stand out from surrounding terms. No way and I don’t want to manual edit my TOC.

@ajlittoz Indeed! I hate direct formatting, it’s too dangerous! The impossibility to properly transfer valid formatting to the TOC or fields is a real problem and completely cuts out Writer as an option for many technical documents. At least we always have (Xe)LaTeX for that, oh well.