On Mon, Dec 11, 2000 at 12:58:42PM -0600, Tony Mantler wrote:
> > > > > I feel like I'm trying to hammer nails with a sea-bass here, surely I
> > > > > can't be the first person on earth to want to include code samples in a
> > > > > document?
> > > >
> > > > have a look at
> > > > http://www.educat.hu-berlin.de/~voss/lyx/listings/listings.html

> To clarify:
> 
> I read the web page and followed the directions. When I outputted
> the resulting lyx file to postscript, I got a code listing just like I
> wanted. When I outputted the same lyx file to ascii text,
> I got no code listing at all.

You can use the new insetexternal in lyx-1.1.6pre2:

Add the following lines to LYXLIBDIR/external_templates
Template Listing-Java
  GuiName "[Program: $$FName]"
  FileFilter "*.java"
  AutomaticProduction false
  Format LaTeX
     Product "\\mylisting{language=Java,$$Parameters}{$$FName}"
  FormatEnd
  Format Ascii
     Product "$$Contents(\"$$FName\")"
  FormatEnd
TemplateEnd

And in the LyX file, put the following in the preamble:
\usepackage{listings}
\newcommand{\mylisting}[2]{\lstinputlisting[labelstep=1,#1]{#2}}

You can add any parameter you like to \lstinputlisting.
Then use File->Insert->External material to insert program listings
(you can add additionally parameters (e.g. caption={...} in the parameters
text input box).

Reply via email to