I use the listings
package, but mostly for snippets. I haven't needed to worry about page breaks in general. One of the great things about listings
is the high degree of flexibility available. For instance, I don't capitalize my SQL, but I can print my listings with capitalized 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 define more keywords as I need them:
\lstdefinelanguage[Oracle]{SQL}[]{SQL}{
morekeywords={ACCESS, MOD, NLS_DATE_FORMAT, NVL, REPLACE, SYSDATE,
TO_CHAR, TO_NUMBER, TRUNC},
}
To make use of these definitions:
\lstset{language=[Oracle]SQL,
style=Oracle,
}
If I were to print out larger pieces of code, I'd either not worry about page breaks or write a preprocessor to divide the code up before passing it to LaTeX
.