3

嗨,我正在尝试在 Latex 中创建一个环境,以重现以下效果。

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

我想能够说。

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

3 回答 3

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

也看到这个。

于 2010-07-14T22:41:25.090 回答
1

使用Donald Arseneau 的 framed.sty,您可以做到这一点,如果您需要跨越多个页面,它也可以很好地工作。

\新环境{bash命令}{%
  \definecolor{shadecolor}{命名}{bg}%
  \begin{阴影}\ttfamily\color[RGB]{222,222,222}%
}{%
  \end{阴影}%
}
于 2010-08-07T12:29:53.917 回答
1

考虑这个http://kuscsik.blogspot.com/2006/12/how-to-create-new-environment-in-latex.html

于 2010-07-14T22:42:46.713 回答