# How to use figures with latex correctly

I used the following tags to put a figure in my latex in which to has 2 figures a and b and to appear as one figure behind each other :

\begin{figure}[ht]
\centering
\resizebox{\textwidth}{!}{%
\begin{tabular}{c c}
\includegraphics[width=2.0in] {fig1} &
\includegraphics [width=2.0in]{fig2} \\
\tiny   a. Pure Aloha & \tiny  b.~~ Slotted Aloha
\end{tabular}}
\centering
\caption{Comparision between pure Aloha and slotted Aloha and how they affected by the delay \cite{ahn2011design}}
\label{fig:1}
\end{figure}


But I got the text appeared above the image in my IEEE format as in this image:

Any suggestions ??

• Please help us help you and add a complete minimal working example (MWE). Probably you are using an .eps files? If the answer is "yes" look at the links tex.stackexchange.com/questions/22063/… or stackoverflow.com/questions/12682621/…. If you see \includegraphics[width=2.0in] {fig1}, fig.1, for example, is without file extension. What \usepackage you use? Jan 28, 2017 at 8:35
• no not .eps they are .png Jan 28, 2017 at 8:37
• you have specified textwidth but your columns art only half that width. Why do you not simply have two figure environments one at the top of each column? Jan 28, 2017 at 9:00
• @Sebastiano : I used graphics Jan 28, 2017 at 9:10

You have to use figure*, not figure. But there are other aspects in your code that should be taken care of.

It makes no sense to scale up something that's been scaled down by some unknown factor and then guess what the size of the subcaption be. Just scale the pictures to the right size to begin with. Here's an example:

\documentclass{IEEEtran}
\usepackage{graphicx}

\usepackage{lipsum} % just for the example

\begin{document}

\lipsum

\begin{figure*}
\centering

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}c c cc}
&\includegraphics[width=.4\textwidth]{example-image-a} &
\includegraphics[width=.4\textwidth]{example-image-b} &\\
&a. Pure Aloha & b. Slotted Aloha &
\end{tabular*}

\caption{Comparison between pure Aloha and slotted Aloha and
how they are affected by the delay \cite{ahn2011design}}
\label{fig:1}

\end{figure*}

\lipsum[1-15]

\end{document}


I use tabular* with four columns (the outer ones being empty) so the space can be automatically filled up at the sides and in the middle. There are other methods.

• Your answers are always excellent. My regards and my compliments. Jan 28, 2017 at 10:10
• I got an error : ! Extra }, or forgotten \endgroup. \sf@endfloatbox ...gefalse \outer@nobreak \egroup \color@endbox l.462 \end{figure*} ? Jan 28, 2017 at 12:34
• @Student.Engineering It's impossible to say more if you don't give enough information about your setup. Jan 28, 2017 at 13:05
• is there any problem with my latex ... Jan 28, 2017 at 14:30

if you want to span the float in the both column, you should use

\begin{figure*}

\end{figure*}

• I got an error when I used this Jan 28, 2017 at 8:31
• ! Extra }, or forgotten \endgroup. \@endfloatbox ...pagefalse \outer@nobreak \egroup \color@endbox l.421 \end{figure*} Jan 28, 2017 at 8:33
• @Student.Engineering This is the reason why you have been asked to provide a small complete (=compilable) document that shows your problem, a.k.a. MWE. Without knowing your particular settings and maybe other errors in your code it is difficult/impossible to help. Jan 28, 2017 at 8:54
• @Student. Engineering which cls are you using? Jan 28, 2017 at 8:58
• @gernot and Venkatesan You are right. In fact, I clearly asked to have the complete code. Jan 28, 2017 at 9:17