Path: utzoo!attcan!uunet!cs.utexas.edu!uwm.edu!rpi!uupsi!sunic!nuug!hod!asbjorns From: asbjorns@sfd.uit.no (Asbjorn Saetran) Newsgroups: comp.text.tex Subject: 'code' environment with caption Summary: environment like 'verbatim', but with caption needed Keywords: environment verbatim caption Message-ID: <1990Jun11.091343.10487@hod.uit.no> Date: 11 Jun 90 09:13:43 GMT References: <10133@chaph.usc.edu> Sender: Asbj\o rn S\ae tran (asbjorns@sfd.uit.no) Distribution: comp.text.tex Organization: University of Tromsoe, Norway Lines: 48 I'm writing a paper in which I need an environment for short (<20 lines) code fragments. The code should be typeset in \tt, just like in the verbatim environment. But in addition I would to be able to add a caption, for example to give a short explanation to the code. An example: text text text text text text \begin{codefragment} /* * Fill InitBlock */ #ifdef MONA E->ed_ib.ib_mode = bit(15); /* promiscues mode */ #endif E->ed_ib.ib_padr[0] = etheraddr[1]; E->ed_ib.ib_padr[1] = etheraddr[0]; \caption{Code for setting the mode bit in the Lance chip} \end{codefragment} more text text text text text text This should be typeset as: text text text text text text /* * Fill InitBlock */ #ifdef MONA E->ed_ib.ib_mode = bit(15); /* promiscues mode */ #endif E->ed_ib.ib_padr[0] = etheraddr[1]; E->ed_ib.ib_padr[1] = etheraddr[0]; Code fragment 1. Code for setting the mode bit in the Lande chip. more text text text text text text I tried to use \newenvironment and build on the 'verbatim' environment, but failed. Has anyone out in there in netland constructed something like this, or does anyone have suggestions to how it could be done? Greetings from Troms\o . Asbj\o rn S\ae tran University of Troms\o Troms\o , Norway. asbjorns@sfd.uit.no