lstlisting in NewDocumentEnvironment
Verfasst: Di 25. Dez 2012, 17:57
Ich möchte Quellcodes durchnummerieren und ein Verzeichnis dafür anlegen.
Dazu habe ich folgendes gemacht:
So funktioniert das allerdings nicht, da ich folgendes bekomme:
Dazu habe ich folgendes gemacht:
\documentclass{book} \usepackage{xparse,tocloft,listings} \newcommand{\codelist}{Codelist} \newlistof{code}{cod}{\codelist} \NewDocumentEnvironment{code}{m} { \begin{lstlisting} \refstepcounter{code} \addcontentsline{cod}{code} {\protect\numberline{\thechapter.\thecode}#1}\par } {\caption{#1}\end{lstlisting}} \begin{document} \begin{code}{Caption} Some Code \end{code} \listofcode \end{document}
Jemand ne Idee?! Missing \endcsname inserted.
<to be read again>
\global
l.17 \begin{code}{Caption}