# Providing alternate stroke styles for black and white printing in PDF

I would like to produce from LaTeX (MiKTeX, TeXnicCenter) both a black and white, and a colored version of my document. It contains vector graphics with several lines in one plot. In the color version, they should have different colors and solid strokes, while in the b&w version, they should have black color and different strokes.

Ideally, I would like to have a single PDF that contains both "styles" for different output methods, but I guess that PDF is not meant for that. I could not find any information on that. Maybe I just lack the proper search terms.

Is there a way to either produce one such document, or to compile two different PDF documents from one TeX source, possibly by only changing one option in its header? To be clear, I would like to avoid having two different TeX sources for the two styles.

Edit: I produce my EPS files via MATLAB R2010a export.

• This is an interesting question (+1) but you need to be very sure of what you're passing to the file. It's only going to annoy your readers if they print something and it's different to what's on screen. It also won't be easy to debug. Tricky PDF features are also not universally supported and can break accessibility. An anecdotal counterexample: You produce a user manual which uses similar colours for the screen version so provide a B&W print version of the figures inside. Your customer likes to read manuals on a kindle. – Chris H Sep 14 '15 at 15:46
• ... If you're thinking of submitting it to a publishing medium you don't control, it probably won't go smoothly either. – Chris H Sep 14 '15 at 15:47

This can be done with PDF Layers (OCGs). In the following example, using Adobe Reader for viewing and printing, different versions of image files are seen in the viewer and on paper after printing:

\documentclass{article}
\usepackage{ocgx2}
\usepackage{graphicx}
\usepackage{mwe}

%Usage: \includeGraphicsForPrintAndView[grx options]{grx for print}{grx for view}
\newcommand\includeGraphicsForPrintAndView[3][]{%
\begin{ocg}[viewocg=never, printocg=always]{black and white}{bwlayer}{1}%
\makebox[0pt][l]{\includegraphics[#1]{#2}}%
\end{ocg}%
\begin{ocg}[viewocg=always, printocg=never]{colour}{colorlayer}{1}%
\includegraphics[#1]{#3}%
\end{ocg}%
}

\begin{document}
\includeGraphicsForPrintAndView{example-image-a}{example-image-b}

\includeGraphicsForPrintAndView{example-image-c}{example-image}
\end{document}

• I would not have thought it possible. Thank you for your fine solution to my problem and the proper terms I was lacking. Heeding the advice given by @Chris H, I will investigate the options, the pros and cons and the possible pitfalls of PDF layers. – Douba Sep 14 '15 at 21:57