0

I want to prevent a figure* going to next page, and be displayed atop the section. Below you find the code, and I also provide an overleaf view-only link.

This past question is also related, but using \twocolumn[{% as suggested breaks usage later on (it forces a page break, so you need to go back to figure* a-posteriori).

I have also tried to fiddle with \FloatBarrier to no avail.

Any suggestions? Much appreciated.

\documentclass[10pt,twocolumn,letterpaper]{article}

\usepackage[review]{cvpr}      % To produce the REVIEW version
\usepackage[utf8]{inputenc}
\usepackage{graphicx}

\usepackage{lipsum}
\newcommand{\loremshort}[1]{{\lipsum[1][0-#1]}}

% FROM: https://aty.sdsu.edu/bibliog/latex/floats.html
% OUTCOME: does not work...
% \input{attempt1.tex}

\def\cvprPaperID{*****} % *** Enter the CVPR Paper ID here
\def\confName{CVPR}
\def\confYear{2023}

\begin{document}
\clearpage
\begin{figure*}[tb!]
\begin{center}
\includegraphics[width=.49\linewidth]{example-image-golden}
\hfill
\includegraphics[width=.49\linewidth]{example-image-golden}
\caption{Why does this figure not want to stay on page 1?}
\end{center}
\end{figure*}
\section{Section}
\loremshort{10}
\end{document}

Yet, the output I get is the following: compiled resut

And this is even if I add attempt1.tex, according to the tricks discussed here:

% Alter some LaTeX defaults for better treatment of figures:
% See p.105 of "TeX Unbound" for suggested values.
% See pp. 199-200 of Lamport's "LaTeX" book for details.
%   General parameters, for ALL pages:
\renewcommand{\topfraction}{0.9}    % max fraction of floats at top
\renewcommand{\bottomfraction}{0.8} % max fraction of floats at bottom
%   Parameters for TEXT pages (not float pages):
\setcounter{topnumber}{2}
\setcounter{bottomnumber}{2}
\setcounter{totalnumber}{4}     % 2 may work better
\setcounter{dbltopnumber}{2}    % for 2-column pages
\renewcommand{\dbltopfraction}{0.9} % fit big float above 2-col. text
\renewcommand{\textfraction}{0.07}  % allow minimal text w. figs
%   Parameters for FLOAT pages (not text pages):
\renewcommand{\floatpagefraction}{0.7}  % require fuller float pages
% N.B.: floatpagefraction MUST be less than topfraction !!
\renewcommand{\dblfloatpagefraction}{0.7}   % require fuller float pages

Trick from David

The twocolumn trick is not quite satisfying:

\documentclass[10pt,twocolumn,letterpaper]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{caption}

\usepackage{lipsum}
\newcommand{\loremshort}[1]{{\lipsum[1][0-#1]}}
\usepackage{blindtext}
\newcommand{\lorem}[1]{{\blindtext[#1]}}

\begin{document}
\section{Introduction}
\lorem{2}
\twocolumn[{
% \begin{figure*}[H]
\begin{center}
\includegraphics[width=.49\linewidth]{example-image-golden}
\hfill
\includegraphics[width=.49\linewidth]{example-image-golden}
\captionof{figure}{Why does this figure not want to stay on page 1?}
\end{center}
% \end{figure*}
}]
\section{Method}
\loremshort{10}
\end{document}

Because it generates a hard page break whenever it's used (similar to clearpage).

enter image description here

6
  • ! LaTeX Error: File `cvpr.sty' not found. is that needed for this example? Nov 3, 2022 at 20:42
  • it's in the overleaf; not sure I guess any 2col template would do the same?
    – andrea
    Nov 3, 2022 at 21:43
  • even your edited example has less than a page of text so a two-column float will necessarily hit the end of document. This is not an issue in a document with more than one page The trick I show is a way to get the figure on the first page so forced page break is not a problem Nov 3, 2022 at 22:48
  • Yes, your solution works for page1, but elsewhere, it has the same issues as placein's FloatBarrier (it creates a \clearpage effect wherever it's inserted). But for a "teaser" (twocol float on page1 it works). However, that's not what I seek.
    – andrea
    Nov 4, 2022 at 2:40
  • if you have more than one page the problem you show here does not arise so my suggestion is not needed Nov 4, 2022 at 7:55

1 Answer 1

0

Two-column floats come, at the earliest, on the next page, as there is no next page here the float can not be positioned at all until it is flushed out by the implicit \clearpage at \end{document}. \clearpage necessarily treats all floats as allowed on float pages as it has to ensure they are all output.

enter image description here

\documentclass[10pt,twocolumn,letterpaper]{article}

%\usepackage[review]{cvpr}      % To produce the REVIEW version
\usepackage[utf8]{inputenc}
\usepackage{graphicx}

\usepackage{capt-of}
\usepackage{lipsum}
\newcommand{\loremshort}[1]{{\lipsum[1][0-#1]}}

% FROM: https://aty.sdsu.edu/bibliog/latex/floats.html
% OUTCOME: does not work...
% \input{attempt1.tex}

\def\cvprPaperID{*****} % *** Enter the CVPR Paper ID here
\def\confName{CVPR}
\def\confYear{2023}

\begin{document}
\twocolumn[{
\begin{center}
\includegraphics[width=.49\linewidth]{example-image-golden}
\hfill
\includegraphics[width=.49\linewidth]{example-image-golden}
\captionof{figure}{Why does this figure not want to stay on page 1?}
\end{center}
}]
\section{Section}
\loremshort{10}
\end{document}
2
  • Yes, as I mentioned earlier, I know this works "just" for this example. The issue is that \clearpage is often used when doing simultaneous edits on overleaf (somebody works on intro, somebody works on method, and we don't change the layout of each other's doc). Issue is that the twocolumn trick forces a hard break in the text (similar to \clearpage) even when that's not desierable. Comments don't allow images, let me post this as an answer to show you.
    – andrea
    Nov 3, 2022 at 21:51
  • I followed the guidelines and added more to my original post.
    – andrea
    Nov 3, 2022 at 21:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .