I want to embed a small program listing and have used Insert -> Program Listing
in LyX's menu for that.
The settings dialog supports selecting a language (Java), but I can't actually see any difference.
Is there a way to get real syntax highlighting/coloring?
Best Answer
Lyx's "Insert -> Program Listing" is internally based on the
listings
package, which provides a a plenty full of options to influence the typesetting. You can enter suchlistings
options on the "Advanced" page of the "Listing Settings" dialog. For instance, enteringthere would typeset all keywords in blue color. For a quick start take a look at other questions with the listings tag – or consult the (excellent!)
listings
documentationThe reason you do not "see any difference" in your current setup may be a font issue: The culprit is the standard
typewriter
font in LaTeX, which does not have a boldface version; however, the default oflistings
iskeywordstyle=\bfseries
, that is, keywords are typeset in boldface. So just try anothertypewriter
font in "Document -> Settings -> Fonts" and see if this makes a difference.(BeraMono is a good font for typesetting listings.)