尝试将一个框放在一组子图形周围

尝试将一个框放在一组子图形周围

我正在尝试在下图周围设置一个边界框:

\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}

你能帮忙吗?

答案1

下面的例子显示了使用包framedtcolorbox和 的可能性adjustbox

在此处输入图片描述 在此处输入图片描述 在此处输入图片描述

\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}

答案2

有几种方法可以添加框架围绕这些元素(注意边界框盒子一般来说,在 LaTeX 中确实有其他含义,即不暗示画线)。

最简单的方法是使用adjustbox包:

\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}

结果


您还可以直接使用varwidth\fbox{..}以避免需要额外的包:

\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}

最后,varwidth如果您愿意自己计算所需的宽度,也可以避免使用包。然后您可以minipage直接使用。这是必要的,以便将内容框入框架,同时仍允许换行:

\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}

还有其他用于此目的的软件包,例如mdframed

相关内容