CTS logo
hazy blue Catskill Mountains in distance

News:

Give our new Discussions area a try!

PDF::Builder v3.024 Released, 12 September 2022
   Please see the CPAN listing, GitHub entry.

PDF::Table v1.003 Released, 05 July 2022
   Please see the CPAN listing, as well as the GitHub entry.


A Thought…

The good thing about science is that it’s true whether or not you believe in it.

   — Neil deGrasse Tyson

Reflowing text

Posted on 2022-Apr-09 at 13:21:00 (last update on 2022-Apr-25 at 09:30:00) by Phil

One problem that shows up in text processing is that a float, such as an image (or other graphic, such as a chart or equation), may naturally try to span a page (or column) break. Since we normally want to keep such an item intact (including any associated title or caption), it must be moved in order to keep everything together. Done blindly by a text processor, this means skipping to the top of the next page (or column), and leaving a large hole at the bottom of the current page. This is not desirable, but the usual solution is to manually adjust the text and float location to pull text from after the float to before it, allowing the float to naturally be at the top of the next page. Sometimes, the solution is to do the opposite and move text to after the float, so the float fits on this page.

The illustrations below shows the effect, and the usual fix:

show float that overflows the page
1. Float overflows the page.

show float moved to top of next page, leaving a hole
2. Move float to top of next page, leaving a hole in the text, and some text now overflowing the next page.

show text moved ahead of moved float to fill hole
3. Move some text from after the float to before it, to fill the hole.

Conversely, it could be possible to move text from ahead of the float to behind it, moving the float forward until it fully fits on this page.

Note that care should be taken that the continued text (i.e., the remainder of the paragraph, not brought forward) should not form a widow on the next page (or column), nor should an orphan be left on the current page if text is to be moved back. Further note that one or more levels of headings (subtitles) should normally be kept with the beginning of a paragraph, and not allowed to become orphans themselves. This is independent of the matter of a float’s positioning, and also applies to simple text output. However, the author should have control over this, and may wish to allow the float to be the first content after the heading(s), if the float is on the same page, as they could then be considered no longer an orphan.

Can such reflowing of text around a float be either semi- or fully automated? Such automation could be (by author’s permission) to permit any text following the float to be pulled ahead of it in order to fill the current page, and allow the float to go to the top of the next page in a natural manner. The default “stop point” would be a heading (indicating a new section at some level). The author could manually insert some sort of command to forbid such movement, or limit it to specific text (e.g., to the end of a certain paragraph, or to before a certain heading level). The idea is to minimize the amount of manual markup and intervention needed by the author to set text in a visually pleasing manner (e.g., no large, distracting gaps or holes).

Relatively speaking…

Something that occurs in text is references to other places in the material that may shift in relative position if text is moved. For example, the author may write, “in the figure above”, but if the system moves that text to above the figure (float), it would need to be automatically updated to “in the figure below”! At the very least, the system would have to inform the author that text was moved, so that it could be checked for such relative references, and manually updated as necessary. This might be handled by the author, using some sort of macro (in a markup language, anyway), to have an appropriate relative reference automatically generated. This could include phrases such as

  • (on this page): “above”, “below”, “on this page”
  • (on an earlier page): “previously”, “on the previous page”, “earlier”, “on the facing page”, “on page XX”
  • (on a later page): “following”, “on the following page”, “later”, “overleaf”, “on the facing page”, “on page XX”

and possibly other phrases (language-dependent). The author would have control over those phrases to be selected from, probably in order of preference.

Digging a hole

If a hole on the page cannot be completely filled for one reason or another, a decision needs to be made how to handle it. If large enough (several lines or more), it might just be left there as-is. If only a line or two, the page’s leading might be slightly increased to stretch (just fill) the page. Of course, the author and/or designer should be able to override this with appropriate markup.

 

All content © copyright 2005 – 2022 by Catskill Technology Services, LLC.
All rights reserved.
Note that Third Party software (whether Open Source or proprietary) on this site remains under the copyright and license of its owners. Catskill Technology Services, LLC does not claim copyright over such software.

 

This page is https://www.catskilltech.com/reflowing-text.html

Search Quotations database.

Last updated Mon, 25 Apr 2022 at 9:30 AM

Valid HTML 5

Sat, 24 Sep 2022 at 6:50 PM EDT