0

This question already has an answer here:

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?

marked as duplicate by gernot, Mensch, Stefan Pinnow, CarLaTeX, Maarten Dhondt Jan 30 '17 at 18:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Browse other questions tagged or ask your own question.