> I'd like to put short source code snippets (from 1 to 10 lines max) into my
> text, in typewriter font (I am writing a coding styleguide). I tried to
> just tweak the font settings but was not happy with it because lyx/latex
> still treats it as normal text, and creates margins at the beginning of a
> paragraph etc; I also could not find a way to integrate tabs or spaces for
> source code indentation like this:
I've found the 'listings' package to be very useful for this purpose. It's
similar to 'verbatim' but you can define blocks of code as a float or
otherwise, put various types of frame around the code, put line numbers
alongside the code and perform syntax highlighting on the code. Also, you can
keep the code separate from the LyX file by using the
\lstinputlisting{filename} directive to insert all or part of the code at the
relevant location.
The listings package is available from CTAN.
Good luck,
Mike