How do I keep cross-references in subdocuments from mixing up in a master document?

I am working on a master document with multiple subdocuments that use the improvised autotext equation numbering technique. Until now, I had not worried about how Libreoffice managed this cross-references internally.

It turns out that while in each individual subdocument the cross-references to the equations work, in the master document they tend to mix up and more frequently get lost, i.e. show the message “Error: Reference not found” instead of an actual value.

How can I fix this? This is the workspace

Notice how when you first open the files all the references are right, but upon a single global update of the document, the “Error: Reference not found” messages start popping around.

If you were to open the embedded contents.xml of a file, you would see that the actual “unique” name of an equation reference is always refTextN where N is the equation number. That’s just a recipe for disaster in a master document case, I must have like three different refText1 references!

You should try to define your sequence for equations numbering in the master, not in the sub-documents.

I would have tried but subdocuments don’t seem to be naturally editable, and even once removing write protection, saving the master document won’t save changes to the edited subdocuments.