Define the color command

color

How can I bind this to another command?

\definecolor{thisismycolor}{rgb}{0.012,0.11,0.5}

Normally:

\draw[color=thisismycolor]

But, I want this:

\draw[color=mycolor]

So i want to connect thisismycolor and mycolor

For example:

\newcommand{\mycolor}{\thisismycolor} but dont work

In summary: When \thisismycolor changes as let the \mycolor change too.

Best Answer

Rather than a simple \colorlet{newcolor}{existingcolor}, which will allow a new color to be defined in terms of existing color(s) (see Shades of colors, Defining a Color using another), it seems the OP wants a shortcut for a long color name. In particular the desire seems to be that, when the longcolorname changes, the shorthand will change with it.

If this is the case, then \colorlet{newcolor}{existingcolor} will not suffice, as the color known as newcolor will not revise itself when existingcolor gets subsequently updated. Indeed, a \colorlet is a one-time assignment, but not a "linkage". After the \colorlet is executed, a change in the specification of existingcolor will, by design, have no effect on the specification of newcolor.

In that case, use a shorthand macro to refer to the long name, in the manner of \newcommand\mycolor{thisismycolor}. This way, you can refer to \mycolor whenever a color is called for, and it will take on the current value of thisismycolor. The key here to understanding is that the color that is defined is thisismycolor. The term \mycolor is not, itself, a color, but merely a macro that gets replaced with a color name.

\documentclass{article}
\usepackage{xcolor}
\colorlet{thisismycolor}{red!80!cyan}
\newcommand\mycolor{thisismycolor}
\begin{document}
\textcolor{\mycolor}{A Test}

\colorlet{thisismycolor}{green!50!cyan}
\textcolor{\mycolor}{A Test}
\end{document}

enter image description here