john mangual john mangual - 2 months ago 12
LaTeX Question

code defining colors in LaTeX

I am looking for the TeX source code for the

function call in the
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.


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.