5

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.

2
  • 1
    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. – Adam Liter Jan 26 '14 at 5:41
  • @Adam, sorry, I edited my code. – BetterEnglish Jan 26 '14 at 5:48
7

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}

enter image description here

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}

enter image description here

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.

2
  • Thanks for your response, How can I put just one border for all the images ? please – BetterEnglish Jan 26 '14 at 5:48
  • 1
    @phdstudent please see my updated answer. – Gonzalo Medina Jan 26 '14 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.