9

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?

  • Are you using this in a sectional title (perhaps a chapter/section heading)? – Werner Jul 3 '14 at 22:32
  • 1
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – egreg Jul 3 '14 at 22:37
  • 1
    following @MaxD, did you (in particular) type \color{BLACK} anywhere. if so, try using the word in lower-case. – wasteofspace Jul 3 '14 at 22:47
  • 2
    load the package xcolor in your preamble and write \definecolor{BLACK}{named}{black} below that. This should define your BLACK colour somewhere in your code as the normal black you would suspect. Like this you can use BLACK everywhere and change it's grayscale or whatever later on. This is my preferred way to handle colours. – LaRiFaRi Jul 3 '14 at 22:51
  • 1
    If you've written all your text in black, I'm not sure why you need to specify this at all. Black is the default. Obviously if you changed to some other colour, you'd need black to change back. But if the text is all in black, you shouldn't need to do anything. What am I missing here? – cfr Jul 3 '14 at 23:22
14

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}.

Workarounds:

  • Providing a definition for the uppercase color name:

    \documentclass{article}
    \usepackage{xcolor}
    \colorlet{BLACK}{black}
    \pagestyle{headings}
    \begin{document}
    \section{\textcolor{black}{Hello}}
    \end{document}
    
  • Using a command to hide the string "black":

    \documentclass{article}
    \usepackage{color}
    \DeclareRobustCommand{\textblack}{\textcolor{black}}
    \pagestyle{headings}
    \begin{document}
    \section{\textblack{Hello}}
    \end{document}
    

    \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}.

| improve this answer | |
  • ok, thanks a lot! i selected all the document and did "text style - color: reset" – Emi Jul 4 '14 at 14:34
  • Absolutely clever! I had the same problem, but with color 'BLUE'... thanks! – Paglia Oct 23 '15 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.