# How can I add words to minted for highlighting? [duplicate]

I use minted for syntax highlighting

If I give it this C code

int foo () {
return 123;
}

int bar () {
int x = foo ();
++x;
}


it will colour-highlight foo in the first line, but later when foo is called in the body of bar, it will not be coloured.

How can I add foo to minted's dictionary so that it will be highlighted everywhere that it appears? Similarly, how can I add the variable x to the dictionary so that it will be highlighted in the line ++x?

The minimum requirement is that all minted usages (\begin{minted} or \inputminted) will use the same dictionary of function/variable names (per language).

Ideally, code such as \definecfunction{foo} could appear anywhere in the document (repeatedly), and all minted usages everywhere would pick it up (presumably this would be a two-pass process). Non-ideally, a full list of symbols could be provided in advance.

How can I make this happen?

• the highlighting is done by the pygments library, using the pygmentize command line, so the natural place to customise anything is there, not in the tex – David Carlisle Jan 30 '17 at 16:39
• – gernot Jan 30 '17 at 16:56