How to float figures to top of page

I suspect I know the answer to this one but would be grateful if someone with more experience could confirm if I have missed something. (Writer 7.4)

Problem
I’m trying to create a monograph with about 100 pages and 30 figures, each with a caption. I would like each image to be positioned at the top of the text area of the page and the text to flow naturally from page to page.
At present I am inserting the images and then the caption. The frame is anchored ‘to paragraph’ and positioned to top/center of text area. The problem is that Writer appears to insert a hidden page break before the frame so that the paragraph does not flow naturally between pages. If I anchor the frame ‘To Page’, the text flows as I would like, but when additional pages are created I have to manually move the frame anchors to update the positions. The problem seems to exist even if I break the document with section breaks to new page - the figures anchor to the physical page number, not the Nth page since the start of the section.

Current work around
At present I create the document with anchor ‘to paragraph’, and then work through the document changing anchor to ‘To page’ and Tools->update->all to force an update to the pagination. Aside from the extra work I have to maintain two copies of the document, one before I place the figures and one after. This is a real pain.

Question 1:
Have I missed something obvious?

Question 2:
I’m looking at using a macro to automate the change in anchor/position for the frames, but so far I cant even record a macro to change the frame positioning. I can record insertion of text, but changes to frame formatting dont get recorded.

Question 3:
If I manage Q2, will I be able to update the pagination as I loop through the frames, or will this happen in the background when the macro completes (and so mess up the positioning).

Question 4:
At some future date I may create a book from a compilation of monographs. If I use the sub-document feature, will changes to then number of pages in one section throw the figures out in subsequent sub-documents?

Many thanks for any suggestions. I would rather avoid LaTeX as it nearly drove me insane when I last used it (admittedly 30 years ago).

  1. Your current workaround doesn’t look preferable to me. Create a frame style (child of Graphic e.g.) for the capturing frames. Recent versions of LibO even allow to set the anchor type, and you can choose the vertical postion to get exactly what you want with ‘From top’ and ‘Entire page’ as long as not the effective distance of the top border of the body text from the page border changes. After ‘Insert caption’ a newly inserted image can be positioned as you want it by simply assigning that frame style to the caption frame. If something was changed later for whatever reasons, you can repeat the assignment.
  2. Donno. But we all do so now and then. You may mean the use of frame styles?
  3. If you want to readjust lots of images of the kind, you can resort to user code. As so often the basics are simple, but there are pitfalls. I personally don’t know (e.g.) all the details concerning layout metrics. In specific I don’t know (nor want to research) how to get the effective layout height of header + distance from body. A recorded macro won’t do, I’m afraid. A raw sketch of usable custom code is contained in the attached example.
  4. Don’t exactly understand what you are afraid of.
  5. No idea. Didn’t use global/sub for many years now.
    topPositioningImages.odt (172.8 KB)

Hi
Thanks for taking an interest and the quick reply. I dont think I was very clear in my original post.

This shows an image,anchored to the red paragraph and positioned as top center of text area. Note that there is blank space at the bottom of the first page that should be filled with text.

If I change the anchor as ‘To Page’ rather than ‘To Paragraph’, I get the desired text flow, but now the image does not move as I insert additional pages at the start of the document. Very annoying as Preface and Acknowledgements are generally the last part to be written and mess up the pagination.

I have tried anchoring ‘To Character’ near the end of the paragraph, but this seems to work the same as ‘To Paragraph’

If you wish to experiment, the two documents can be downloaded here.

Since writing the post I have found the Libre Extension “PicTool” that allows a mass edit of the anchors for frames and images. This solves Q3 and Q4 in my post.

Thanks Lupp. The macro looks useful but for the moment I will try the PicTool and come back to your macro if I need more flexability.

I wonder if the presence of the section is causing the problem.

I removed the “lipsum” section, anchored To character and moved the anchor to various words in the red paragraph. I get the expected result.

BUT, you may still be vulnerable to the same behaviour:

  1. a frame and its anchor point are always positioned on the same page
  2. frame styles tend to be less “reactive” to modifications than other styles

According to 1., the exact anchor position will govern how many lines of the paragraph may be set on the “previous” page. If there is more room, you’ll still have some space left at bottom of page. Consequently, to play safe, anchor at right of last character of the paragraph.


Item 2. is indeed user-unfriendly. First, I recommend you store the properties in a frame style. This makes it easier to apply these properties to all images (of the same type of course). You may perhaps set for AutoSize if you scale/crop separately.
Formatting does not always automatically updates after a frame style change. You can apply another frame style then revert to your custom style but this loses the anchor position which is reset at first character of paragraph.
You can also try Tools>Update>Update All but there is no 100% success guaranteed.
The last “workaround” after an update attempt is to save, close and reopen the document which forces a full real reflow.

If you are speaking to the developers my guess is that ‘Anchor to paragraph’ is ambiguous when a paragraph splits across two pages. I may be wrong but it looks as if they only consider anchoring to the start of the paragraph when they should also consider anchoring to the end of the paragraph (or all pages in the case of extremely long paragraphs). Thanks for your help.

No, anchor To paragraph is not ambiguous. The anchor is located at immediate left of first character. It is only a special case of To character.

I corrected the behaviour by anchoring at the very end of the paragraph. But, I feel that it will not solve all cases and, as I mentioned, there are some “glitches” with frame properties updates, whether it is controlled by a style or not. This is the bad side of frames.

Anchor modes

To page as you noticed glues the frame to a physical page. This mode is primarily intended for DTP-like work where your main object is a page, not text, and you want to arrange data in specific pages without spill over to next page. Example: ad flyer, cheat sheets.

This anchor should usually be avoided for the pain you describe.

The most frequent mode is To paragraph (and less frequently its companion To character which is more tedious to maintain) with which you have maximum flexibility in positioning within the current page.

Take care that the label for the reference position/area maybe confusing (you didn’t tell if your UI is English or some other language). Translation may not be fully accurate. Pay special attention to wording to distinguish between Paragraph text area and Page text area.

  • Paragraph text area refers to the bounding rectangle containing the paragraph
    The frame remains in the vicinity of the paragraph and if space remaining in the page is not high enough to accommodate the frame and the paragraph, a page break is added.
  • Page text area refers to the part of the page allocated to “discourse”, excluding header and footer
    This is probably the position you want.
  • Entire page refers to the full page
    You can then cover the header, footer and margins. IMHO, not recommended except for special purpose.

This should answer Q1

Q2 is irrelevant if you master the position parameters for the frames. A way to improve “automation” is to record all your parameters in a frame style so that after you inserted the frame, you just assign the style to it and its size, position, … is automatically adjusted according to the parameters in the style.

Note however that frame styles don’t behave as nice as the other categories when you update them. You may need to assign another style then revert to the original style for the change to take effect.

Up to now, I never felt the necessity for a macro to achieve my formatting, even with frames. I can’t then answer for Q3 but I personally consider Q2 as unnecessary for such a “basic” task. (When it comes to frames, nothing is really basic.)

Managing a master document and its sub-documents require a very rigorous and systematic approach of formatting. The best thing you can do is to collect all your styles in a template and base all documents on this template. In the master+subs, it is even more important to avoid absolutely all direct formatting to keep safe against “formatting hell”. Don’t add new styles in the sub-documents as they won’t be controlled from the master. Be stubborn when writing your collection of documents: stick to your style collection and never deviate. If something is wrong, modify the style in the template and update the documents.

I don’t understand the exact meaning of your question about pages and figures. The figures are “local” to the sub-doc and their position is defined there. The master is “only” a binder and it will not change the sub-doc contents (except for page number, chapter number and other similar sequences). If you fear for the figure numbers, use the same sequence counter everywhere and it will update automatically. For your references in the text, use a cross-reference to capture the actual number (never quote it literally as it may change). Figures may also be numbered by chapter which gives a more stable number.

2 Likes