2

I am trying to put four figures side by side in a two column latex document to do so I am using this code. But it's not working. Where am I doing wrong?

\begin{figure}
    \centering
    \begin{subfigure}[b]{scale=0.1}
        \includegraphics{BFS6MB.png}
        \caption{Comparison1 of large caption dfdfd rates dfdfB dfdfd dfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfddfdfdfdf}
        \label{fig:6MB_BFS}
    \end{subfigure}
    \qquad
    \begin{subfigure}[b]{scale=0.1}
        \includegraphics{BFS25MB.png}
        \caption{Comparison2 of large caption dfdfd rates dfdfB dfdfd dfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfddfdfdfdf}
        \label{fig:25MB_bfs}
    \end{subfigure}
    \qquad
    \begin{subfigure}[b]{scale=0.1}
        \includegraphics{MM6MB.png}
        \caption{Comparison3 of large caption dfdfd rates dfdfB dfdfd dfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfddfdfdfdf}
        \label{fig:6MB_mm}
    \end{subfigure}
    \qquad
    \begin{subfigure}[b]{scale=0.1}
        \includegraphics{MM25MB.png}
        \caption{Comparison4 of large caption dfdfd rates dfdfB dfdfd dfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfddfdfdfdf}
        \label{fig:25MB_mm}
    \end{subfigure}
        \caption{Four Figures}
        \label{fig:four figures}
\end{figure}

I am using \documentclass[conference]{IEEEtran}

Generated Page

1 Answers1

5

Where am I [g]oing wrong?

  • Use a figure* environment, not a figure environment, to typeset the figure object across both columns of the two-column environment.

  • You should load the subcaption package, not the subfig package. Actually, it's not clear from your write-up as to which one of these two packages you load. However, you did set the subfig tag, and this makes me think that there's an issue with the package that should be loaded to create subfigures.

  • The instruction \begin{subfigure}[b]{scale=0.1} cannot be correct. It should probably be

    \begin{subfigure}[b]{1\columnwidth}
    

    Observe that the mandatory argument of the subfigure environment is a length variable, not a scalar.

  • The instructions \includegraphics{...} need to be augmented. They should probably be

    \includegraphics[width=\textwidth]{...}
    
  • Delete the second of the three \qquad instructions and replace the other two with \hfill ("horizontal fill").

  • Not an error but an inaccuracy (and redundancy): the \centering instruction isn't needed if the subfigures are supposed to span the full width of the two-column text block -- which I assume is the case here.

enter image description here

\documentclass[conference,demo]{IEEEtran} % omit 'demo' option in real document
\usepackage{graphicx} 
\usepackage{subcaption}
\begin{document}
\begin{figure*}
    %\centering % Not needed
    \begin{subfigure}[b]{1\columnwidth}
        \includegraphics[width=\textwidth]{BFS6MB.png}
        \caption{Comparison1 of large caption dfdfd rates dfdfB dfdfd dfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfddfdfdfdf}
        \label{fig:6MB_BFS}
    \end{subfigure}
    \hfill
    \begin{subfigure}[b]{1\columnwidth}
        \includegraphics[width=\textwidth]{BFS25MB.png}
        \caption{Comparison2 of large caption dfdfd rates dfdfB dfdfd dfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfddfdfdfdf}
        \label{fig:25MB_bfs}
    \end{subfigure}
    %% leave a blank line to create a line break

    \begin{subfigure}[b]{1\columnwidth}
        \includegraphics[width=\textwidth]{MM6MB.png}
        \caption{Comparison3 of large caption dfdfd rates dfdfB dfdfd dfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfddfdfdfdf}
        \label{fig:6MB_mm}
    \end{subfigure}
    \hfill
    \begin{subfigure}[b]{1\columnwidth}
        \includegraphics[width=\textwidth]{MM25MB.png}
        \caption{Comparison4 of large caption dfdfd rates dfdfB dfdfd dfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfddfdfdfdf}
        \label{fig:25MB_mm}
    \end{subfigure}
    \caption{Four Figures}
    \label{fig:four figures}
\end{figure*}
\end{document}
Mico
  • 506,678