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}



makeatletter- check the source of your copy/paste. – Ethan Bolker Dec 10 '16 at 15:25\documentclass{...}, the required\usepackage's,\begin{document}, and\end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Martin Schröder Dec 10 '16 at 15:43