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

4
  • 2
    What is not working here? Can you provide an image of the output? Also, what \documentclass are you using?
    – Werner
    Commented Jul 26, 2019 at 0:25
  • I am using \documentclass[conference]{IEEEtran} Commented Jul 26, 2019 at 0:41
  • Added the figure Commented Jul 26, 2019 at 0:47
  • Welcome to TeX.SE!
    – Mico
    Commented Jul 26, 2019 at 4:48

1 Answer 1

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}

You must log in to answer this question.

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