0

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:


echo


\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}
  • 7
    You can have listings and minted. To customize even more, there is tcolorbox with listings and minted libraries. – user156344 May 20 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.