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?

  • 1
    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
    Commented Jun 12, 2015 at 11:43

1 Answer 1


Write a file called bw.cfg and containing


and modify your main file to have


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

Full test document.




Black \textcolor{red}{Red}


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

enter image description here

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

enter image description here

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .