I tried to create a new environment in which I wanted to use minted. Somehow it didn't really work and I found these two posts: 1. 2.
I then copied the code and tried to modify it for my needs. I want to be able to use \begin{code}{label}
. This is what I have:
\newenvironment{code}[2]
{\VerbatimEnvironment
\minted@resetoptions
\setkeys{minted@opt}{frame=lines}% from fancyvrb
\renewcommand{\minted@proglang}[1]{#1}
\begin{figure}[htp]%% default placing
\centering
\label{#2}
\begin{VerbatimOut}{\jobname.pyg}}
{\end{VerbatimOut}
\minted@pygmentize{\minted@proglang{}}
\DeleteFile{\jobname.pyg}
\end{figure}}
\makeatother
I get several "FancyVerb" errors and undefined control sequences.
EDIT
Basically I want to define a new environment that produces the following:
\begin{minted}
[
frame=lines,
framesep=2mm,
linenos,
label=TestLabel
]
{java}
while(true){
//Do stuff
}
\end{minted}
Best Answer
I think you're overcomplicating things:
Another version, where the argument refers to
label=
; I also changedfigure
into the more properlisting
environment.