spróbować czegoś takiego:
\documentclass{article}
\usepackage{listings}
\usepackage{color}
\usepackage{textcomp}
\definecolor{listinggray}{gray}{0.9}
\definecolor{lbcolor}{rgb}{0.9,0.9,0.9}
\lstset{
language=c,
basicstyle=\scriptsize,
upquote=true,
aboveskip={1.5\baselineskip},
columns=fullflexible,
showstringspaces=false,
extendedchars=true,
breaklines=true,
showtabs=false,
showspaces=false,
showstringspaces=false,
identifierstyle=\ttfamily,
keywordstyle=\color[rgb]{0,0,1},
commentstyle=\color[rgb]{0.133,0.545,0.133},
stringstyle=\color[rgb]{0.627,0.126,0.941},
}
\begin{document}
\begin{lstlisting}
#include <stdio.h>
int main()
{
// A line comment
printf("A really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, REALLY long line. && & \n");
return 0;
}
\end{lstlisting}
\end{document}
która produkuje:
alt text http://img260.imageshack.us/img260/1608/codes.png
Jak mogę uzyskać lateks, aby uciec i automatycznie \ n? – KP65
ok dzięki, edytował op – KP65
Estetyczna uwaga: column = fixed często daje złe wyniki (jak tutaj, litery są rozmieszczone zbyt wiele). Wolę kolumny = pełnafleksja, nawet przy czcionce o stałej szerokości, zapewnia ona o wiele bardziej naturalny wygląd kodu. –