在包含标签环境的图形周围创建一个框

我想在我的LaTeX图形周围创建一个框架或框,其中包含使用Tab键环境格式化的代码。我的代码看起来像这样:
begin{figure}
begin{tabbing}
texttt{void method(I, T, E)} { \
  texttt{some code}<emph{some pseudo code}>();\
...
end{tabbing}
caption{The caption for the figure}
end{figure}
我已尝试使用各种框和框命令,无论是图形内还是图形,但LaTeX通常会回答“Something's wrong - 可能缺少 item”或“Not in outer par mode”。 如何围绕我的图形内容创建一个框? 谢谢!     
已邀请:
一种方法是使用
mdframed
包。它是可定制的,我定义了一个样式来说明它的用法:
documentclass{article}
usepackage{xcolor}
usepackage{mdframed}

mdfdefinestyle{mystyle}{
    backgroundcolor=yellow!20
}

begin{document}
begin{figure}
begin{mdframed}[style=mystyle]
begin{tabbing}
texttt{void method(I, T, E)} { \
  texttt{some code}<emph{some pseudo code}>();\
...
end{tabbing}
caption{The caption for the figure}
end{mdframed}
end{figure}
end{document}
    

要回复问题请先登录注册