Minted is a great package for latex users to insert colorful code in the manuscript. But enabling minted in latex might not as easy as other packages. Here are some tips to save your time.
Installation & Configuration
Note: This guide is based on MacTex.
Import package
Import the minted package:
\usepackage[cache=false,outputdir=build]{minted}
Add –shell-escape option
Make sure you are adding the --shell-escape
option while building.
For example, if you are using the VS Code with latex-workshop, you have to add the --shell-escape
option in the setting:
"latex-workshop.latex.tools": [
{
"args": [
"--output-directory=build",
"-interaction=nonstopmode",
"-synctex=1",
"--shell-escape",
"%DOC%"
],
"command": "pdflatex",
"name": "pdflatex"
}
...
]
Install pygments
If you see the error “You must have `pygmentize’ installed to use this package”. You have to install the pygments.
For mac user:
brew install pygments