1

I have a problem when using subfigures: When there is not enough space for the two side-by-side subfigures they are put on the next page, which is fine of course, but then the text following the subfigures(not captions) are put up ahead of the subfigures, so that the text meant to come after the subfigures now is ahead of them.

The code i am using is:

\begin{figure}[hbt]
\centering
\begin{subfigure}{.5\textwidth}
  \centering
  \includegraphics[scale=0.8]{test}
  \caption{test}
  \label{fig:test}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}
  \centering
  \includegraphics[scale=0.8]{test}
  \caption{test}
  \label{fig:test}
\end{subfigure}
\caption{test}
\label{fig:test}
\end{figure}

Does anybody know what might be causing my problem?

JNL
  • 11
  • figure is a floating environment. If you don't want this stuff to float around, put it into a non-floating environment (and put a \captionsetup{type=figure} at its beginning). See also: https://tex.stackexchange.com/a/139907/2574 (Point 6) –  Oct 13 '15 at 20:47
  • ...alternativ könnte man auch mit \FloatBarrier (angeboten vom placeins-Paket) arbeiten. –  Oct 14 '15 at 08:28
  • Okay thanks. But i just don't get why all my figures works fine at page break when using the [hbt](they follow my code), but when having figures with subfigures, it does not work at all at page breaks. It seems that i cannot control them with the specifiers? – JNL Oct 14 '15 at 10:12
  • I guess this has nothing to do with subfigures, it's just that this particular figure has too much height to fulfill the rules of [hbt]. (BTW: You could try [!hbt] instead.) See also: https://tex.stackexchange.com/questions/39017/how-to-influence-the-position-of-float-environments-like-figure-and-table-in-lat –  Oct 15 '15 at 08:04

1 Answers1

1

If you never want a float to float "backwards" to the top of the current page so that it is placed before its position in the source file then you can use

\usepackage{flafter}

which is part of the base latex distribution.

Normally such position isn't a problem as the idea of the \caption and \ref system is that you word the caption assuming it has a fixed position relative to the image, but that wording in the main text body should be neutral about the position of the image and just refer to it by number. But anyway flafter ensures floats are always after their source position.

I note you have omitted p from the argument which makes it quite a bit harder for latex to position the float, so more likely it goes to the end of the document.

David Carlisle
  • 757,742