How to break lines with the listings package in LaTeX
LaTeX is a really nice typesetting language and it has a nice tool
called listings
which handles program listings for you. By default,
listings doesn’t break lines. Why it doesn’t do that is beyond me, but
I’m sure the author has his reasons. It does however have support for
breaking lines quite easily. The trick is using something along the
lines of:
\lstset{
basicstyle=\small,
showstringspaces=false,
language={},
breaklines=true,
breakatwhitespace=true,
prebreak={\mbox{\hfill$\hookleftarrow$}}}
which renders into