I just installed Lyx and when I try to insert the program I observe that there is no syntax highlighting. What is the best way to allow for syntax highlighting in LYX?
[Tex/LaTex] Lyx code tag with highlighting for C
codehighlightinglistingslyx
codehighlightinglistingslyx
I just installed Lyx and when I try to insert the program I observe that there is no syntax highlighting. What is the best way to allow for syntax highlighting in LYX?
Best Answer
I assume you need highlighted code in the PDF. When you do Insert --> Program listing, or if you insert a child document as a Program listing, it is the features of the
listings
package that is used. The look of all listings in a document can be modified under Document --> Settings --> Listings, where you can add any of the<key>=<value>
pairs listed in the manual.For example, to specify that the language is C, add
language=C
, to say that comments should be italic and yellow, addcommentstyle=\color{yellow}\itshape
, and so on. Again, the manual is the reference. (I've never really used it much myself.)By adding something like
to the settings, this hello world from Wikipedia (with an added comment) turns out as shown below: