2011-03-04 55 views
3

我想創建一個圍繞我的LaTeX圖的框架或框,其中包含使用Tab鍵環境進行格式化的代碼。我的代碼看起來是這樣的:圍繞包含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} 

我一直在使用各種框和邊框命令嘗試,無論是在和沒有數字,但乳膠通常以「什麼是錯的 - 也許是缺少\項目」響應或「未在外部模式下「。

如何在我的身材內容周圍創建一個框?

謝謝!

+1

我建議你在[TeX.SE]發佈(http://tex.stackexchange.com)在未來。 – 2011-10-13 23:58:04

+0

@彼得:謝謝,我會牢記這一點! – Eyvind 2011-10-17 13:02:37

回答

3

一種方法是使用the mdframed package。這是相當定製的,我定義的樣式來說明它的用法:

enter image description here

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