![尝试将一个框放在一组子图形周围](https://linux22.com/image/249701/%E5%B0%9D%E8%AF%95%E5%B0%86%E4%B8%80%E4%B8%AA%E6%A1%86%E6%94%BE%E5%9C%A8%E4%B8%80%E7%BB%84%E5%AD%90%E5%9B%BE%E5%BD%A2%E5%91%A8%E5%9B%B4.png)
我正在尝试在下图周围设置一个边界框:
\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
下面的例子显示了使用包framed
、tcolorbox
和 的可能性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
。