title: How do I create a new Beamer environment with a verbatim environment?
body: <p>I'm creating a Beamer presentation that has a lot of example LaTeX in it, which has to go in a verbatim environment.  I'm getting tired of typing </p>
  
  <pre><code>\begin{example}
    \begin{verbatim}
    Verbatim Text
    \end{verbatim}
  \end{example}
  </code></pre>
  
  <p>I wish to create a new command or environment that will shorthand this for me.  I also need this for blocks and theorems, since I'm using those frequently as well.  But if I can figure it out for examples, it should be easy to translate to another example.</p>
  
  <p>I can't create a new environment or command using just \begin{verbatim}, since it cuts off the rest of the command.  So I switched to using the fancyvrb package, and tried the following:</p>
  
  <pre><code>\DefineVerbatimEnvironment
  {MyVerbatim}{Verbatim}{}
  
  \newcommand{\makeexample}[1]{
      \begin{example}
          \begin{MyVerbatim}
          #1
  
          \end{MyVerbatim}
      \end{example}
  }
  
  \makeenvironment{VerbExample}{\begin{example}
      \begin{MyVerbatim}}{\end{MyVerbatim}\end{example}}
  </code></pre>
  
  <p>That gives me the \makeexample{Example Text} command, and the \begin{VerbExample}...\end{VerbExample} environment, but they both still throw errors on compile.  The frame I'm trying to use them in looks like this (I've got the [fragile] option on the frame, so it's not that).</p>
  
  <pre><code>\begin{frame}[fragile]
      \frametitle{Why Doesn't Verbatim Work?}
  
      \makeexample{Verbatim Text}
  
      \begin{VerbExample}
          Verbatim Text
      \end{VerbExample}
  \end{frame}
  </code></pre>