[Tex/LaTex] How to put two figures in same line and center of paper

floatsgraphicssubfloats

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*}

Best Answer

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}
Related Question