1

The resolution of this problem appears at the end of this post. First here is the puzzling symptom.

I am using the LaTeX book class on a long complex 400pp document. Some floats generated with the LaTeX \begin{figure} environment (no optional arguments) decide to float many pages beyond the point where they were invoked (other floats in between the bad ones appear OK). Figures can float past a \cleardoublepage, past a \part{}, past a \chapter{}. Some appear on the second page of the following chapter! In between, there are pages containing no floats, where the figure could plausibly have been placed. There are no warnings in the .log file, neither on the page where the figure environment was invoked, nor on the page where the float actually appears.

Resolution: My book also contains many \marginpar's. The problem was that in just one place I had accidentally embedded a \marginpar inside a \footnote. I knew this was not allowed, but I did not realize that it would break something inside LaTeX and, for hundreds of following pages, mess up placement of figure floats. Fixing this one line fixed everything.

closed as off-topic by Mico, Kurt, user13907, user11232, Svend Tveskæg Oct 21 '15 at 3:32

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Well, the generic thing would be using the same algorithm as you use when constructing an MWE, comment piece by piece, till the reason is obvious. – Johannes_B Oct 19 '15 at 16:49
  • 1
    Maybe you have over-sized content of float. For star tra to reduce it (for example use example-image from graphicx package with \includegraphics[width=0.5\hsize]{example-image}). And addto float options [htbp]. And see you log file, there probably is some warning ... – Zarko Oct 19 '15 at 16:50
  • 2
    What warnings do you receive in your .log regarding the float placement? Without any concrete content to play with, I think this comment thread is going to grow long before the question is closed... – Werner Oct 19 '15 at 16:59
  • 4
    I'm voting to close this question as off-topic because the underlying error was not revealed in the body of the posting but, instead, only in a follow-up posting/answer by the OP. As such, the poaing is likely to be of very limited value to other users of this site. – Mico Oct 21 '15 at 0:30
1

The latex float placement algorithm does not penalise (or even measure) the number of pages a float is moved. If it does not fit on the current page then it will be placed in the earliest place that meets the constraints.

Unless \cleardoublepage has been redefined then a float will not go past that point, so it is not really possible to comment on the details of your float placement unless you can show some code.

1

The problem was that in just one place I had accidentally embedded a \marginpar inside a \footnote. I knew this was not allowed, but I did not realize that it would break something inside LaTeX and, for hundreds of following pages, mess up placement of figure floats.

Once I guessed that this might involve \marginpar, I identified the problem by following Johannes_B's advice: I added a line that redefined \marginpar to do nothing, then slowly moved that line forward in the book manuscript from the beginning until the problem began to appear. This localized the bad code until it became obvious, as Johannes_B said it would be. Thanks Johannes_B.

0

You can use the float package and use \begin{figure}[H] to place a single figure exactly where you want.

Maybe that is a quick way of solving your problem.

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