Tollef Fog Heen's blog

tfheen Tue, 07 Jun 2005 - 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

A line of code with a break symbol at the end

[16:35] | tech | How to break lines with the listings package in LaTeX

Tollef Fog Heen <tfheen@err.no>