Maintaining a table with alternating row backgrounds and direct formatting

In the attached document (contents cleaned), I created a table using a custom alternating pattern style, which I called AGR or Alt Just Pattern (I cannot currently remember the difference, if any). In many cells, there is a combination of bolded and unbolded text. However, when I add or delete a row, I lose all of the formatting, exactly as described here: Table formatting disappears when adding a new row in Writer

In response to the advice there, I recreated the table using the “none” style. I can now add and delete rows without losing the formatting. However, I cannot figure out how to add an alternating background to the cells of that new table styled with “none.” Is there a solution to this problem that does not involve maintaining the table in the none style and then, when complete, pasting it into a custom styled table that alternates row backgrounds, and never adding or deleting rows to that custom styled table? (If not, this seems like a massive bug, albeit one related to the broken tables style function more generally.) Thank you.

libreoffice test table - cleaned.odt (56.7 KB)

1 Like

There is no real solution. I explain in the referenced question why you lose your formatting as soon as you create your table with so called “table styles” (which aren’t styles in the usual meaning of the term in Writer).

So either you accept a built-in table “style” and you can’t apply custom format to it or you stick with None “style”.

I see however some form of workaround. Add two empty rows to your table (one with your background, the other one without background). Make these two rows an AutoText.

Later, when you want to add new rows at end of your table, invoke the AutoText to get your new rows with your chosen background.

This workaround is unfortunately not universal: if you need to add a single row in the middle of your table, you’ll have to fix the backgrounds in all rows below.

PS: to make your formatting more resilient against spurious changes, use styles: paragraph styles for global attributes in a row, character styles for single words in a cell. Note however that direct formatting always takes precedence over named styles and this is why the direct formatting applied by the table “style” macros erases yours.

Thank you for the quick reply. I figured as much, and indeed I do need to be able to add and delete rows in the middle of the table, so Autotext won’t really do the trick.

(P.S. A digression to your digression – I appreciate your advice about using styles. But I find it somewhat baffling that the incredibly common use of bold and italics is not automatically applied as a character style rather than direct formatting. I can’t imagine anyone staying in the flow of writing and consciously stopping and applying a character style each time they want to bold or italicize something. I suppose one could remap ctrl-b and ctrl-i to implement a character style that applied only bold or italics without changing anything else about the font, but then you would need a third keystroke to return to the default character style, which is counterintuitive when all you really want is to turn off the bold or italics. Given the amount of stress placed on styles, it is surprising that the default keystrokes all implement direct formatting, and hide the styles from the ordinary user, who encounters them only when they cause problems.)

An answer to your digression to my digression: I have attached keyboard shortcuts to Emphasis and Stong Emphasis for my own use to replace Ctrl+B/I. I have Alt+0 for No Character Style (this setting parallels Ctrl+0 to go for Text Body which is the standard for main topic text). In the end, when I initially write my document, I switch to (Strong) Emphasis to highlight a word or expression then I switch back to no emphasis, just like I would do with direct formatting. There is no extra stroke and I don’t find it counter-intuitive (after all, “intuition” is frequently nothing else than muscle memory).

This customisation is stored in the user profile; it is therefore available for all documents without the need for reconfiguring on demand.

And I add a new digression:

Alas, M$ Word as so much conditioned the world that introducing the ubiquitous notion of styles is first rejected and criticised as “non-intuitive”. Word only knows of some form of paragraph styles in its style sheet. Developing the idea of styles is waived away by the majority of users and, when they accept it, they use it with a wrong philosophy. They consider styles describe the visual effect after application. With time, I have evolved from this first-thought idea to the more complex workflow of semantic styling where the style name reflects the significance I grant to my paragraphs, words, pages, images, … In a second step, these semantic fields received their visual attributes., not the other way round (what italics would mean? It can be applied to emphasis, citation, foreign word, irony, trademark, … If you give these names to your styles, it does not matter if they end up italics, because you can easily change trademarks for bold small capitals and this will not impact, emphasis, foreign words, …).

2 Likes

You may have bold and italics as character styles… if you get the correct toolbar :wink:

(use the Standard Toolbar interface : View > Interface > Standard toolbar)

With View > Toolbars > Formatting (Styles) you get the two usual suspects in that new toolbar. You might want to then get rid of the usual Formatting toolbar.
This is how my UI is set now (I’ve added a few more toolbuttons wrt styles :wink:
HTH

2 Likes