Index style, keep it consistent

Edits/Updates are below original post.

I have a 200-page document with an alphabetical index. When I upgraded to version 6.1.5.2 (x64) my index started showing some of the entries in italics (or worse, part of the entry is in italics). It looks awful.

In my research, I found a close match here, Text format in alphabetical index. That answer is to redo the whole index without selecting text so as to make a “spot” position rather than a range.

This is a huge index and it’s not like all instances of each word is included (some aren’t as they aren’t relevant), it would take me days of doing nothing else! Is there another way other than going back to the old version?

Here are some screenshots to clarify what I am talking about.

What it looks like:

What I want it to look like:

EDIT 1

There are reasons to believe that this is something confined to my file. So I began looking into a way to analyze the file itself and found that to be surprisingly easy because if you dig deep enough, the file is simple XML. Here is what I found.

The index’s raw XML looks like this:

<text:index-body>
<text:index-title text:style-name="Sect4" text:name="Alphabetical Index1_Head">
<text:p text:style-name="Index_20_Heading">Alphabetical Listing</text:p></text:index-title>
<text:p text:style-name="P655">Ag&apos;rune<text:tab/>114, 115</text:p>
<text:p text:style-name="P655">Ahjifrohme<text:tab/>141</text:p>
<text:p text:style-name="P655">Ahlabim<text:tab/>18, 72, 79, 120</text:p>
.
.
.
<text:p text:style-name="P655">Yuretgolen<text:tab/>134</text:p>
<text:p text:style-name="P655">Zaphkah<text:tab/>136</text:p>
<text:p text:style-name="P655">Zenchu<text:tab/>141</text:p>
</text:index-body>
</text:alphabetical-index>

Some of the entries are not consistent and they are the ones that show up in italics. Shown below, the middle of the three index entries (Blood Moon) will be in italics.

<text:p text:style-name="P655">Blind-eyes<text:tab/>22</text:p>
<text:p text:style-name="P655"><text:span text:style-name="T125">Blood Moon</text:span><text:tab/>79</text:p>
<text:p text:style-name="P655">Blue Swords<text:tab/>12, 78</text:p>

So that, at least, defines why I am seeing the issue in this file. I guess I could hack the file and edit the XML directly but that could have foreseen effects. I’ll keep tinkering with it.

EDIT 2

Digging into the XML more, I have found the location of index entries in the doc’s text.

Sticking with the “Blood Moon” example, that XML looks like this:

<text:p text:style-name="Standard">
    While there are dozens of other companies, some stand out for one reason or another. <text:s/>Their time may be short or long. <text:s/>Their commanders may be brilliant or fools. <text:s/>Their hearts may be strong or black. <text:s/>They all have a story. <text:s/>They will all spill blood for gold. <text:s/>
</text:p>
<text:p text:style-name="P178"/>
<text:p text:style-name="P322">
    <text:alphabetical-index-mark-start text:id="IMark1571996490840"/><text:span text:style-name="T121">Blood Moon</text:span><text:alphabetical-index-mark-end text:id="IMark1571996490840"/>The <text:alphabetical-index-mark-start text:id="IMark1571996489496"/>Blood Moon<text:alphabetical-index-mark-end text:id="IMark1571996489496"/> is the name of the mercenary group and the name of the ship they crew, a wind runner. <text:s/>This mercenary group has letters of marque and reprisal from several coastal nobles. <text:s/>Their standing mission is combating piracy in the <text:alphabetical-index-mark-start text:id="IMark1571996493528"/><text:span text:style-name="T247">I</text:span>nner <text:span text:style-name="T247">S</text:span>ea<text:alphabetical-index-mark-end text:id="IMark1571996493528"/> but they do side jobs from time to time. <text:s/>One of those more recent and noteworthy tasks was taking out a group of sahuagin accosting some fishing villages. The Moon&apos;s captain, <text:alphabetical-index-mark-start text:id="IMark1571996489976"/>Rachel Dewitt<text:alphabetical-index-mark-end text:id="IMark1571996489976"/>, is a woman with seawater for blood. <text:s/>She has been sailing for over twenty years and commanding <text:alphabetical-index-mark-start text:id="IMark1571996493624"/>Blood Moon<text:alphabetical-index-mark-end text:id="IMark1571996493624"/> for the last four. <text:s/>Aboard this ship is fifty crew. 
</text:p>
<text:p text:style-name="P178"/>

This shows three index entries and none of them use the T125 style. Even more puzzling, the only index entry for “Rachel Dewitt” is here and looks normal yet in the index it is partly italics

<text:p text:style-name="P655"><text:span text:style-name="T125">Rachel Dew</text:span>itt<text:tab/>79</text:p>

Again, style T125 is added but only to part of the entry!

Digging out what T125 is defined as shows this:

<style:style style:name="T125" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic"/></style:style>

I have confirmed that removing the ref to T121 from the first “Blood Moon” entry clears all the issues with T125 appearing in the index entries for “Blood Moon” and “Rachel Dewitt”. Why that happens is unknown to me.

Edit 3

I have finally managed to reproduce the effect in another, much smaller, file!!!

Attaching as requested.

I tried to reproduce but I can’t. My test case is different: LO 6.0.7.3, fresh new files with indexed terms heavily loaded with character styles and direct formatting. Index looks as expected. Maybe it’s specific to the upgrade.

To make sure, can you attach a one-page sample exhibiting the misbehaviour? I’ll have a look with my version.

@ajlittoz - I can’t make it do the same thing with a new doc. The original was created in 2011 and, over the years, has been maintained in various versions of LibreOffice and OpenOffice. I have no idea how to tell what is going on in it. I wish there was some file analyzer I could employ.

@ajlittoz It’s 4 pages but still really small.

I tried to Update index in your sample (using v.6.2.2.1); and that made everything look consistent, without different character formatting. Doesn’t that work for you?

I confirm that Update Index also works in older versions, at least down to the 4.x series.

I noticed that your document is heavily direct formatting. For example, you don’t use character styles but apply stylistic variations directly; many paragraphs also are modified without going through a named style. This may cause a huge burden while maintaining the document.

Also (but this is not relevant to the present issue), you still use the “double-space-after-full-stop” dating back from the mechanical typewriter era. With modern document processors, this sometimes causes “glitches” when text is justified.

@ajlittoz Yeah, it’s an OCD thing to double space at stop.

Your XML analysis shows character styles have been applied to some entries and the extent (between <span> and </span> elements) proves it was a manual voluntary action you have forgotten with the years. It is quite easy to fix.

  1. Display the style navigator with F11 or Format>Styles and click on the second icon from left (Character styles)
  2. Right click in index and Edit Index/Table
  3. Make sure Protected against manual changes is not checked. Uncheck it if needed. OK
  4. Select the whole index table (if this is not handy because your index is very long, extending on many pages, you can proceed page per page or any other quantum, even entry per entry)
  5. In the styles navigator, double-click on Default Style
  6. As a fail-safe measure, do also Format>Clear direct formatting or Ctrl+M
  7. Optionally, reprotect the index against manual changes

To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

Excellent suggestion and your ongoing efforts are appreciated! While that will fix the index, if it is rebuilt/updated then all the old junk is back. My indexes have been managed automatically for years, moving away from that is no good for me. Also, if I turn on protection from manual changes after I manually fix the styles it all reverts and the fixes are undone.

Does it mean some sort of script is processing the index after you added entries with Insert>… and Tools>Update all ? Only such processing can bring back the “formatting”. Since it seems to target specific entries, I suggest you review it to eventually update or remove part of it. If you have no such processing, describe exactly how you make/update the index.

@ajlittoz To my knowledge, no additional processing/scripts are being applied. I assume what is done is part of index creation/maintenance code inherent to LO. I agree that only some type of processing would reapply the removed styles. I am reviewing the specific entries affected and they don’t appear totally random. In a few cases, the entries appear in a paragraph with style set to “Default” but the first word is “Default” style with an extra bold and/or italic applied only to that word. That’s my best lead atm. As for how I make a make/update an index: Highlite the word(s), click menu Insert > Table of Contents and Index > Index Entry. That opens the Insert Index Entry dialog, click Insert. To update or rebuild an index I right-click it and select Update Index. That covers it.

To my knowledge, no character or direct formatting is captured while collecting index data. I can’t then explain why some of your entries are “highlighted”. Sometimes, I have the opposite requirement: copying the formatting from text to index but this is not possible.

Could you inquire which style T125 is? T125 is a usage name. The definition might link it to a named style, unless it is direct formatting. This could give a clue.

@ajlittoz
<style:style style:name=“T125” style:family=“text”><style:text-properties fo:font-style=“italic” style:font-style-asian=“italic” style:font-style-complex=“italic”/></style:style>