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 deadlock]{\label{deadlock}\includegraphics[width=1.5in]{deadlock-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}

Can you please help?

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

enter image description here enter image description here enter image description here

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

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

\begin{figure}[!htp]
\begin{framed}
\centering
\subfigure[Process with no error]{\label{noerror}\includegraphics[width=1.5in]{noerror-process}}\qquad
\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 deadlock]{\label{deadlock}\includegraphics[width=1.5in]{deadlock-process}}\qquad
\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 no error]{\label{noerror}\includegraphics[width=1.5in]{noerror-process}}\qquad
\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 deadlock]{\label{deadlock}\includegraphics[width=1.5in]{deadlock-process}}\qquad
\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
\section{Package \texttt{adjustbox}}

\begin{figure}[!htp]
\begin{adjustbox}{minipage=\linewidth,frame}
\centering
\subfigure[Process with no error]{\label{noerror}\includegraphics[width=1.5in]{noerror-process}}\qquad
\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 deadlock]{\label{deadlock}\includegraphics[width=1.5in]{deadlock-process}}\qquad
\subfigure[Process with lack of synchronization]{\label{lacksync}\includegraphics[width=1.5in]{lacksync-process}}
\caption{Different kinds of errors occuring in InFlux Processes}
\end{adjustbox}
\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{adjustbox}

\usepackage{blindtext}% for dummy text only

\begin{document}
\blindtext

\begin{figure}[htp]
\begin{adjustbox}{varwidth=\textwidth,fbox,center}
    \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 deadlock]{\label{deadlock}\includegraphics[width=1.5in]{example-image-c}}
    \subfigure[Process with lack of synchronization]{\label{lacksync}\includegraphics[width=1.5in]{example-image}}
\end{adjustbox}
\caption{Different kinds of errors occuring in InFlux Processes}
\label{processes}
%\vspace*{-0.65cm}
\end{figure}

\blindtext
\end{document}

Result


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 deadlock]{\label{deadlock}\includegraphics[width=1.5in]{example-image-c}}
    \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 deadlock]{\label{deadlock}\includegraphics[width=1.5in]{example-image-c}} 
    \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.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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