I use the listings package, but mostly for snippets. I do not need to worry about page breaks in general. One of the great features of listings is its high degree of flexibility. For example, I do not use my SQL code, but I can print my lists with capital keywords:
\makeatletter \newcommand{\lstuppercase}{\uppercase\expandafter{\expandafter\ lst@token \expandafter{\the\ lst@token }}} \newcommand{\lstlowercase}{\lowercase\expandafter{\expandafter\ lst@token \expandafter{\the\ lst@token }}} \makeatother \lstdefinestyle{Oracle}{basicstyle=\ttfamily, keywordstyle=\lstuppercase, emphstyle=\itshape, showstringspaces=false, }
And identify more keywords as needed:
\lstdefinelanguage[Oracle]{SQL}[]{SQL}{ morekeywords={ACCESS, MOD, NLS_DATE_FORMAT, NVL, REPLACE, SYSDATE, TO_CHAR, TO_NUMBER, TRUNC}, }
To use these definitions:
\lstset{language=[Oracle]SQL, style=Oracle, }
If I were to print large snippets of code, I would not worry about page breaks or write a preprocessor to split the code before transferring it to LaTeX .
source share