1

I'm writing a report and have 5 images that need to be placed on it. When adding the aforementioned images to the report, the first two are placed at the top of the text on the first page, the other two are placed on either column on the second page, and then the fifth is placed on a third page, even though the second page is empty (besides the other two images). We're only allowed to use a maximum of two pages with two columns each, so this presents a big problem even if I disregard the formatting issue.

I've tried using the float package's [H] specifier to force the images exactly where I put them in the .tex file, but all that does is create massive gaps in the columns.

If I use the [p] specifier, the images only fill the left column of each page before moving on to the next, starting with the second page..

The [h] specifier basically combines the two above: it creates large gaps in the text and the last few images fill out a single column before moving on to the next page.

This is the best I could do for a MWE (first time attempting one). I have as many \item as in the original document, but with filler text. I also took out the specifiers because I'm not sure how I'd represent multiple different specifiers without simply copy/pasting everything several times.

\documentclass[aps,pre,twocolumn,showpacs,amsmath,amssymb]{revtex4-1}

\usepackage{graphicx}
\usepackage{color}
\usepackage{bm}
\usepackage{float}
\usepackage{pgfplots}
\usepackage{blindtext}

\pgfplotsset{compat=1.16}

\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\hfuzz 1pt
\vfuzz 1pt

\setlength{\parskip}{\baselineskip}

\begin{document}
\begin{itemize}
%
\item \blindtext
\begin{figure}
    \begin{tikzpicture}
        \begin{axis}[
            xlabel={$x$},
            ylabel={$y$},
            xmin=0, xmax=10,
            ymin=0, ymax=10,
            legend pos=north east,
        ]
        \addplot[mark=none, domain=0:10,samples=2]{x};
        \addlegendentry{$y = x$}
        \end{axis}
    \end{tikzpicture}
\caption{Stuff}
\label{fig:image1}
\end{figure}
\begin{figure}
    \begin{tikzpicture}
        \begin{axis}[
            xlabel={$x$},
            ylabel={$y$},
            xmin=0, xmax=10,
            ymin=0, ymax=10,
            legend pos=north east,
        ]
        \addplot[mark=none, domain=0:10,samples=2]{x};
        \addlegendentry{$y = x$}
        \end{axis}
    \end{tikzpicture}
\caption{Stuff}
\label{fig:image2}
\end{figure}
\item \blindtext
\begin{figure}
    \begin{tikzpicture}
        \begin{axis}[
            xlabel={$x$},
            ylabel={$y$},
            xmin=0, xmax=10,
            ymin=0, ymax=10,
            legend pos=north east,
        ]
        \addplot[mark=none, domain=0:10,samples=2]{x};
        \addlegendentry{$y =x$}
        \end{axis}
    \end{tikzpicture}
\caption{Stuff}
\label{fig:image3}
\end{figure}
\item \blindtext
\begin{figure}
    \begin{tikzpicture}
        \begin{axis}[
            xlabel={$x$},
            ylabel={$y$},
            xmin=0, xmax=10,
            ymin=0, ymax=10,
            legend pos=north east,
        ]
        \addplot[mark=none, domain=0:10,samples=2]{x};
        \addlegendentry{$y = x$}
        \end{axis}
    \end{tikzpicture}
\caption{Stuff}
\label{fig:image4}
\end{figure}
\item \blindtext
\item \blindtext 
\begin{figure}
    \begin{tikzpicture}
        \begin{axis}[
            xlabel={$x$},
            ylabel={$y$},
            xmin=0, xmax=10,
            ymin=0, ymax=10,
            legend pos=north east,
        ]
        \addplot[mark=none, domain=0:10,samples=2]{x};
        \addlegendentry{$y = x$}
        \end{axis}
    \end{tikzpicture}
\caption{Stuff}
\label{fig:image5}
\end{figure}
%
\end{itemize}
\end{document}

TL;DR: Images aren't being displayed properly in a two-column format. What am I doing wrong?

  • Welcome to TeX.SE! your code has errors ... I first time see float specifier [(.. ....)]. Also piValueN.dat is not included in your MWE, so we can't test it. – Zarko Oct 29 '19 at 11:45
  • Sorry, ellipsis was meant to represent the various specifiers I've attempted. What's a MWE? EDIT: For context, I've never worked in LaTeX before now, and it was just kinda "Here, do this in LaTeX", without any guidance. – Orion Oct 29 '19 at 11:55
  • Alright, I looked up what a MWE is and am working on drafting one. – Orion Oct 29 '19 at 12:06
  • I think I got it. I replaced most of the text with filler using the blindtext package for the sake of privacy and the plots with a function. – Orion Oct 29 '19 at 12:35
  • It has to do with how LaTeX processes floats and splits paragraphs. Note that the entire paragraph is formatted before being split across two columns, and the first default float [t] will go to the top of that column. – John Kormylo Oct 29 '19 at 13:58
2

If you know exactly where the graphics will fit, you might consider treating them "in line", not as floats.

Wrap them in \begin{center} ... \end{center}, to add the vertical space that would be added automatically by a float.

Finally, use \captionof (package caption) to insert the caption.

2

All I did here is use [ht] figures. If the float can be placed here, it will be. It will never go to the top of the current column. Instead it will go to the top of the next column.

Since you already loaded the float package, I used an [H] figure for the last one. I also added \vspace{\intextsep} which is part of [h] but not [H]. The \hrules are there just to make the spacing clearer.

See also this question

\documentclass[aps,pre,twocolumn,showpacs,amsmath,amssymb]{revtex4-1}

\usepackage{graphicx}
\usepackage{color}
\usepackage{bm}
\usepackage{float}
\usepackage{pgfplots}
\usepackage{blindtext}

\pgfplotsset{compat=1.16}

\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\hfuzz 1pt
\vfuzz 1pt

\setlength{\parskip}{\baselineskip}

\begin{document}
\begin{itemize}
%
\item \blindtext

\begin{figure}[ht]
    \begin{tikzpicture}
        \begin{axis}[
            xlabel={$x$},
            ylabel={$y$},
            xmin=0, xmax=10,
            ymin=0, ymax=10,
            legend pos=north east,
        ]
        \addplot[mark=none, domain=0:10,samples=2]{x};
        \addlegendentry{$y = x$}
        \end{axis}
    \end{tikzpicture}
\caption{Stuff}
\label{fig:image1}
\end{figure}
\begin{figure}[ht]
    \begin{tikzpicture}
        \begin{axis}[
            xlabel={$x$},
            ylabel={$y$},
            xmin=0, xmax=10,
            ymin=0, ymax=10,
            legend pos=north east,
        ]
        \addplot[mark=none, domain=0:10,samples=2]{x};
        \addlegendentry{$y = x$}
        \end{axis}
    \end{tikzpicture}
\caption{Stuff}
\label{fig:image2}
\end{figure}

\item \blindtext

\begin{figure}[ht]
    \begin{tikzpicture}
        \begin{axis}[
            xlabel={$x$},
            ylabel={$y$},
            xmin=0, xmax=10,
            ymin=0, ymax=10,
            legend pos=north east,
        ]
        \addplot[mark=none, domain=0:10,samples=2]{x};
        \addlegendentry{$y =x$}
        \end{axis}
    \end{tikzpicture}
\caption{Stuff}
\label{fig:image3}
\end{figure}
\item \blindtext

\begin{figure}[ht]
    \begin{tikzpicture}
        \begin{axis}[
            xlabel={$x$},
            ylabel={$y$},
            xmin=0, xmax=10,
            ymin=0, ymax=10,
            legend pos=north east,
        ]
        \addplot[mark=none, domain=0:10,samples=2]{x};
        \addlegendentry{$y = x$}
        \end{axis}
    \end{tikzpicture}
\caption{Stuff}
\label{fig:image4}
\end{figure}
\item \blindtext
\item \blindtext\vspace{\intextsep}

\begin{figure}[H]
\hrule
    \begin{tikzpicture}
        \begin{axis}[
            xlabel={$x$},
            ylabel={$y$},
            xmin=0, xmax=10,
            ymin=0, ymax=10,
            legend pos=north east,
        ]
        \addplot[mark=none, domain=0:10,samples=2]{x};
        \addlegendentry{$y = x$}
        \end{axis}
    \end{tikzpicture}
\caption{Stuff}
\label{fig:image5}
\hrule
\end{figure}
%
\end{itemize}
\end{document}

This version is equivalent to using [H] figures, except possibly the \intextsep spacing.

\documentclass[aps,pre,twocolumn,showpacs,amsmath,amssymb]{revtex4-1}

\usepackage{graphicx}
\usepackage{color}
\usepackage{bm}
\usepackage{float}
\usepackage{pgfplots}
\usepackage{blindtext}

\pgfplotsset{compat=1.16}

\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\makeatletter
\newenvironment{myfigure}{\par\vskip\intextsep
  \def\@captype{figure}%
  \noindent\minipage{\columnwidth}%
}{\endminipage
  \par\vskip\intextsep}
\makeatother

\hfuzz 1pt
\vfuzz 1pt

\setlength{\parskip}{\baselineskip}

\begin{document}
\begin{itemize}
%
\item \blindtext

\begin{myfigure}
    \begin{tikzpicture}
        \begin{axis}[
            xlabel={$x$},
            ylabel={$y$},
            xmin=0, xmax=10,
            ymin=0, ymax=10,
            legend pos=north east,
        ]
        \addplot[mark=none, domain=0:10,samples=2]{x};
        \addlegendentry{$y = x$}
        \end{axis}
    \end{tikzpicture}
\caption{Stuff}
\label{fig:image1}
\end{myfigure}
\begin{myfigure}
    \begin{tikzpicture}
        \begin{axis}[
            xlabel={$x$},
            ylabel={$y$},
            xmin=0, xmax=10,
            ymin=0, ymax=10,
            legend pos=north east,
        ]
        \addplot[mark=none, domain=0:10,samples=2]{x};
        \addlegendentry{$y = x$}
        \end{axis}
    \end{tikzpicture}
\caption{Stuff}
\label{fig:image2}
\end{myfigure}

\item \blindtext

\begin{myfigure}
    \begin{tikzpicture}
        \begin{axis}[
            xlabel={$x$},
            ylabel={$y$},
            xmin=0, xmax=10,
            ymin=0, ymax=10,
            legend pos=north east,
        ]
        \addplot[mark=none, domain=0:10,samples=2]{x};
        \addlegendentry{$y =x$}
        \end{axis}
    \end{tikzpicture}
\caption{Stuff}
\label{fig:image3}
\end{myfigure}
\item \blindtext

\begin{myfigure}
    \begin{tikzpicture}
        \begin{axis}[
            xlabel={$x$},
            ylabel={$y$},
            xmin=0, xmax=10,
            ymin=0, ymax=10,
            legend pos=north east,
        ]
        \addplot[mark=none, domain=0:10,samples=2]{x};
        \addlegendentry{$y = x$}
        \end{axis}
    \end{tikzpicture}
\caption{Stuff}
\label{fig:image4}
\end{myfigure}
\item \blindtext
\item \blindtext

\begin{myfigure}
    \begin{tikzpicture}
        \begin{axis}[
            xlabel={$x$},
            ylabel={$y$},
            xmin=0, xmax=10,
            ymin=0, ymax=10,
            legend pos=north east,
        ]
        \addplot[mark=none, domain=0:10,samples=2]{x};
        \addlegendentry{$y = x$}
        \end{axis}
    \end{tikzpicture}
\caption{Stuff}
\label{fig:image5}
\end{myfigure}
%
\end{itemize}
\end{document}
  • I used what you have there and got a third page with a single image, while the second page has just one image, a paragraph from the previous page that inexplicably gets cut in half despite being 7 lines long, and one more paragraph in the second column. – Orion Oct 29 '19 at 14:06
  • This appears to be peculiar to revtex4-1. You can force the float onto page 2 using \clearpage, but this messes up the column equalization. – John Kormylo Oct 29 '19 at 14:14
  • That actually worked, in the sense that it limited the number of pages to 2. Now I just need to tweak it so it actually looks the way I want it, but I think this was a step in the right direction. Thank you. – Orion Oct 29 '19 at 14:22
  • BTW, I forgot that \blindtext does not add a \par at the end (\item adds one at the beginning). – John Kormylo Oct 29 '19 at 14:42
  • I don't use \par at the end of each \item, so \blindtext should still be analogous to what I actually have, right? – Orion Oct 29 '19 at 14:45

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.