4

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?

3

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.

1

According to http://www.tex.ac.uk/FAQ-2colfltorder.html,

Now, standard LaTeX has different lists for single-column floats, and double-column floats; this means that single-column figures can overtake double-column figures (or vice-versa), and you observe later figures appear in the document before early ones. The same is true, of course, for tables, or for any user-defined float.

The LaTeX team recognise the problem, and provides a package (fixltx2e) to deal with it. Fixltx2e amalgamates the two defer lists, so that floats don’t get out of order.

So you can include \usepackage{fixltx2e} (which should come default with Latex) on your preamble and this should force the figures to appear in the correct order in the text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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