I want to write C++ code in LaTeX using the listings
package. The problem is that I want to change the color numbers in code (integers, doubles...). The only solution I found was this:
\lstdefinestyle{customc}{
belowcaptionskip=1\baselineskip,
breaklines=true,
frame=L,
xleftmargin=\parindent,
showstringspaces=false,
basicstyle=\footnotesize\ttfamily,
language=C++,
morekeywords={Mat, cvtColor,one},
keywordstyle=\bfseries\color{green!40!black},
commentstyle=\itshape\color{purple!40!black},
stringstyle=\color{orange},
}
\lstset{literate=%
{0}{{{\color{red}0}}}1
{1}{{{\color{red}1}}}1
{2}{{{\color{red}2}}}1
{3}{{{\color{red}3}}}1
{4}{{{\color{red}4}}}1
{5}{{{\color{red}5}}}1
{6}{{{\color{red}6}}}1
{7}{{{\color{red}7}}}1
{8}{{{\color{red}8}}}1
{9}{{{\color{red}9}}}1
}
But this solution give me this:
Some numbers in variables are put in color too, but I don't want this. Someone knows another form of putting different color number in code?