Make a cross-reference from one included section to another included section

I am trying to make a cross-reference from one included section to a Figure in another included section. I am working with flat odt documents since we need to manage the files under git version control.

To reproduce:

  • Create three empty .fodt files: main.fodt, child1.fodt, child2.fodt
  • In child1.fodt: Insert a header line: “The start of child1”, then insert a section “Section1” below that: Position the cursor where you want the section to appear, then from the menu: Insert->Section and Type in “Section1” under the “New Section” input field. Then press “Insert” button. Then move the cursor inside the inserted section, and type “This is Section1 from child1”. Then save child1.fodt.
  • In child2.fodt: Insert a header line: “The start of child2”, then insert a section “Section1” below that: Position the cursor where you want the section to appear, then from the menu: Insert->Section and Type in “Section1” under the “New Section” input field. Then press “Insert” button. Then move the cursor inside the inserted section, and type “This is Section1 from child2”. Then press enter two times, still inside the inserted section. From the menu, choose “Insert->Image”. From the file dialog, choose e.g. “Cat1.png” (if you do not have a “Cat.png” file, you can download the files. See below) and click the “Open” button. Then right-click the inserted cat image, and choose “Insert Caption…” from the popup menu. Type “Cat” into the Caption text field, and click the “Ok” button.Then save child2.fodt.
  • In main.fodt: Insert a header line: “The start of main”, then insert a section “Section1” below that: Position the cursor where you want the section to appear, then from the menu: Insert->Section and Type in “Section1” under the “New Section” input field. Then click the “Link” radio button in the right pane. Then in the “File name” text field, type in the absolute location of the child1.fodt document, for example: “file:///home/hakon/child1.fodt”. In the “Section” text field type in “Section1”. Then press the “Insert” button. Then in main.fodt, position the cursor outside and below the newly inserted section from child1.fodt. Then from the menu, choose “Insert->Section” and insert “Section1” from child2.fodt the same way as we did with child1.fodt. Save main.fodt.
  • You can alternatively skip the above steps and download the three files from GitHub - hakonhagland/libreoffice-crossref-example
  • We will now try to make a cross reference from child1.fodt to the cat image in child2.fodt.
  • In main.fodt, position the cursor inside Section1 and press the right mouse button and select “Edit Section…” from the popup-menu. Deselect the “Write Protection->Protect” checkmark and click the “Ok” button.
  • Still in main.fodt. Position the cursor inside inside Section1 and select “Insert->Cross-reference…” from the main menu. In the “Type” listbox choose “Figure” and in the “Refer using” listbox, choose “Category and Number”. In the “Selection” listbox choose “Figure1: Cat” (the only option). Click the “Insert” button. Click the “Close” button.
  • Save the main.fodt document
  • Close libreoffice (all open documents)
  • Inspect main.fodt and child1.fodt in an xml text editor. We can see that only main.fodt has been updated with the cross-reference to the cat Figure. child1.fodt has not been updated. So if I reopen main.fodt in libreoffice, the cross-reference is lost.

Expected result

  • child1.fodt should be updated with the cross-reference when I saved main.fodt above.
  • the next time I open main.fodt (after having closed libreoffice) the cross-reference from child1.fodt to child2.fodt is still there.