The listings code package 1 seems to be the standard way to set code in LaTeX. There are several alternatives 2 but listings code is the classic choice. It's quite customizable -- you can easily add languages change colors insert line numbers and so on. The full documentation 3 is worth looking at but I'll give some usage and screenshots for motivation. First here's a minimal examplen documentclassarticle code usepackagelistings code begindocument code beginlstlistinglanguage=Haskell code -- Recursive factorial in Haskell code factorial = 1 code factorial n = n * factorial (n - 1) code endlstlisting code enddocument code This produces a rather unattractive result that's not syntax-highlightedn nLuckily the poor-looking defaults are easy to fix. Options are passed to the listings package as key-value pairs . They can either be arguments to the lstlisting code environment (as above) or they can be set globally using the lstset code mand. Here are three useful options. Font family and spacing. By default listings code sets code in Computer Modern Roman and forces it to fit a fixed- grid. It looks much better if you use Computer Modern Typewriter and turn off the forced spacing. You can also stylements separately from coden lstsetbasicstyle=ttfamily columns=fullflexiblementstyle=rm code n Syntax highlighting. You can separately highlight identifiersments strings and keywords (see Section 4.6 of 3). Here I'll just show identifiers (because that's all my sample has)n usepackagecolor code code lstsetidentifierstyle=coloridentifierColor code n Line numbering. You can add line numbers next to your code. Here's the style I liken lstsetnumbers=left numberstyle=footnotesize frame=l code nBe sure to check the documentation for lots more options and examples! 1