I have the following mwe:
% arara: pdflatex: { shell: true }
% arara: pdflatex: { shell: true }
\documentclass{article}
\usepackage{minted}
\usepackage{listings}
\usepackage{caption}
\captionsetup[lstlisting]{font=sf,labelfont=bf,skip=\smallskipamount}
\usepackage{xparse}
\NewDocumentEnvironment {example} { mm }
{\VerbatimEnvironment
\captionof{lstlisting}{#2}\ifx\relax#1\relax\else\label{#1}\fi%
\begin{minted}[linenos=true]{latex}}
{\end{minted}}
\NewDocumentEnvironment {xexample} { o o }
{\VerbatimEnvironment
\IfNoValueF { #1 }%
{\captionof{lstlisting}{#1}%
\IfNoValueF {#2} { \label{#2} }%
}%
\begin{minted}[linenos=true]{latex}}%
{\end{minted}}
\begin{document}
\begin{example}{TheLabel}{The caption}
\usepackage{minted}
\usepackage{caption,floatrow}
\end{example}
%\begin{xexample}[Another caption]
%\usepackage{minted}
%\usepackage{caption,floatrow}
%\end{xexample}
See Example~\ref{TheLabel}
\end{document}
The environment example works like expected. However this environment has two mandatory arguments. I am a friend of optional arguments/keys. With the environment xexample I tried this implementation but it fails.
What's going on here?
Bonus: Is it possible to pass options to minted as well? (of course with an optional argument ;-))


\begin{minted}[caption=...,label=...]?? – May 02 '13 at 18:31minteddoesn't provide the optionscaptionnorlabel. egreg found a nice way: http://chat.stackexchange.com/transcript/message/9247614#9247614 – Marco Daniel May 02 '13 at 18:38fancyvrbavailable for minted. – May 02 '13 at 18:42\fvset? I have no idea? – Marco Daniel May 02 '13 at 18:44fancyvrbare imported bymintedwith\minted@define@extra{...}Replace...withlabeland it is known. But I suppose thatfancyvrbdid not know thecaptionoption. – May 02 '13 at 18:52