# What's a nice way to display code in a document?

I'm looking for a nice or creative way to display code in a LaTeX document. I see a lot of nice layouts in books, with text-boxes, titles, annotations, delimiters, and all sorts of attractive things. Mine's a bit lame so far, I just use the verbatim and upquote packages with \noindent and \rule{\linewidth}{0.5mm} to separate it from other sections:

\documentclass{article}
\usepackage[margin=0.25in]{geometry}
\usepackage{verbatim}
\usepackage{upquote}

\begin{document}
\noindent
\rule{\linewidth}{0.5mm}%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{verbatim}
% code % code % code % code % code % code %
% code % code % code % code % code % code %
% code % code % code % code % code % code %
\end{verbatim}
\rule{\linewidth}{0.5mm}%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage
\end{document}

• You can have listings and minted. To customize even more, there is tcolorbox with listings and minted libraries. – user156344 May 20 at 11:17