Colorize numbers in lstlisting (latex) -
i want know if possible colorize numbers in lstlisting package latex. example want numbers in red, 0x0f (hex) , 0b00001111 (bin):
void setapwm2(unsigned char porcento) {   //100 * 256 = 25.600   unsigned int val = porcento * pr2;   val /= 25;   //garante que tem apenas 10 bits   val &= 0x03ff;   //os 8 primeiros bits são colocados no ccpr1l   ccpr2l = val >> 2;   //os últimos dois são colocados na posição 5 e 4 ccp1con   ccp2con |= (val & 0b00001111) << 4; } if there no way, there other package can it?
ps: i'm working c language. thanks
minted uses python library (pygments) , can kind of highlighting latex able understand code , not keywords listings does.
at least hex supported directly, in pygments demo fails binary numbers , fine if add on line highlighter code (probably regexp similar 1 parses hex).
edit:
in pygments\lexers\compiled.py line 60 has:
(r'0x[0-9a-fa-f]+[ll]?', number.hex), which parses hex c. add below (r'0b[0-1]+[ll]?', number.hex), (using number.hex because otherwise need add number.bin tokes.py or something).
Comments
Post a Comment