I had trouble reordering pictures and text but I managed to. Needs advanced computer knowledges.

Hello,
I had a problem and I managed to solve it. I think others may get the same trouble so I’m posting my solution here.

Warning: this solution is only for advanced user. I deeply suggest you do a COPY of the original file BEFORE any action “just in case of”. “Case of” happens frequently imho. In this one an error may end with a corrupted file.

I had this problem which has been sometime asked: I had a writer file with picture under which were description of the picture. I wanted to move the text above picture for all picture. Basically a “search find replace” with some regex except you had to put “any picture” into the search bar. It seems in the past there were some extension able to do it but I cannot see any nowadays.

Then I remember odt is is an open file format. :slight_smile: :sunglasses:
So I basically made a copy of my original file (which I kept in a precious safe place) and open with a file archiver the odt file.
In it I saw a series of file. The one that interested me is content.xml which is a pure xml file. I then opened it with a text editor and could use basic search and replace to do what I needed to do, then replaced the original content.xml with the modified one.
That’s all folks.

PS: thanks a lot libreoffice not only for being free but for using open format :person_raising_hand:

1 Like

Thanks for sharing!

Note that in the way you provided this, it is now “a question without a solution”, so people looking for a solution for a similar problem can just skip it. It is better to re-organize as: a “problem” in the question part (edit it, and re-word to only describe the problem, as the user sees it); then press “Suggest a solution” button, where will go your way of resolving this. Then you can yourself mark it as the accepted solution.

There is a better way of doing this without tweaking the file (which is always hazardous).

You apparently consider the picture to be your “main” object to which a description or caption is attached. This is how Insert>Caption works but it does not allow modifications after creation. In addition it complicates document structure by inserting frames (which can’t be constrained to proper nesting).

Reverse your paradigm. Consider your description to be the main object which is decorated by your picture.

Your description becomes an “ordinary” paragraph to which you apply an adequate paragraph style. Insert the picture you anchor to the paragraph (or some character). Apply a dedicated frame style.

By default, built-in Graphics style is applied. You can go with it if you have only one “type” of pictures, i.e. all your pictures are handled the same.

DON’T POSITION YOUR PICTURE MANUALLY! Doing so attaches direct formatting (DF) to the picture and this DF is next to impossible to get rid of. According to precedence rule, DF has higher priority than styles and your manual position will never be replaced by position defined in the style.

Position of picture is specified in the Type tab of the style.

  • make sure Anchor is To paragraph
  • Position Horizontal Center relative to Entire paragraph area for global centring between margins,
  • Position Vertical Top or Bottom for pictore above or below description paragraph
  • tick Keep inside text boundaries to prevent the image from being clipped if it is too close to page top or bottom

In Wrap tab there are extra settings to tune picture relationship to text.

  • select Wrap Off (because you want the picture neatly above or below the description)
  • Spacing allows to add extra spacing to better separate the picture from text; only Top and Bottom are relevant here
  • untick Allow overlap (so that the frames are automatically repositioned if you attach several pictures to the same description – I don’t understand why developers ticked this setting by default; it causes more problems this way)

Now, if you want to change from top description to bottom description, you simply change the vertical position reference in the Type tab of the style.

Frame styles are bit more fragile than other styles. If you don’t see any change after a style modification, click in some “ordinary” paragraph (i.e. one without picture attached). If it still does not update, Tools>Update>Update All.

Here LO 24.8.4.2 under Fedora 41 with KDE Plasma desktop.

PS: if you want to tweak document XML, save it as .fodt This will spare you the pain of using a zip utility and reinserting modified contents in it. A .fodt can be opened in any text editor.