2010-07-14 109 views
2

嗨我正在嘗試在Latex中創建一個重新創建以下效果的環境。在Latex中創建環境

\colorbox{bg}{\ttfamily{\color[RGB]{222,222,222} 
Hello 
Whats up 
} 
} 

我希望能說。

\begin{bashcommands} 
Hello 
Whats Up 
\end{bashcommands} 

回答

4

這個工作對我來說:

\makeatletter\newenvironment{bc_box}{% 
    \begin{lrbox}{\@tempboxa}\begin{minipage}{\columnwidth}}{\end{minipage}\end{lrbox}% 
    \colorbox{bg}{\usebox{\@tempboxa}} 
}\makeatother 

\newenvironment{bashcommands}{ 
    \begin{bc_box}\ttfamily\color[RGB]{222,222,222} 
}{          
    \end{bc_box} 
} 

See this, as well.

+0

看起來像一個真正的囉嗦做的方式。 我在answers.google.com上看到了相同的答案。 我希望有一種方法可以簡單地將命令插入框中。但如果這不起作用,我想我必須使用這種方法。 – 2010-07-15 17:43:49

0

使用Donald Arseneau's framed.sty,你可以做到這一點,這也將很好,如果你需要跨越多個工作頁面。

\newenvironment{bashcommands}{% 
    \definecolor{shadecolor}{named}{bg}% 
    \begin{shaded}\ttfamily\color[RGB]{222,222,222}% 
}{% 
    \end{shaded}% 
}