I'm finding image floats being placed in a paragraph... OK this is normal. But they're being placed inside sentences which looks terrible. So I have been fishing a round for some time but haven't had people complain about this. This type of answer usually comes up: How to protect text from being split by a float?

I'm using:



enter image description here

Any thoughts?

  • 1
    Did you have a blank line between the figure environment and the paragraph? How do you specify the float placement of the figure? – Marco Daniel Jun 22 '13 at 10:35
  • 4
    Yes. You can try it out ;-) – Marco Daniel Jun 22 '13 at 10:37
  • 4
    The complete algorithm is well explained by Frank Mittelbach in the following answere: How to influence the position of float environments like figure and table in LaTeX? – Marco Daniel Jun 22 '13 at 10:41
  • 1
    Hmm it's still giving me the same problem even with a space here. – HCAI Jun 22 '13 at 11:34
  • 1
    If you're worried about floats splitting sentences in the middle of the page, then I suggest you should only use t, b, and p as placement options. – user10274 Jun 22 '13 at 12:26

your example shows that the break you are concerned about occurs at a page break. let us assume that you are not concerned about a float splitting a paragraph in the middle of a page.

there are several possibilities, depending on the particular conditions:

  • the location of the reference to the float;

  • the size of the float;

  • the length of the split paragraph;

  • the number of lines split to one page or the other.

if the reference to the float occurs earlier than the last paragraph on the "first" page, and the space after that paragraph is sufficient to hold the float, the float instructions might be moved to precede the paragraph in which the reference appears, and the float placement option [b] specified to try to move it onto the same page.

if only one or two lines goes onto the "next" page, you could try to make the first page a line or so longer by using \enlargethispage{1\baselineskip} somewhere on that page.

if the split paragraph has only a line or two on the "first" page, you could encourage a page break before it by inserting \goodbreak before the split paragraph. or, in desperation, you could specify \newpage.

if the split paragraph doesn't start on the first page of a chapter, you could try making adjustments to one or more of the preceding pages (making them a line shorter or longer -- and matching the length of facing pages) to change the conditions that resulted in the unwanted break.

there's an obsolete command \samepage that, placed somewhere in a paragraph, is supposed to keep all lines of the paragraph on the same page. the key instruction in the definition of \samepage is \interlinepenalty=10000, so using that by itself is somewhat less forceful. the affected paragraph should always be enclosed in a group (with braces {...\par} or \begingroup ... \par\endgroup) to limit the scope of the penalty, and remember that a paragraph must be ended for proper operation of paragraph-scoped instructions (\baselineskip, changes in line width, and similar, in addition to \interlinepenalty).

or, when all else fails, rewrite.

  • +1 for putting a more positive spin on it than my answer – David Carlisle Jun 22 '13 at 17:37
  • @DavidCarlisle -- oh, not necessarily a more positive spin, just a few decades of having to do things like this in publications like tugboat. basically, practical hackery. (anyhow, thanks for the encouragement.) – barbara beeton Jun 22 '13 at 20:20
  • Hackery at it's finest! LaTeX is abusing my good and patient nature! – HCAI Jun 23 '13 at 14:30

Basically you can't.

The text is not being split by a float, it is being split by a page break. Only then after the page break, while considering the possibilities for the layout on the following page LaTeX decides to insert a pending float into the top area. By this point LaTeX has essentially no information about the content of the page it just has a vertical list of boxes and glue. In fact the first few boxes are the line boxes coming from the broken paragraphs but LaTeX doesn't know that, they could be graphics or anything, it certainly can not tell the sentence structure.

If you wanted to do this and still leave the possibility of placing the floats somewhere you would probably want to arrange that the line breaking was different. It's a general feature (or lack of feature) of TeX that there is no feedback from the page breaker to the line breaker.

  • I wonder if luatex changes the situation. – Aditya Jun 22 '13 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.