🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #399

Re: LaTeX \newenvironment and \verbatim

#399
From: Nico Verwer
Date: Fri, 24 Jul 1992 07:54
37 lines
1765 bytes
In <QePh2i600WB6MJKENo@andrew.cmu.edu> me12+@andrew.cmu.edu (Marc R. Ewing) writes:

>Is it possible to do something like:
>
>\newenvironment{zcode}{\begin{quote}\begin{verbatim}}%
>                      {\end{verbatim}\end{quote}}

Some time ago, someone posted the answer to this. Unfortunately, I do
not have his/her name anymore, so I cannot give credit. I do remember
that there was a long discussion on this, to which I contributed as
well, so it won't be inappropriate if I post the macros here:

% 	\(re)newverbatim{<name>}[args]%
% 		{<bhook-before>}{bhook-after}{ehook-before}{ehook-after}
% 
% The args bhook/ehook-before/after will be inserted just before/after
% \begin/\end{verbatim} (roughly speeking).

\makeatletter

\def\newverbatim{\let\@NVtempa\newcommand\@newverbatim}
\def\renewverbatim{\let\@NVtempa\renewcommand\@newverbatim}
\def\@newverbatim#1{\@ifnextchar[%]
				 {\@inewverbatim{#1}}{\@inewverbatim{#1}[0]}}
\long\def\@inewverbatim#1[#2]#3#4#5#6{%
	\expandafter\@NVtempa\csname #1\endcsname[#2]%
		{#3\@verbatim\frenchspacing\@vobeyspaces#4\@defxverbatim{#1}%
\@xverbatim}%
	\@namedef{end#1}{#5\endverbatim#6}}

\begingroup \catcode `|=0 \catcode `[= 1
\catcode`]=2 \catcode `\{=12 \catcode `\}=12
\catcode`\\=12 
|gdef|@defxverbatim#1[|def|@xverbatim##1\end{#1}[##1|end[#1]]]
|endgroup

\makeatother
Technical Details
Message-ID: <1992Jul24.075447.14602@cs.ruu.nl>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!alchemy!nico
References: <QePh2i600WB6MJKENo@andrew.cmu.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.text.tex
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!alchemy!nico
From: nico@cs.ruu.nl (Nico Verwer)
Subject: Re: LaTeX \newenvironment and \verbatim
Sender: network-news@cs.ruu.nl
Message-ID: <1992Jul24.075447.14602@cs.ruu.nl>
Date: Fri, 24 Jul 1992 07:54:47 GMT
References: <QePh2i600WB6MJKENo@andrew.cmu.edu>
Organization: Utrecht University, Dept. of Computer Science
Lines: 38