How is it possible to write a own command that gets a listings environment as parameter?
Code: Select all
\documentclass[a4paper]{article}
\usepackage{listings} % include listings to print source code in LaTeX
\lstnewenvironment{MyCode}{\lstset{language=C++}}{} % Define a new listings environment
\newcommand{\test}[1]{Code: \\ #1} % The following command prints Code: and the parameter given by the user
\begin{document}
% The following lines don't work
\test{
\begin{MyCode}
while(BEDINGUNG)
{
CODE
}
\end{MyCode}
}
\end{document}