I have the following piece of code:
\documentclass{article}
\usepackage{subcaption,caption}
\usepackag{graphicx}
\begin{document}
\begin{figure}[hbt!]
\centering
\begin{subfigure}[b]{0.5\textwidth}
\centering
\includegraphics[width = 0.75 \textwidth]{./fig1}
\subcaption{$\epsilon$-Greedy}
\end{subfigure}
\begin{subfigure}[b]{0.5\textwidth}
\centering
\includegraphics[width = 0.75 \textwidth]{./fig2}
\subcaption{UCB}
\end{subfigure}
\end{figure}
\end{document}
This is creating the following picture:
But I want it to look like following (with subcaptions)
The second picture was created using subfigure
package which is obsolete now and isn't allowing to put subcaption properly. Nevertheless, this is the code I used
\begin{figure}[hbt!]
\centering
\subfigure{
\includegraphics[width = 0.45 \textwidth]{./fig1}
}
\subfigure{
\includegraphics[width = 0.45 \textwidth]{./fig2}
}
\end{figure}
Best Answer
I can suggest two remedies:
Keep the widths of the
subfigure
environments unchanged, but insert%
(comment character) immediately after the first instance of\end{subfigure}
.Reduce the widths of the
subfigure
environments from0.5\textwidth
to0.45\textwidth
, insert\hfill
after the first instance of\end{subfigure}
, and increase the width of the included graphics from0.75\textwidth
to1\textwidth
. This approach will also let you get rid of all three\centering
instructions, greatly reducing code clutter.