Can I define a newenvironment that has inside it a minted environment?
eg and environment that would be a quickhand for the following code:
\begin{figure}[htp]
\centering
\begin{minipage}{9cm}
\begin{minted}[frame=single]{ruby}
some minted code...
\end{minted}
\end{minipage}
\caption{a caption}
\end{figure}
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.
MWE:
\documentclass{article}
\usepackage{minted}
\usepackage{pgfkeys}
\usepackage{color}
\usepackage{environ}
\usemintedstyle{bw}
\definecolor{bg}{rgb}{0.95,0.95,0.95}
\pgfkeys{
/terminal/.cd,
caption/.code={\pgfkeyssetvalue{terminal/caption}{\caption{#1}}},
label/.code={\pgfkeyssetvalue{terminal/label}{\label{#1}}},
}
\pgfkeyssetvalue{terminal/label}{}
\pgfkeyssetvalue{terminal/caption}{\caption{}}
\NewEnviron{terminal}[1]{
\begingroup
%\pgfkeys{/terminal/.cd,caption={}}
\begin{figure}[\thefigpos]
\centering
\begin{minipage}{9cm}
\begin{minted}[frame=single]{ruby}
\BODY
\end{minted}
\end{minipage}
%\pgfkeysvalueof{terminal/caption}
%\pgfkeysvalueof{terminal/label}
\end{figure}
\endgroup
}
\begin{document}
\begin{terminal}
a tryout
\end{terminal}
\end{document}