[Tex/LaTex] Floats for order of figure in case of double column figure

floatspositioningtwo-column

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:

enter image description here

\documentclass[twocolumn]{article}
\usepackage{afterpage,lipsum,capt-of,graphicx}% http://ctan.org/pkg/{afterpage,lipsum,capt-of,graphicx}
\usepackage[margin=1in]{geometry}% Just for this example
\begin{document}
\lipsum[1-7]

\begin{figure*}
  \centering\includegraphics[width=.7\linewidth,height=2in]{example-image-a}\par
  \caption{This is a figure caption}
\end{figure*}%

\afterpage{%
  \noindent\begin{minipage}{\columnwidth}
    \centering
    \includegraphics[width=.8\linewidth,height=4\baselineskip]{example-image-b}
    \captionof{figure}{This is anoth figure caption}
    \vspace*{\textfloatsep}% Insert "regular" gap between float and text
  \end{minipage}%
}

\lipsum[8-14]
\end{document}

figure* prints the figure at the top of the following page (by default) in twocolumn mode. Immediately following the placement of figure* 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 a minipage and not a float, capt-of helps us set the appropriate caption.

Related Question