How to fix LibreOffice's behavior regarding figures and Fields

If I add an image, add a Caption to it, let’s say “test” and choose to insert a Field with its name afterwards with “Category and Number” it will output as it should "Figure ". However if I change the label from Figure to Figura , the field will only read . If I change it back to Figure the field will again update accordingly.
Questions:
Is there any way to make it work as it should?
Is there any way to update category names and keep the insert field functionality work as expected?

Demo attached: test.odt

PS: To be noted that the initial request stated that renaming from Figure to Figures does not work as expected, while it does, as pointed by @ajlittoz in comments.

I changed “Figure” to “Figures” in the caption and the field updated accordingly. It may need Tools>Update>Update all or Fields to show up.

I’m using LO 7.0.4.2.

I believe that the current behaviour is consistent and normal.

First, your sample was different from your question. In the sample, you used category (number range) “Figure”, and in the caption, you changed “Figure” to “Figura”, not “Figures”. That makes some difference, as @ajlittoz commented.

Why is this so? It seems that LO checks that the text before number range field starts with the name of the number range. If it is, then this text is considered “category name” for the purposes of the “Category and Number” formatting, otherwise LibreOffice has no way to tell if the preceding text has any relation to category, or is this some free-form text like in “Some interesting data (illustration 1)”, where the text preceding “1” ("Some interesting data (illustration ") is not the category name.

So IMO it already works as expected, and if you need to change your category to “Figura”, then you need a numbering range named appropriately.

From experimenting, it looks like (at least with “Category first” setting) Writer captures everything between the “declared” category name and the number range as what is field-inserted as “Category”. This explains why “Figures” works and not “Figura” because “Figure” is a valid prefix in “Figures” while it is not in “Figura”.

This leads to funny things with “Some interesting data (illustration 1)” depending on whether the category name is present in the long text (this is case-sensitive).

Thanks for the explanation since I cannot upvote yet. One more question: do these change when language is changed since I cannot test that at the moment.
Still this behavior is not really consistent or user friendly as the name shows correctly.

The category names change with the UI language, not with document or paragraph language. So you should rather define your own categories while preparing your work. Thus the category names will be exactly what you want.

Writer captures everything between the “declared” category name and the number range as what is field-inserted as “Category”. … This leads to funny things with “Some interesting data (illustration 1)” depending on whether the category name is present in the long text (this is case-sensitive).

True. It seems it would be better if it captured after the last occurrence of the category, so that “Images with fruits (Image 1)” would work as expected. Want to file a bug? :slight_smile:

Still this behavior is not really consistent or user friendly as the name shows correctly.

Not quite understand what you mean. Which name shows correctly where? and how “name” relate to “category”?

@mikekaganski

Want to file a bug?

Perhaps not. I see interesting effects in this, even if this is involuntary. The danger would be to rely upon it if it may disappear without notice. It all depends on what the design specification says (such a document exists, doesn’t it?). I don’t think this is defined by ODF because it is only a facility for the author (related to cross-references). What is stored in the file is independent of it.

I don’t feel quite sure about what you actually did.

Just a hint: If you don’t want to use one of the predefined Category_s for a group of Number range TextField_s, you should define your new Category when inserting (creating) the first instance. Later you can edit the shown text, but not the name of the Category (except, probably, by user code). There are limited automatisms concerning references, but I don’t know a specification insofar. As seen from the API, a Category is represented by a TextFieldMaster object. The UI has (afaik) no means to edit it later. The individual instances actually shown in the text are assigned to the TextFieldMaster as DependentTextField_s.

Thanks for the explanation since I cannot upvote yet.