\selectcolormodel{gray} doesn't always work with tikzducks

\selectcolormodel works fine but tikz is doing a lot of color assignments by mapping internal commands with \let and this bypasses the color conversion in a number of cases. E.g. a color (or a command expanding to a color) used directly works, but not with the fill key. And \colorlet doesn't work either.

\documentclass{article}

\usepackage{tikz}

\begin{document}


    \textcolor{red}{RED}

    \selectcolormodel{gray} 
    Black and white version:

    \def\mycmdcolor{red}
    \colorlet{mynewletcolor}{red}    
    \definecolor{mynewdefcolor}{rgb}{1,0,0}


    \textcolor{red}{RED} 

    \textcolor{\mycmdcolor}{MYCMDCOLOR}

    \textcolor{mynewletcolor}{MYNEWLETCOLOR}

    \textcolor{mynewdefcolor}{MYNEWDEFCOLOR}


    \begin{tikzpicture}    


    \fill[\mycmdcolor] (0,0) rectangle (1,1);

    \draw[fill=\mycmdcolor] (2,0) rectangle (3,1);

    \draw[fill=mynewletcolor] (4,0) rectangle (5,1);        

    \draw[fill=mynewdefcolor] (6,0) rectangle (7,1);

    \end{tikzpicture}

\end{document}

enter image description here

Imho the only way out is to load xcolor directly with the gray model. Everything else is only curing the symptoms.


This seems to be a bug in tikz, see

  • Related question: \selectcolormodel{gray} not applied to \draw

  • Bug report: https://sourceforge.net/p/pgf/bugs/349/

I followed the advice of Ulrike Fischer and changed the code to avoid fill=.... It is fixed in version 0.3 and newer.

If you still encounter this problem, please update your tex distribution or get an up to date package version from https://www.ctan.org/pkg/tikzducks or https://github.com/samcarter/tikzducks