2

I have two figures a and b. I want to put them in the same line with margin and center. I am using two columns format to write the paper but the figure will be one column. I used the bellow code, but two figure are in the wrong location: one is left and one is right of the page. How can I fix it?

\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{caption}


\begin{figure*}
  \centering
  \subfigure[a]{%
    \includegraphics[width=0.23\textwidth]{a}%
    \label{fig:a}%
  }%
  \hfill
  \subfigure[b]{%
    \includegraphics[width=0.228\textwidth]{b}%
    \label{fig:b}%
  }%  
  \caption{xxx}
  \label{fig:ab}
\end{figure*}
2

First Version

The subcaption package is an alternative to subfig. With \caption{caption one}... you also could use subcaptions.

enter image description here

MWE:

\documentclass[journal]{IEEEtran}
%\documentclass[twocolumn]{article}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{lipsum}

\begin{document}
\lipsum[1-9]
\begin{figure*}
\begin{subfigure}{0.5\linewidth}
\centering
\includegraphics[width=0.23\textwidth]{example-image-a}
%\caption{caption one}
\label{fig:A}
\end{subfigure}
\hfill
\begin{subfigure}{0.5\linewidth}
\centering
\includegraphics[width=0.228\textwidth]{example-image-b}
%\caption{caption two}
\label{fig:B}
\end{subfigure}
\hfill
\caption{xxx}
\label{fig:ab}
\end{figure*}
\lipsum[3-10]
\end{document}

2.version ref to your comment

With \hspace{} you could customize the margin between images. In the example \hspace{0.2cm} is used.

enter image description here

\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{caption}
\usepackage{lipsum}
\begin{document}
\lipsum[1-9]
\begin{figure*}
  \centering
  \subfigure[a]{%
    \includegraphics[width=0.23\textwidth]{example-image-a}%
    \label{fig:a}%
    }\hspace{0.2cm}%or more
    \subfigure[b]{%
    \includegraphics[width=0.228\textwidth]{example-image-a}%
    \label{fig:b}%
  }%  
  \caption{xxx}
  \label{fig:ab}
\end{figure*}
\lipsum[1-9]
\end{document}
  • Thanks but I want the figure a and figure b near together. They are in big margin in your result – John May 25 '17 at 11:11
  • Ok then just delete your \hfill.-> Second Example added. – Bobyandbob May 25 '17 at 11:32
  • Could we make a small margin to two images? It is so closed together – John May 25 '17 at 11:35
  • Yes you can make a small margin with addding \hspace{0.2cm} or more \hspace{1cm} ... . Answer is updated. -- Please clarify what you mean in your question in future with example code and maybe a image that it shoul look like, that makes it easier. Hope the solution is now okay for you!? – Bobyandbob May 25 '17 at 12:09
1

EDIT: Different try after comments.

\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
\usepackage{subfigure}
  \usepackage{caption}
\usepackage{lipsum}

\begin{document}
\lipsum
\begin{figure*}
\centering
\begin{minipage}[b]{.4\textwidth}
\centering
 \includegraphics[width=.7\linewidth]{example-image-a}
\caption{Caption}\label{a}
\end{minipage}\qquad
\begin{minipage}[b]{.4\textwidth}
\centering
\includegraphics[width=.7\linewidth]{example-image-b}
\caption{Caption}\label{b}
\end{minipage}
\end{figure*}
\lipsum
\lipsum
\end{document}

NEW RESULT:enter image description here

My try:

\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{caption}
\usepackage{lipsum}

\begin{document}

\lipsum
\begin{figure}[!htb]
\begin{minipage}{0.24\textwidth}
 \centering
 \includegraphics[width=.7\linewidth]{example-image-a}
 \caption{a}\label{Fig:Data1}
\end{minipage}\hfill
\begin {minipage}{0.24\textwidth}
 \centering
 \includegraphics[width=.7\linewidth]{example-image-b}
 \caption{b}\label{Fig:Data2}
\end{minipage}
\end{figure}
\lipsum
\end{document}

Result: enter image description here

  • Thanks but I want two images in mode of one column like setting \begin{figure*} – John May 25 '17 at 10:18
  • I am not getting what you want to achive but nvm – iacopo May 25 '17 at 10:19
  • The figure must be in one column mode. Because my figure is long. You are setting the figure in two column mode – John May 25 '17 at 10:21
  • @user8264 i edit the answer, get a look and tell me if this is what you want to achive – iacopo May 25 '17 at 10:28
  • Btw: Please remove subfigure as it is kind outdated and not needed any more. – TeXnician May 25 '17 at 10:30

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.