[Writer] How to put a caption outside the frame?

I’m preparing an academic paper using LibreOffice Writer. The paper contains a number of programming code examples. I’ve put these into frames, with captions and “Figure” indices. As documented at [1], the caption appears inside the frame.

I’ve been asked to move the captions outside. Is it possible to change the position of the caption display? That is:

I have now:

|-frame--------------|
| contents...        |
| contents...        |
| Figure 1. Caption. |
|--------------------|

I want:

|-frame--------------|
| contents...        |
| contents...        |
|--------------------|
Figure 1. Caption.

If I delete the caption, any references to it (Insert > Cross-reference) become invalid.

If I select the caption text and drag it outside, cross-references say “Source not found.”

Something I’m missing?

Thanks.

[1] Using Captions - LibreOffice Help - “When you add a caption to a frame, the caption text is added to the text inside the frame, either before or after the existing text” (my emphasis).

I’m afraid that you would not be able to do that from UI. The identifiers would be changed anyway.

You could try saving the work as FODT (which is plain XML file) and edit it in the source code level, moving relevant paragraph elements with their reference data intact. Hope that is doable for you.

The real question is: why would you do that? I can understand it if your frame has a border (or background or any “visible” attribute different from the surrounding environment) and you are required to put the caption out of this highlighting. In this case, put the coding sample in its own frame inside the figure frame.

Otherwise play with the layout properties and dimension of the frame and the caption paragraph style to simulate the external positionning.

I just discovered – to my considerable surprise – that the following turns out to preserve the relationship between the caption and any cross-references.

  1. Select the entire text of the caption (the whole paragraph, including the category and index, e.g. “Figure 1”).
  2. Cut (ctrl-x). At this point, cross-references will change to say “Reference not found,” but don’t worry.
  3. Put the cursor at the beginning of the paragraph following the frame.
  4. Hit return to open up a new paragraph.
  5. Hit up-arrow to move the cursor to the new, empty paragraph.
  6. Paste (ctrl-v). When I just did this in LO 5.4.4.2, it kept the category, index, and caption text intact, and paragraph style, and the reference target – so, cross-references changed back to point to the number!

Steps 4 and 5 are important. If the cursor is on a non-empty paragraph when you paste, it will not keep the caption’s paragraph style.

When I asked the question here, I saw the cross-references disappear and I assumed they would be broken. But, it appears that they survive a cut/paste operation. So, problem solved.

Otherwise, ajlittoz’s suggestion to put a frame for the code sample inside a frame for the caption is a good one.

Does your procedure preserve all properties of “traditional” caption inside a picture frame? I.e, when you move around the picture frame or add another figure, caption follows the original frame and is automatically renumbered.

In your case, I fear (but I haven’t tested it) that you’ll have to manually update (move the caption since it is now a regular paragraph or renumber by hand ALL figure numbers).