# What to do if \clearpage does not flush the floats exactly?

Consider this MWE:

\documentclass[%
12pt,
journal,
onecolumn,
twoside,
draftcls,
letterpaper,
]{IEEEtran}

\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usepackage{setspace} %\singlespacing
\usepackage[nopar]{lipsum}
\usepackage{xstring}
\usepackage{afterpage}

\begin{document}
\lipsum[1]

\lipsum[2]

\lipsum[3]

\lipsum[4]

\clearpage % \newpage % no effect %[1]
% \afterpage{\clearpage} % has effect, but page 1 doesn't end with [4], starts also \lipsum[5] %[2]

\begin{figure}[hbt]
\centering
\begin{tabular}{p{0.5\textwidth} p{0.5\textwidth}}
\vspace{0pt} \includegraphics[width=0.41\textwidth]{pic1.pdf} &
\vspace{0pt} \includegraphics[width=0.41\textwidth]{pic1.pdf}
\end{tabular}
\caption[hda-beh]{Something something, something, something something;
(some) something and something something (thing); some thing:
something something, something something}
\label{fig:something}
\end{figure}

\lipsum[5]

\lipsum[6]

\end{document}


... where I'm using this pic1.pdf (an illustration I've had, with most content removed).

I'm using \clearpage because I want the page to end after the fourth paragraph; then I'd expect the floats to be on page 2, and I'd expect the text to continue from page 3. However, with the above code as is (choice %[1]), I actually get this (click on thumbnails for full size):

... that is, unexpectedly, text is placed on page 2, and the floats on page 3.

If I use \afterpage{\clearpage} (that is, I uncomment %[2] and comment %[1]), I get this instead:

... that is, now floats are on page 2, as expected - but page 1 does not end with paragraph 4, instead it includes a bit of paragraph 5 (circled in red), which I don't want!

So how do I tell latex: "end the page HERE, flush floats on next page, and start with text on the page after that"?

-
If you want to specify positions like this, you don't want to use a float environment since using one tells LaTeX 'move this around to wherever seems best to you'. So avoid figure and you can put the images where you want without worrying about the float mechanism. There are packages which let you specify captions outside floats for precisely this kind of reason. –  cfr May 16 at 19:53
\clearpage flushes all pending floats but it can't flush floats that LaTeX has not yet seen –  David Carlisle May 16 at 22:18

Put the \clearpage after the \end{figure} rather than before the \begin{figure}.
You want to tell LaTeX, "No! Do it now!" So do that -- just after the figure has been defined. All that that \clearpage before you defined the figure accomplished was to start a new page. There were no unprocessed floats in the queue at the time it hit your \clearpage.
To make it worse the OP made the problem worse by preventing the float going on a page on its own by use of the optional argument to remove p Thus increasing the chance the float goes to end of document –  David Carlisle May 16 at 22:17