% -*- Mode: TeX -*- \ifx\thisfileis\anUndefinedMacro\input maybeload \fi \thisfileis{verbatim} % abort loading if we're already loaded \input redefine % This file provides a way of defining new verbatim environments, which is % otherwise difficult. The '\newverbatimenvironment' declaration is just like % the '\newenvironment' declaration except that the stuff in between \begin{foo} % and \end{foo} is read with the special syntax of verbatim mode. % \makeatletter % First, dispatch depending on whether there is an optional argument. \def\newverbatimenvironment#1{\@ifnextchar [{\@new@v@env{#1}}{\@new@v@env{#1}[0]}} % In the definition of \@new@v@env, the easy part (definition of \endFOO) comes % first. The definition of \FOOVERBATIM is harder, and finally \FOO is defined % to have \verb@syntax\FOOVERBATIM at the end of its expansion. \def\@new@v@env#1[#2]#3#4{\expandafter\def\csname end#1\endcsname{#4}\relax \expandafter\def@verbatim\csname #1VERBATIM\endcsname{#1}{##1\end{#1}}\relax \expandafter\newcommand\csname #1\endcsname [#2]{#3\verb@syntax\csname #1VERBATIM\endcsname}} % Define verbatim syntax. \def\verb@syntax{\obeylines\tt\let\do\@makeother\dospecials\frenchspacing\@vobeyspaces} % Finally, an auxiliary function to define a macro whose argument is delimited % by \end{foo} in special syntax, \def@verbatim{\CS}{foo}{...body...}. \begingroup \catcode `|=0 \catcode `[= 1 \catcode`]=2 \catcode `\{=12 \catcode `\}=12 \catcode`\\=12 |gdef|def@verbatim#1#2#3[|def#1##1\end{#2}[#3]] |endgroup \makeatletter