Unwanted cell background repeating every other row

I want a table with two heading rows – one with merged cells for the title and one for column heads.

I want the heading rows to repeat if the table flows into the next page.

The problem comes if I try to create a Table Style from the table by going to Table>AutoFormat Styles. I click Add and give the new style a Name. I click OK.

The style created adds a colored background to every other row. This wasn’t in the original table and I don’t want it. Is there any way to prevent this addition?

If I click OK, even my original table is formatted with the additional colored rows.

This is in LibreOffice 7.2 Writer on a Windows 11 machine.
Formatted Table to create style.odt (11.4 KB)

AutoFormat Table Styles

English documentation

I appreciate the links Hrbrgr. However, nowhere in the LibreOffice Writer Guide nor in the link to AutoFormat Table Styles do I find an answer to my question of why AutoFormat adds the extra colored rows and how to prevent this.

So, if everything works correctly, the auto-format style can only render what you have previously defined and assigned to the new style.

If you want someone to examine it, you can upload a sample file here. You should then specify which area you have marked to use for the auto-format style.

To upload, please edit your input question. There you will also find the icon for uploading.

Thoerethically it could also be that there is a malfunction in your system.

Unfortunately, your statements so far are not sufficient to give an informed answer. Thank you.

Don’t use table styles. You can’t really create custom styles.

At minimum, they’re buggy. Most of the time, they play nasty tricks on your back because they’re implemented as macros adding direct formatting on your rows/columns/cells. Direct formatting overrides paragraph and character styles. Consequently your carefully styled formatting gets hidden by the macros.

You must be aware that any change in table structure (not in cell contents) causes the macros to be triggered again and they will completely reformat the table. The fact that background is repainted shows that your table is based on some built-in “style”, not yours. This built-in style was probably selected when you thought you created a new “style”.

The best solution I use is to have at some convenient location in your document an empty template with the exact structure and formatting. Copy this template table and paste it where you need it.

When your document is complete and ready to publish, delete the template table.

The reason for trying to create a Table Style is to prevent needing to style each of multiple tables individually. I have done this with other tables, but they only had one heading row. The problem seems to be when there are two heading rows.
The idea of copying and pasting may solve the problem for a single document, however.

I share your concern about the need to clone a table structure in a user-friendly manner. Unfortunately, table “styles” are presently not usable.

  • they don’t record cell merges
    This is obvious on your example where the first row is a single merged cell. This probably results from the fact that the “style” doesn’t keep the dimensions of the model: you can still change the number of columns when inserting a table based on a “style”. This dynamic aspect is incompatible with merged cells (as the requested number of columns may differ). The variable number of rows is less critical but you can have the same “situation” vertically with the same consequence.
  • they don’t follow your background pattern
    I think this is a consequence of the macro implementation. I feel (I’m no developer) that table “styles” are in fact a set of “simple” macros with rudimentary firing criteria. One of these is background painting. It looks as if only alternating background colours are possible as soon as some background is detected.
    I complicated your model by adding column background and inserted a table with a different number of columns. I got an unmanageable mess with alternating column background overlaid by row background. And how the macros chose to group background colours is a mystery.
  • the macros always fire to replace your intentional formatting by theirs.

For me, the only viable solution is to copy an existing table.


PS: I noticed your example table was not configured for repeating the heading rows (Text Flow tab in table properties). You probably forgot it when preparing the sample. Anyway, it doesn’t change the problem.

Copying the table somehow is best, this is another way to do that. If you will use the table layout across more than one document or in a long document add your table to AutoText.

  • Format your table as you want it but empty of data.
    • Use Table Properties to set number of rows to repeat on new page and whether you want rows to split
    • Consider using style Table Heading for the table headings, you could make a derived style if you want two different types of heading
    • Are any columns to be formatted as number?
    • Will the heading names always be the same? If so you could include them
  • Select the table complete and click Tools > AutoText (Ctrl+F3), a dialogue box will open
  • Give your table a name, e.g. My Table 1 , in the shortcut field it will suggest a shortened version like MT1
  • Select My AutoText as a location unless you use a different scheme
  • Click the button AutoText and click New. You can Close the dialogue box now.

Where you want a new table just type mt1 and press F3

If you don’t need it any more, just click Tools > AutoText to open the dialogue box, select your entry, My Table 1 and press the Delete key. Confirm the deletion.

1 Like

Thank you EarnestAI for the well thought out and explained reply. While it would be nice to have the table listed when going to Table>Insert Table… along with a sample image, the method you present gets the job done.