How can I make such an environment:
\documentclass[a4paper,12pt]{report}
\usepackage{minted,fancyvrb}
\newenvironment{mycode}[1]{
\begin{listing}
\begin{minted}{bash}}{
\end{minted}
\caption{#1}
\end{listing}}
\begin{document}
\begin{mycode}{My title}
echo $PATH
\end{mycode}
\end{document}
I tried to do it this way:
\documentclass[a4paper,12pt]{report}
\usepackage{minted,fancyvrb}
\newminted{bash}{}
\newenvironment{mysupercode}{\VerbatimEnvironment\begin{bashcode}}{\end{bashcode}}
\newenvironment{mycode}[1]{
\VerbatimEnvironment\begin{listing}\begin{mysupercode}}{
\end{mysupercode}\caption{#1}\end{listing}}
\begin{document}
\begin{mycode}{My title}
echo $PATH
\end{mycode}
\end{document}
But got the following error:
Illegal parameter number in definition of \endmycode. \end{mysupercode}\caption{#1}\end{listing}}
\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. – BambOo Aug 21 '18 at 12:16#1) in the\endpart of the environment. You could, in the\beginpart do\def\thiscaption{#1}and then use\caption{\thiscaption}later. – Phelype Oleinik Aug 21 '18 at 12:16