In the past I used external tools to provide listings for my papers. However, with 90% of my listings being SQL today, I am regularly editing and tweaking my listings for readability, which is easier when having them directly inside my LyX document. I had the fear that this would impair code highlighting. It doesn't, since the default listings package provides a ton of options [1].
LyX also to define default listing properties in (Document > Settings > Listings).
Here are my current defaults.
Here is some example output.
[1] Carsten Heinz, Brooks Moses, Jobst Ho mann. The Listings Package.
http://mirror.unl.edu/ctan/macros/latex/contrib/listings/listings.pdf
Current working mode and options
- Use default listings package
- Want floated listings (in LyX)? -> (Right-Click >Settings > Placement > Float [x])
- Float needs caption (in LyX)? -> (Menu > Insert > Caption)
- Want to add/change colors? -> use colors + listing options\definecolor{byzantium}{rgb}{0.44, 0.16, 0.39}commentstyle={\color{byzantium}\textit}
- Want more colors? -> go to http://latexcolor.com/
- Want to add keywords? -> use listing options
language=SQLmorekeywords={WITH} - Want to emphasize words? -> use listing options
emph={Q,Q_c,Q_r,Q_b,Q_d,Q_}emphstyle={\color{blue}\textbf}
LyX also to define default listing properties in (Document > Settings > Listings).
Here are my current defaults.
basewidth={0.5em} basicstyle={\ttfamily\small} breaklines=true columns=flexible commentstyle={\color{byzantium}\textit} emph={Q,Q_c,Q_r,Q_b,Q_d,Q_} emphstyle={\color{blue}\textbf} keepspaces=true keywordstyle={\color{darkmidnightblue}} language=SQL morekeywords={WITH} tabsize=4
Here is some example output.
Links
[1] Carsten Heinz, Brooks Moses, Jobst Ho mann. The Listings Package.
http://mirror.unl.edu/ctan/macros/latex/contrib/listings/listings.pdf
Comments