Using xcolor I like to define a named color which actually does not change the current color. So \textcolor{mycolor}{text} should print text in the currently active color. In other words: I'm looking for a way to define a no-op color.
I'm not talking about the special color name '.', which refers to the currently used color. Using \colorlet{mycolor}{.} will simply define mycolor to the color used at that moment. However, having a names alias of '.' would do the trick.
About the background:
In my ydoc bundle which I used for the package manuals of mine I use predefined styles for certain repeatable used items. For example package names are formatted using \pkg{name} which uses \pkgstyle internally to format the name. This style macro uses, beside other things, the color pkg to color the package names. By default I do not want to have the package names colored in a different way, so the pkg is defined to be black. This is fine for normal, black text, but if \pkg is used inside a colored text the package names are still black. Some goes for all other macros like this which all use this generic set of macros.
My question is now if it is possible to define a named color with xcolor which actually does not change the current color. This would allow to disable the use of a special color without redefining the style macro to not include \textcolor. It would be nice if this special no-op color could be copied using \colorlet to other color names as well.
A MWE would be the following. The word 'test' should always have the same color as 'before' and 'after'. The definition of \myformat should not be changed, only the definition of mycolor.
\documentclass{article}
\usepackage{xcolor}
\colorlet{mycolor}{.}% Wanted: Always be the currently active color
\newcommand{\myformat}[1]{\textcolor{mycolor}{\ttfamily #1}}
\begin{document}
before \myformat{test} after
\color{blue}
before \myformat{test} after
\color{red}
before \myformat{test} after
\end{document}
.' cannot be used? – Leo Liu Nov 25 '11 at 17:37\textcolorto gobble its colour argument#1and only typeset the text part#2. And, this redefinition could be done within\myformatto localize it. – Werner Nov 25 '11 at 17:38\colorlet{mycolor}{.}in the definition of\myformat. So I still cannot understand your purpose. Is there any special reason makeydocprevent using such techniques? – Leo Liu Nov 25 '11 at 17:43pkgcolor to a specific color. So basically, if no color is defined I don't want a\textcolorto be used (or at least it should not do anything), but if a color it defined it should be used.\colorlet{mycolor}{.}would simply definemycolorto be the current color, like black, but if the color changes.would then be the new color, butmycolorwould still be black. – Martin Scharrer♦ Nov 25 '11 at 17:51