> Could you consider putting this in the Wiki?
I answer again.
Yes, I can consider it, and I've realized it's not easy enough to do it so I 
abandon that idea.
Here is the working Wiki code if someone knows how to do it.

----------------------------------------------------------------------------------------
How to include external program code (program listings). You can use change 
the code in external program and LyX will show the updated source code in the 
output.


!!! Include programlistings

This automatically uses the source code, and any change in the external source 
code will be visible in the LY X output.

* Install the program highlight that is available on 
[[http://www.andre-simon.de/]]
* Run the program highlight on one of your sourcecode files with the 
command:
->@@highlight  -A -L -t 4 -I -S cpp  -r -q KOD.cpp@@
->Change the file name (KOD.cpp) to your file, and change language 
if you use something else than C++ (cpp).
* Things are written in a window, copy and paste everything from the row

->@@\usepackage{color}@@
to
->@@\definecolor{bgcolor}{rgb}{1,1,1}@@

->(but do not include this last line!) to the LATEX Preamble window in 
document settings. Click the Save as Document Defaults button.
* In the Preferences window you should add a new FileFormat

->@@Format:cpp@@
->@@GUIname:C++@@
->@@Extension:cpp@@
->@@Editor:nedit@@

->nedit is the texteditor that I use to write program code. Change to what you 
want to use. Notice that the “Format” name must be something unique that is 
not used elsewhere.
* In the Converters windows you should add

->@@From: C++@@
->@@To: LaTeX(pdflatex)@@
->@@Converter: highlight -A -L -t 4 -I -S cpp -f -r -q $$i -o $$o@@

->Add the same thing for conversion from C++ to LATEX(plain). Don’t forget to 
change to reflect the language you are using.
* Open the file external_templates that is in the LY X directory (either the 
global one, or copy the file to your own personal directory and edit 
that one). To the file you should add the following:

          Template CppCode         
          GuiName "[C++ $$Basename]"         
          HelpText                 
             Add C++ code
          HelpTextEnd         
          InputFormat cpp         
          FileFilter "*.{cpp,h,hpp,c}"         
          AutomaticProduction true         
          Format LaTeX                 
             Product "{\\small \\input{$$FPath$$Basename.tex} }"
             UpdateFormat latex                 
             UpdateResult "$$FName.tex"         
          FormatEnd         
          Format PDFLaTeX                 
             Product "{\\small \\input{$$FPath$$Basename.tex} }"
             UpdateFormat latex                 
             UpdateResult "$$FPath$$Basename.tex"         
          FormatEnd 
          TemplateEnd 

* Now you can use “Insert” , “File”, “External Material” and add your program 
code.

----
Category: [[ProgramCode]] [[SourceCode]] [[Algorithm]] [[Listing]]

Reply via email to