views:

58

answers:

3

Hi I'm trying to create an environment in Latex that recreates the effect of the following.

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

I want to be able to say.

\begin{bashcommands}
Hello
Whats Up
\end{bashcommands}
+3  A: 

This works for me:

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

Amir Rachum
Seems like a really winded way of doing it.I saw the same answer on answers.google.com.I was hoping there was a way to simply insert the command into the box. But if that doesn't work, I guess I'll have to use this method.
Varun Madiath
A: 

Consider this http://kuscsik.blogspot.com/2006/12/how-to-create-new-environment-in-latex.html

mbq
While that is the obvious method, it doesn't really work in the case I'm trying to use it for. I guess it might have something to do with the colorbox command.
Varun Madiath
A: 

Using Donald Arseneau's framed.sty, you can do this, which would also work nicely if you need to span multiple pages.

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