Can I define a newenvironment that has inside it a minted environment?

eg and environment that would be a quickhand for the following code:

some minted code...
    \caption{a caption}

I've tried using both the normal \newenvironment and the \NewEnviron from the environ package. Nothing seems to work, as I always get:

Paragraph ended before \FV@BeginScanning was complete.\par  \end{terminal} 
Extra }, or forgotten \endgroup.
\begin{VerbatimOut} on input line 87 ended by \end{minipage}.
Extra }, or forgotten \endgroup.









a tryout

1 Answer 1


Unfortunately, there is no simple way since minted uses verbatim environments and isn’t designed to be included into other environments (mea culpa).

The following does what you want. It uses minted internals instead of the minted environment to achieve this. As a consequence, you need to put \makeatletter before the command if you want to include it into your tex file:

  • 7
    If there's any possibility of including something like this snippet in the main documentation, or providing a more suitable mechanism for allowing users to embed minted environments in custom ones, that'd be much appreciated.
    – semperos
    Mar 29, 2013 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.