I have the following code in my latex command .
\newcommand{\color}[1]{\lceil (#1+2)^2/2\rceil}
After that I have inserted the following command for insertion of code in LATEX documents .
\usepackage{listings}
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{frame=tb,
language=Java,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
basicstyle={\small\ttfamily},
numbers=none,
numberstyle=\tiny\color{gray},
keywordstyle=\color{blue},
commentstyle=\color{dkgreen},
stringstyle=\color{mauve},
breaklines=true,
breakatwhitespace=true
tabsize=3
}
But TEXMAKER compiler shows me error that command \color
is already defined. Why does compiler show error for insertion of these code ? Can you suggest me an way to solve this issue ?
\color
is already defined by the packagecolor
orxcolor
which is either included by you or by another package you used. If you explicitly want the command\color
as in your example, you must redefine it via\renewcommand
, but I do not recommend this. Chose another command name instead, please\color
, since it is used/defined by thecolor
package. Strange though, your command\color
doesn't even use anything related to colour... so why not define it as\mycommand
?\color
, then add\let\color\relax
immediately after loading it. Then you can go ahead and\usepackage{color}
as you already do.