[texhax] Recommendations on source code printing with highlighting and tabs

teli at mails.selgrad.org teli at mails.selgrad.org
Sun Jul 12 18:18:29 CEST 2009


Hej,

On 10:45 Sun 12 Jul     , Jesse Perla wrote:
>    I need to display source code (mostly C++, but a little matlab and
>    XML) for research papers and tutorials, but am having trouble getting
>    it to look as good as software books
I read a lot of books with worse listing quality (e.g. verbatim style,
no highlighting). :)

>    Question 1) With lstlisting or verbatimtab, is there any way to
>    highlight lines of code?  I want to have a chunk of code and highlight
>    relevant lines somehow (ideally with a background color for it, etc.
>    but I am flexible).
Listings with color are possible, I don't know about background
highlighting for seperate lines, but foreground color should be possible.
Have a look at the color section of the manual on www.ctan.org.

>    Question 2) What are the lstset settings people use with lstlisting to
>    make C++ or others look 'nice'?
I'm not doing this for real publications, but i use:

\lstset{language=C++,
		basicstyle=\small,
		frame=single,
        breaklines=true,
        breakatwhitespace=true,
		numbers=left,
		numberstyle=\tiny,
		xleftmargin=5mm,
		tabsize=4
}

I don't say this settings are 'nice', but they are Ok for me :)
Maybe the listed options can serve as hints for the index :)

>	Question 3) I tried both 'lstlisting' and 'verbatimtab'.  Are there
>	any other ones I should be aware of?
The lstlistings manual mentions many other.


Hope this was of any help :)
	Kai


-- 
All mail clients suck. This one just sucks less.


More information about the texhax mailing list