Jef Patat wrote:


I'm sorry, I forgot to mention that I know I can do highlighting with
Insert->Program Listing.  But I would like coloured syntax.


The listings package uses multiple keywords to control various colors (background, keywords, comments, ...), which you will need to set. So:

1. Add something to load your favorite color package (most likely color.sty or xcolor.sty) to the preamble. LyX (at least as of version 1.5.6) does not do this automatically unless something else in the document triggers it. For instance, you can say \usepackage[svgnames]{xcolor}, which gives you access to the svgnames palette of colors.

2. Right click the gray (or is it 'gray' for a color and 'grey' for a colour?) handle of the listings inset. Select the language on the Main Settings tab, then switch to the Advanced tab. You can type a question mark (?) in the box to get a list of known parameters. Type in your choices in the format key=value. You can find the relevant parameters in the documentation for the listings package. LyX is fairly smart about adding braces as needed if you just type one entry per line, and as you type parameter names it will show you a list of possible completions on the left (but, AFAIK, won't auto-complete for you, at least as of version 1.5.6). For example (using svgnames)

commentstyle=\color{DarkGreen}
keywordstyle=\color(Blue}

does exactly what you would expect. Note that you can fiddle with other style attributes (such as putting keywords in italics) as well.

HTH,
Paul

Reply via email to