To my readers who didn't come upon this article through google, the minted package is a better alternative to the listings package. Minted allows you to present code in techno-color! This means the programs you have worked hard on, like:
With minted your code will finally be noticed in the appendix of that report...
Disclaimer: Minted can do many things, but it will not make bad programs work. Though it will make them look like they could work.
The Setup
1. Make sure you have MacPorts and LaTeX installed.2. Install Python. If you don't have it installed already, here is an example of how you would install Python 2.7 with MacPorts in the terminal:
3. Install the proper Pygments package. For continuity, I'm going to show how to do this with the version of Python installed in step 2. In the terminal type the following:
4. Finally, create a soft link from the Pygments package to your /usr/local/bin folder and the setup is complete.
The Usage
Let's run some examples! One of the basic examples provided in the minted documentation is called minimal.tex. If you are feeling lazy, you can download it from here. The TeX file contains the first program everyone writes in C:The minted documentation assumes that you are compiling minimal.tex in the terminal. If this is true, to compile minimal.tex you need only to send this command:
Now typeset it! Both methods should result in a PDF containing:
FYI, If you use Kile the way to set up the pdflatex flag is to go to Tools > Configure Kile > Tools > Build > PDFLaTeX and add '-shell-escape' to the 'Options:' box.
ReplyDeleteThanks for the tip!
DeleteThank You So Much for this! Very clear and really helped me out!
ReplyDeleteThere's a typo in your sample latex document:
ReplyDelete`\begin{documents}` should be `\begin{document}`
Other than that, great job. This helped me get my system up and running.