Add to latexmk black&white output version

I want to generate a colored and a black & white version of my latex document. Is it possible to configure latexmk via a latexmkrc file to do so?

Output folder should contain two pdf files.

Alternatively, does there a PDF-Viewer exist, which allow to preview the document in black & white?

• I do not know latexmkrc files but maybe my answer here (tex.stackexchange.com/a/122395) is of interest. I always set my conditional manually and run LaTeX again. You could do a bw.tex and a color.tex both including \newif\ifcolor \colortrue %\colorfalse \input{main.tex} (and vice versa) and than you configure something like pdflatex bw.tex color.tex and get two PDFs at once. – LaRiFaRi Jun 12 '15 at 11:43

Write a file called bw.cfg and containing

\PassOptionsToPackage{monochrome}{xcolor}

and modify your main file to have

\InputIfFileExists{bw.cfg}{}{}

before the call to xcolor. For printing in colors just rename the file.

Full test document.

\documentclass{article}

\InputIfFileExists{bw.cfg}{}{}
\usepackage{xcolor}

\begin{document}

Black \textcolor{red}{Red}
\textcolor{blue}{Blue}

\end{document}

Here's the output when latexmk -g -pdf testcolor is run and the configuration file is found.

Upon renaming bw.cfg to bw.cfg-disabled the output is

Note the -g option to force full compilation. You need it only when changing the color option, of course.

You can use the -jobname option to make latexmk produce a differently named PDF file. A shell script doing the two runs of latexmk (with renaming of the .cfg file) is the easiest way to get two PDF files.