1

I use the code

\begin{figure}[ht]
\begin{center}
\subfig{\label{dfg}\includegraphics[width=1\textwidth]{figures/2dcontour}} [Figure (A)] 
\subfig{\label{dfg}\includegraphics[width=\textwidth]{figures/3dcontour}} [Figure (A)] 
\end{center}
\caption{}
\label{fig:subfigureExample}
\end{figure}

But it never gives me side by side figures, only in case I make the figures very small let's say scale=0.1, they become beside each other.

I have looked many online webs about this but they don't do anything different, and I do not know why it does not work for me.

Worth mentioning that subfigure did not work for me and that is why I have used subfig.

Kola B.
  • 690
Soyol
  • 145
  • 3
    The width of your figures is set to \textwidth. That means one figure fills the complete textwidth your document have. Therefore the figures can only be one after the other. Try for both figures something like width=.48\textwidth (that leaves a little place for a space between the images if needed). Because you gave no compilable MWE you have to try this yourself, sorry ... So write \includegraphics[width=0.48\textwidth]{figures/2dcontour} for your first image ... – Mensch Jun 22 '16 at 01:43

1 Answers1

3

I recommend the following

\begin{figure}[h]
    \centering
    \includegraphics[width=0.495\textwidth]{figure1}
    \includegraphics[width=0.495\textwidth]{figure2}
    \caption{Side by side figures.}
    \label{fig:sidebyside}
\end{figure}

This creates two side by side figures. Note that the width has to be set to a values slightly less that width=0.5\textwidth otherwise the second figure will appear below the first figure. Also you can just use \centering.

Now if you want to add captions to each figure the following will do the trick:

\begin{figure}[htb]
\centering
    \begin{subfigure}[h]{0.495\textwidth}
        \includegraphics[width=\textwidth]{dfs}
        \caption{subfigure caption 1}
        \label{fig:fig1}
    \end{subfigure}
        \begin{subfigure}[h]{0.495\textwidth}
        \includegraphics[width=\textwidth]{dfs}
        \caption{subfigure caption 2}
        \label{fig:fig2}
    \end{subfigure}
\caption{overall caption}
\label{fig:subfigureexample}
\end{figure}

Be sure to include

\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
mu7z
  • 339
  • Thanks for your reply, but you are not using any subfig command, actually what you say works but for width=0.4\textwidth at most, and then pictures always come small for me, have no idea why. Besides, your solution has the problem that each subcaption does not come under its corresponding figure, so it does not work. – Soyol Jun 22 '16 at 02:53