# Optimising TikZ pictures for greyscale printing

I often use colours in my TikZ pictures. Are there simple ways to make versions of these that will come out looking good if I print them on a B&W printer?

For example, say I have some filled regions in my picture, can I change them into cross-hatched or dotted regions consistently and easily? Ideally I'd like some option I can pass to the the tikzpicture environment which would reinterpret the colour for filled regions not as a colour, but as some crosshatching or small dots type filling...

-

You could create you own styles (e.g. afill, bfill, …) and apply them to the area you want to fill. Then you're able to change the style globally or you make two definition files (one for BW and the other for color printing) and you can choose the style by loading one of them vie \include

Indeed that’ll work only for new pictures, but maybe your editor allows searching for fill=red and replace it by afill or something like that

Here’s an example:

% make the definition files (this way just for the example)
\begin{filecontents}{color.tkz}
\tikzset{%
afill/.style={fill=red},
bfill/.style={fill=blue},
}
\endinput
\end{filecontents}
\begin{filecontents}{bw.tkz}
\usetikzlibrary{patterns}
\tikzset{%
afill/.style={draw,pattern=crosshatch},
bfill/.style={draw,pattern=crosshatch dots},
}
\endinput
\end{filecontents}

% document begins here ...
\documentclass{minimal}

\usepackage{tikz}
\input{color.tkz}% or \input{bw.tkz}

\begin{document}
\begin{tikzpicture}
\path [afill] (0,0) rectangle (2,2);
\path [bfill] (3,0) rectangle (5,2);
\end{tikzpicture}
\end{document}


wich gives either

or

Normally you would make the definitions files by hand. And you can save them in your local texmf-tree to use them with more than one document.

PS: I don’t like cross-hached area an prefer simple grey scales for printing in BW. In this case one can change the definition of the used colors to change them to a grey scale … See the PGF manual, p. 89, last item before section 7.7

Do not use background patterns, like a crosshatch or diagonal lines, instead of colors. They distract. Background patterns in information graphics are evil.

-
I agree that cross hatching isn't nice, but there's only so many distinctions of grey that people can make out so it's nice to have the possibility sometimes. Especially if you want to have one area over another so part of the crosshatched area is grey background and the other part is white... –  Seamus Jun 4 '11 at 17:11
@Seamus: Certainly you can have more real colors than you have with a grey scale but I think that good graphics/graphs/charts (not images) only need a few colors (black, white and maximum two other colors/greys) to keep clear. Otherwise the reader may sees a colorful painting without recognizing it’s meaning. –  Tobi Jun 5 '11 at 9:37
Do not exclude colorblind! Always add another way to differentiate things. –  Paul Gaborit Jun 11 '12 at 16:53

To change the colors in my documentations, I define colors in the preamble or a file for configuration. It's possible with a "if" structure to choice between to set of colors. I don't test the next code but it's the idea.

\newif\ifgraystyle \graystylefalse % true

\ifgraystyle
\def\backgroundone{gray!20}
\def\backgroundtwo{gray!50}
\else
\def\backgroundone{blue}
\def\backgroundtwo{red}
\fi

\tikzset{%
afill/.style={fill=\backgroundone},
bfill/.style={fill=\backgroundtwo},
}

-
If you use \definecolor instead of storing a string to a macro with \def you could use the colors in text to—I guess … –  Tobi Jun 4 '11 at 16:37
I prefer keep \definecolor to the names of the colors and to use \def for the color of an object : example \def\background{myred} I use \definecolorfor myred and not for \background but it's perhaps not relevant. –  Alain Matthes Jun 4 '11 at 17:36
OK, I thought that \background won’t work in some cases (e.g. \color{\background}) but it seems to work too. So it’s just a question of the users preference. For me background ist a color like myred and not a command so I’ll use \definecolor :-) –  Tobi Jun 5 '11 at 9:33