[Tex/LaTex] ! LaTeX Error: Undefined color `BLACK’


i have written all the text in black color, but i get this error several times in the same page:

! LaTeX Error: Undefined color `BLACK'.

i tried to solve it by writting this: \definecolor{black}{gray}{0,0,0} but it didnĀ“t work.

what should i do?

Best Answer

Very likely the color setting is inside a section (or friend) title and the title goes into the header with uppercase letters. \MakeUppercase (or \uppercase) does not know the semantics of arguments, it just converts all letters to uppercase: \textcolor{black}{hello} becomes \textcolor{BLACK}{HELLO}.


  • Providing a definition for the uppercase color name:

  • Using a command to hide the string "black":


    \DeclareRobustCommand protects \textblack from expanding inside \MakeUppercase to dispose and uppercase "black" in \textcolor{black} again.

BTW: \definecolor{black}{gray}{0,0,0} is not correct, because color model gray only expects one number: \definecolor{black}{gray}{0}.