I have a VHDL code which I want to insert into my latex document.
I need a package that takes care of syntax highlighting, indentation etc.
Is there a package which serves this purpose?
[Tex/LaTex] Rendering VHDL in latex
codelistingspackagesrendering
Best Answer
The
minted
package includes support for VHDL code. It uses the Python module Pygments to provide syntax highlighting, and Pygments supports VHDL.1Once it’s installed, you get syntax highlighting, which can be configured in lots of ways (see the package documentation). You'll also need to use the
-shell-escape
flag when you run the file, since LaTeX is calling an external program (Pygments) to do the highlighting.You can either type (VHDL) code directly into the document, using
\begin{minted}{vhdl} ... \end{minted}
or use\inputminted{vhdl}{somefile.vhdl}
to include code from an external file:Here's a minimal example:
I'd never heard of VHDL before, so the example code is taken from the Wikipedia page for VHDL.
This is what you get with those default settings:
The documentation (available on GitHub) goes into much more detail about how to customise the syntax highlighting, style, layout and so on.
1 You can check if a language is supported by Pygments by running
at a command line and inspecting the output. Running on my machine, I get this (as part of a much longer output):