[Tex/LaTex] verbatim text with C code


I'm trying to typeset a lot of C code in the latest ConTeXt (MKIV). It tried:

    printf("Hello, world\n");

only to find that \startC macro is undefined. It is defined in verb-c.mkii.
I even tried to put

\input verb-c.mkii

before using \startC but it fails on another undefined macros. What is the proper way to typeset C? The manual recommends \startC but it doesn't state how to switch it on except of \definetyping (which doesn't hightlight the syntax).

It actually works in MKII version of ConTeXt but it fails in MKIV.

Best Answer

This ConTeXt Garden page lists the pret-c module. So the following should work.

\definetyping[C][option=C, tab=4] % defines \startC as shortcut for \starttyping[option=C]
\definetype[typeC][option=C, tab=4, style=tt] % defines \typeC

bla bla \typeC{int main(){}} bla bla
int foo = 42;

Maybe you need to install the module first:

tlmgr install context-C-Pretty-Printing
Related Question