To add syntax-highlighted code in LaTeX, use the listings package or minted (which calls Pygments). Set the language, import files, and caption code blocks.