# \fbox does not work with images

I tray to add a border on a list of images using \fbox but it did not work.

my code:

\documentclass[conference]{IEEEtran}
\usepackage{graphicx}
\begin{figure}[!h]
\centering
\fbox{
\mbox{\subfigure[Frame 1]{\includegraphics[width=4cm]{im1.png}}
\subfigure[Foreground silhouette 1]{\includegraphics[width=4cm]{im2.png}}}\\
\mbox{ \subfigure[Foreground silhouette 1]{\includegraphics[width=4cm]{im3.png}}
\subfigure[Foreground silhouette 1]{\includegraphics[width=4cm]{im4.png}}}\\
\mbox{\subfigure[Frame 1]{\includegraphics[width=4cm]{im5.png}}
\subfigure[Foreground silhouette 1]{\includegraphics[width=4cm{im6.png}}}\\
\mbox{\subfigure[Foreground silhouette 1]{\includegraphics[width=4cm{im7.png}}
\subfigure[Foreground silhouette 1]{\includegraphics[width=4cm]{im8.png}}
}
}

\caption{cc.}
\label{fbox}
\end{figure}
\end{document}


I get this error Something's wrong--perhaps a missing \item. }. When i remove the \fbox all things are going. thanks to help me.

• Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. Jan 26, 2014 at 5:41
• @Adam, sorry, I edited my code. Jan 26, 2014 at 5:48

To have each subfigure surrounded with a frame, place the \fbox inside the \subfigure:

\documentclass{IEEEtran}
\usepackage{subfigure}
\usepackage[demo]{graphicx}

\begin{document}

\begin{figure}
\centering
\subfigure[Frame 1]{\fbox{\includegraphics[width=4cm]{im1.png}}}
\subfigure[Foreground silhouette 1]{\fbox{\includegraphics[width=4cm]{im2.png}}}\\
\subfigure[Foreground silhouette 1]{\fbox{\includegraphics[width=4cm]{im3.png}}}
\subfigure[Foreground silhouette 1]{\fbox{\includegraphics[width=4cm]{im4.png}}}\\
\subfigure[Frame 1]{\fbox{\includegraphics[width=4cm]{im5.png}}}
\subfigure[Foreground silhouette 1]{\fbox{\includegraphics[width=4cm]{im6.png}}}\\
\subfigure[Foreground silhouette 1]{\fbox{\includegraphics[width=4cm]{im7.png}}}
\subfigure[Foreground silhouette 1]{\fbox{\includegraphics[width=4cm]{im8.png}}}
\caption{cc.}
\label{fbox}
\end{figure}

\end{document}


To have only one frame, you can do:

\documentclass{IEEEtran}
\usepackage{subfigure}
\usepackage{varwidth}
\usepackage[demo]{graphicx}

\begin{document}

\begin{figure}[!h]
\centering
\fbox{%
\begin{varwidth}{\linewidth}
\subfigure[Frame 1]{\includegraphics[width=4cm]{im1.png}}
\subfigure[Foreground silhouette 1]{\includegraphics[width=4cm]{im2.png}}\\
\subfigure[Foreground silhouette 1]{\includegraphics[width=4cm]{im3.png}}
\subfigure[Foreground silhouette 1]{\includegraphics[width=4cm]{im4.png}}\\
\subfigure[Frame 1]{\includegraphics[width=4cm]{im5.png}}
\subfigure[Foreground silhouette 1]{\includegraphics[width=4cm]{im6.png}}\\
\subfigure[Foreground silhouette 1]{\includegraphics[width=4cm]{im7.png}}
\subfigure[Foreground silhouette 1]{\includegraphics[width=4cm]{im8.png}}
\end{varwidth}}
\caption{cc.}
\label{fbox}
\end{figure}

\end{document}


The demo option for graphicx simply replaces actual figures with black rectangles; do not use that option in your actual document.

If images on the same row are too close, you could use \quad, for example, to add some spacing between them.

By the way, subfigure is obsolete; perhaps you should consider using subfig or subcaption. Also, [!h] might be too restrictive; try using a more convenient option [!ht] or not using none.

• Thanks for your response, How can I put just one border for all the images ? please Jan 26, 2014 at 5:48
• @phdstudent please see my updated answer. Jan 26, 2014 at 5:54