我正在环境中编写一个算法figure
,当我写标题时,它显示得不太好。相反,它看起来太靠近文本框了。
这是 MWE
\documentclass[10pt,emptycopyrightspace]{ewsn-proc}
\usepackage{amsmath,balance,amssymb,amsfonts,complexity,filecontents,graphicx,pgfplots,textcomp,tikz,tikz-3dplot}
\usepackage[most]{tcolorbox}
\usepackage[noend]{algpseudocode}
\usepackage{algorithm}
\usepackage[sort,nocompress]{cite}
\begin{document}
\begin{figure}[htbp]
\fbox{\begin{minipage}{\columnwidth}
\textsc{SomeAlgorithm}
\begin{algorithmic}[1]
\State Do this
\State Do that
\If{You cannot do this or that}
\State Do something else
\EndIf
\While{You are not successful}
\State Work hard
\EndWhile
\end{algorithmic} \end{minipage}}
\caption{Some algorithm}
\end{figure}
\end{document}
标题太靠近图形边框了。我尝试留出一些空间,\vspace{...}
但没有效果。
怎样才能使标题离图形有点远呢?
答案1
只需添加caption
包,即可在标题和浮动之间设置更合适的间距。话虽如此,我不明白为什么您不使用algorithm
带有样式的环境boxed
。您还将对算法进行单独的编号。由于我没有安装您的课程,因此我使用article
带有选项的课程twocolumn
:
\documentclass[10pt, twocolumn]{article}%,emptycopyrightspace]{ewsn-proc}%
\usepackage{amsmath, amssymb, amsfonts, balance, filecontents, graphicx, complexity, pgfplots, textcomp, tikz, tikz-3dplot}%,
\usepackage[most]{tcolorbox}
\usepackage[noend]{algpseudocode}
\usepackage[boxed]{algorithm}
\usepackage{caption}
\captionsetup[boxed]{skip=6pt}
\usepackage{lipsum}
\usepackage[sort,nocompress]{cite}
\begin{document}
\lipsum[11]
\begin{figure}[htbp]
\fbox{\begin{minipage}{\columnwidth}
\textsc{SomeAlgorithm}
\begin{algorithmic}[1]
\State Do this
\State Do that
\If{You cannot do this or that}
\State Do something else
\EndIf
\While{You are not successful}
\State Work hard
\EndWhile
\end{algorithmic} \end{minipage}}
\caption{Some algorithm}
\end{figure}
\lipsum[11]
\begin{algorithm}[htbp]%
\textsc{Some Algorithm}
\begin{algorithmic}%[1]
\State Do this
\State Do that
\If{You cannot do this or that}
\State Do something else
\EndIf
\While{You are not successful}
\State Work hard
\EndWhile
\end{algorithmic}
\caption{Some algorithm}
\end{algorithm}
\lipsum[6-10]
\end{document}