I have the following code:
\subsection{sub1}
\begin{figure*}
\centering
\includegraphics[scale=0.62]{fig1.png}
\caption{
this is fig1.
\label{fig:fig1}
}
\end{figure*}
blabla [...]
\subsection{sub2}
\begin{figure}
\centering
\includegraphics[scale=0.42]{fig2.png}
\caption{
This is fig2.
\label{fig:fig2}
}
\end{figure}
blabla[...]
I would like figure 1 to be printed before Figure 2, and both of them printed at the top.
Please note that Figure 1 is double column. I always end up with Figure 1 in page three and Figure 2 in page two.
I found a lots of advice on how to use floats, for example:
https://stackoverflow.com/questions/3936430/is-there-a-way-to-get-latex-to-place-figures-and-tables-in-the-order-they-are-re
But they do not seem to work at all (because I have a two-column figure?). Using [H]
has Figure 1 moving to an otherwise blank page at the end of the document. I tried all possible variants of [!ht]
, with no success.
My hope is to get a solution that will not require me to download some hacked package (my file might have to be compiled by other people as well) or fighting with the .cls
file (that I am not allow to change, for the same reason).
Any advice?
Best Answer
Following some guidelines from How to place a multicolumn figure above a single column figure and a single column table?, here's an approach:
figure*
prints the figure at the top of the following page (by default) intwocolumn
mode. Immediately following the placement offigure*
in your code, we use\afterpage
to manually insert content on the following page. As such, they should end up one following the other, only that the second one will be part of the running text, and therefore be positioned inside the first column.Instead of floating the second (column) figure, we place it in a
minipage
of width\columnwidth
(and some vertical separation between the "float" and text; see How can I inject the proper amount of vertical space between captions and figures?). Since we're using aminipage
and not a float,capt-of
helps us set the appropriate caption.