1

I would like to force ieeetran to start a new page with a wide (i.e. 2-column) figure on top, and render text below it. So far I've been unable to achieve this behavior in a "deterministic" way, and the only workaround I've found for having wide figures on the top of pages is to move their instantiation back to some previous portions of text code--through a cumbersome trial-and-error process--, but this results in chaos as I end up having seemingly-random instantiations all over my code. Instead, I'd like to keep the figure instantiations within the code of the sections where they belong, but if I do so, it seems impossible to force them to be rendered at the top of the page. How can I achieve this? Thanks, Jorge.

Example:

\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{lipsum}

\begin{document}

\begin{figure*}[!t]
\centering
    \subfloat[]{\includegraphics[width=0.4\linewidth]{example-image-a}}
    \hfill
    \subfloat[]{\includegraphics[width=0.4\linewidth]{example-image-b}}
    \caption{Some dummy figures.}
    \label{fig1}
\end{figure*}

\section{This text should follow Fig. \ref{fig1}, not precede it!}
\lipsum[1-6]

% Problem happens also after a \clearpage
\clearpage
\begin{figure*}[!t]
\centering
    \subfloat[]{\includegraphics[width=0.8\linewidth,height=0.2\textheight]{example-image-c}}
    \caption{Another figure.}
    \label{fig2}
\end{figure*}

\section{This text should follow Fig. \ref{fig2}, not precede it!}
\lipsum[1-6]

\end{document} 

Output:

enter image description here

dontpanic
  • 809
  • 1
    figure* always appear on the top of the next page where it is inserted. this means, that it cannot be on the first page of the document. to better see this, in your mwe increase number paragraphs of the \lipsum and remove \clearpage – Zarko Jul 04 '18 at 01:43
  • I'm surprised to learn this! Maybe it would be possible to redefine/tweak it to insert it in the current page? – dontpanic Jul 04 '18 at 01:59
  • 1
    with help help of the packagestfloats is possible insert it on the bottom of the current page, but not on the top. – Zarko Jul 04 '18 at 06:36

1 Answers1

1

The approach is similar to here, but easier. Note that a figure without a caption does not show up in the list of figures.

\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{lipsum}
\usepackage{afterpage}

\makeatletter
\newcommand{\setcaptype}[1]{\def\@captype{#1}}
\makeatother

\newsavebox{\tempbox}

\begin{document}

\savebox{\tempbox}{\begin{minipage}{\textwidth}% measuer height of figure
\setcaptype{figure}%
\centering
    \subfloat[]{\includegraphics[width=0.4\linewidth]{example-image-a}}
    \hfill
    \subfloat[]{\includegraphics[width=0.4\linewidth]{example-image-b}}
    \caption{Some dummy figures.}
    \label{fig1}
\end{minipage}}

\begin{figure}[t]
\rlap{\usebox\tempbox}
\end{figure}
\afterpage{\begin{figure}[t]% next column
\rule{0pt}{\dimexpr \ht\tempbox+\dp\tempbox}
\end{figure}}

\section{This text should follow Fig. \ref{fig1}, not precede it!}
\lipsum[1-6]

% Problem happens also after a \clearpage
\clearpage
\savebox{\tempbox}{\begin{minipage}{\textwidth}% measuer height of figure
\setcaptype{figure}%
\centering
    \subfloat[]{\includegraphics[width=0.8\linewidth,height=0.2\textheight]{example-image-c}}
    \caption{Another figure.}
    \label{fig2}
\end{minipage}}

\begin{figure}[t]
\rlap{\usebox\tempbox}
\end{figure}
\afterpage{\begin{figure}[t]% next column
\rule{0pt}{\dimexpr \ht\tempbox+\dp\tempbox}
\end{figure}}

\section{This text should follow Fig. \ref{fig2}, not precede it!}
\lipsum[1-6]

\end{document} 
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • Thanks so much for your solution, John! I'll try to digest it myself (but not now--I have a deadline, and the important thing is that it solves my problem! :) ) – dontpanic Jul 04 '18 at 04:42