3

I have four images and i want to put them on top of the page side by side. I am writing on a two column document format. I drew the following picture to show how i want the pictures to look. I tried using minipage environment within figure* , but didn't work . Please advice. A,B,C,D are images i want to insert

I also tried using this link, didn't work for me. link Here is the code i tried using.

       \begin{figure*}
       \centering
       \begin{minipage}[b]{0.3\textwidth}
       \includegraphics[width=0.2\textwidth]{single_hop_wireless1.jpg}
       \caption{Pre processing memory graph}
       \end{minipage}

       \begin{minipage}[b]{0.3\textwidth}
       \includegraphics[width=0.2\textwidth]{single_hop_wireless2.jpg}
        \caption{Post processing memory graph}
       \end{minipage}

      \begin{minipage}[b]{0.3\textwidth}
      \includegraphics[width=0.2\textwidth]{single_hop_wireless3.jpg}
       \caption{Pre processing JVM memory graph}
       \end{minipage}

      \begin{minipage}[b]{0.3\textwidth}
     \includegraphics[width=0.2\textwidth]{single_hop_wireless4.jpg}
      \caption{Post processing JVM memory graph}
     \end{minipage}
    \end{figure*}

Thanks in advance.

1 Answers1

5

Your code can't generate desired images, because (i) with empty lines between mini pages you actually requires that they should be each in own line (ii) with use of mini pages you will obtain 4 figures and not sub figures as is shown on example images.

Try the following:

\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}

\begin{document}
       \begin{figure*}
       \centering
\begin{subfigure}[b]{0.24\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{Pre processing memory graph}
\end{subfigure}
%
\begin{subfigure}[b]{0.24\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{Post processing memory graph}
\end{subfigure}
%
\begin{subfigure}[b]{0.24\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{Pre processing JVM memory graph}
\end{subfigure}
%
\begin{subfigure}[b]{0.24\textwidth}
\includegraphics[width=\textwidth]{example-image}
\caption{Post processing JVM memory graph}
\end{subfigure}
    \end{figure*}
\end{document}

enter image description here

Zarko
  • 296,517
  • It works as a standalone tex file. But when i try integrating it in my original file it gives an error. It says that "! Package subcaption Error: This package can't be used in cooperation (subcaption) with the subfigure package. – Monowar Anjum Mar 06 '16 at 01:08
  • This is another problem, about it you didn't mentioned in your question. If you have provide complete MWE, which exhibit your problem, I would be able to warn on mismatch in your preamble. Solution is simple: omit subfig or subcaption package and use only one of them! – Zarko Mar 06 '16 at 02:43