I am looking for the TeX source code for the \color function call in the xcolor library which I am importing


{ \color{blue!60!white} abc }    


I am asking here rather than on tex.stackexchange because I am asking for the programming rather than just the tex commands. In theory, this is working TeX code and I should just move on.

  • 2
    You have a strange idea about what is on topic here.
    – cfr
    Nov 20 '16 at 4:25

Technically, if you're just interested in what \color does, then you can issue


in your document and check your .log:

> \color =\long macro:
->\@ifnextchar [\@undeclaredcolor \@declaredcolor .

This works because \color is declared to be robust, otherwise issuing \show\color would have worked.

The code shows that \color conditions on whether or not the input stream contains [. That is,


would lead to executing \@undeclaredcolor, while calling


would lead to executing \@declaredcolor. In both cases, the {<colour>} argument is gobbled by either \@undeclaredcolor or \@declaredcolor.

If you wish to follow a more detailed path of macro execution and expansion, issuing the tracing command

\color{blue!60!white} abc }

would allow you to debug quite a bit, revealing a lengthy macro expansion pattern of about 800 lines as one follows deeper down the rabbit hole, starting, of course, with the \@ifnextchar condition mentioned above.




Not much to look at. Argument #3 seems to be the color. The last line looks most important.


Why do LaTeX internal commands have an @ in them?

  • Isn't this for a colour box rather than just a colour switch?
    – cfr
    Nov 20 '16 at 4:24

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.