# Trying to put a box around a collection of subfigures

I'm trying to have a bounding box around the following figure:

\begin{figure}[htp]
\begin{center}
\subfigure[Process with no error]{\label{noerror}\includegraphics[width=1.5in]{noerror-process}}
\subfigure[Process with syntactic  errors (connector having multiple incoming edges and presence of hanging node)]{\label{synerror}\includegraphics[width=1.5in]{synerror-process}} \\
\subfigure[Process with lack of synchronization]{\label{lacksync}\includegraphics[width=1.5in]{lacksync-process}}
\end{center}
\caption{Different kinds of errors occuring in InFlux Processes}
\label{processes}
\vspace*{-0.65cm}
\end{figure}


-
Welcome to TeX.sx! Note that we like to see minimal working example (MWE) which are complete and compilable, not just code snippets. This gives people the possibility to easily compile your example and to add and test their solution. – Martin Scharrer May 13 '12 at 12:52
You can use the package tcolorbox or framed. – Marco Daniel May 13 '12 at 12:56
Should the caption be inside the frame or outside? – Martin Scharrer May 13 '12 at 13:09
Also see Should I use center or centering for figures and tables? to learn why you should use \centering instead of center. – Martin Scharrer May 13 '12 at 13:10

The following example shows possibilites with the package framed, tcolorbox and adjustbox.

\listfiles
\documentclass[demo]{article}
\usepackage{framed}
\usepackage{tcolorbox}

\usepackage[]{graphicx}
\usepackage{subfigure}
\begin{document}
\section{Package \texttt{frame}}

\begin{figure}[!htp]
\begin{framed}
\centering
\subfigure[Process with syntactic  errors (connector having multiple incoming edges and presence of hanging node)]{\label{synerror}\includegraphics[width=1.5in]{synerror-process}}

\subfigure[Process with lack of synchronization]{\label{lacksync}\includegraphics[width=1.5in]{lacksync-process}}
\caption{Different kinds of errors occuring in InFlux Processes}
\end{framed}
\end{figure}
\clearpage
\section{Package \texttt{tcolorbox}}

\begin{figure}[!htp]
\begin{tcolorbox}
\centering
\subfigure[Process with syntactic  errors (connector having multiple incoming edges and presence of hanging node)]{\label{synerror}\includegraphics[width=1.5in]{synerror-process}}

\subfigure[Process with lack of synchronization]{\label{lacksync}\includegraphics[width=1.5in]{lacksync-process}}
\caption{Different kinds of errors occuring in InFlux Processes}
\end{tcolorbox}
\end{figure}
\clearpage

\begin{figure}[!htp]
\centering
\subfigure[Process with syntactic  errors (connector having multiple incoming edges and presence of hanging node)]{\label{synerror}\includegraphics[width=1.5in]{synerror-process}}

\subfigure[Process with lack of synchronization]{\label{lacksync}\includegraphics[width=1.5in]{lacksync-process}}
\caption{Different kinds of errors occuring in InFlux Processes}
\end{figure}

\end{document}

-

There are several ways to add a frame around such elements (note that bounding box and box in general do mean something else with LaTeX, i.e. do not imply a drawn line).

The simplest way is to use the adjustbox package:

\documentclass{IEEEtran}

\usepackage{subfigure}

\usepackage{blindtext}% for dummy text only

\begin{document}
\blindtext

\begin{figure}[htp]
\subfigure[Process with no error]{\label{noerror}\includegraphics[width=1.5in]{example-image-a}}
\subfigure[Process with syntactic  errors (connector having multiple incoming edges and presence of hanging node)]{\label{synerror}\includegraphics[width=1.5in]{example-image-b}} \\
\subfigure[Process with lack of synchronization]{\label{lacksync}\includegraphics[width=1.5in]{example-image}}
\caption{Different kinds of errors occuring in InFlux Processes}
\label{processes}
%\vspace*{-0.65cm}
\end{figure}

\blindtext
\end{document}


You can also use varwidth and \fbox{..} directly to avoid the need for an extra package:

\documentclass{IEEEtran}

\usepackage{subfigure}
\usepackage{graphicx}
\usepackage{varwidth}

\usepackage{blindtext}% for dummy text only

\begin{document}
\blindtext

\begin{figure}[htp]
\centering
\fbox{\begin{varwidth}{\textwidth}
\subfigure[Process with no error]{\label{noerror}\includegraphics[width=1.5in]{example-image-a}}
\subfigure[Process with syntactic  errors (connector having multiple incoming edges and presence of hanging node)]{\label{synerror}\includegraphics[width=1.5in]{example-image-b}} \\
\subfigure[Process with lack of synchronization]{\label{lacksync}\includegraphics[width=1.5in]{example-image}}
\end{varwidth}}
\caption{Different kinds of errors occuring in InFlux Processes}
\label{processes}
%\vspace*{-0.65cm}
\end{figure}

\blindtext
\end{document}


Finally, you can also avoid the varwidth package if you are willing to calculate the required width yourself. Then you can use minipage directly. This is needed in order to box the content for the frame while still allowing for line breaks:

\documentclass{IEEEtran}

\usepackage{subfigure}
\usepackage{graphicx}

\usepackage{blindtext}% for dummy text only

\begin{document}
\blindtext

\begin{figure}[htp]
\centering
\fbox{\begin{minipage}{3.05in}%
\subfigure[Process with no error]{\label{noerror}\includegraphics[width=1.5in]{example-image-a}}
\subfigure[Process with syntactic  errors (connector having multiple incoming edges and presence of hanging node)]{\label{synerror}\includegraphics[width=1.5in]{example-image-b}} \\
\subfigure[Process with lack of synchronization]{\label{lacksync}\includegraphics[width=1.5in]{example-image}}
\end{minipage}}
\caption{Different kinds of errors occuring in InFlux Processes}
\label{processes}
%\vspace*{-0.65cm}
\end{figure}

\blindtext
\end{document}


There are also other packages for this, e.g. mdframed.

-