# 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
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.7300205826759338, "perplexity": 1208.0320097600545}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2020-10/segments/1581875143373.18/warc/CC-MAIN-20200217205657-20200217235657-00290.warc.gz"}