I want to use the beamer package with a white on black style to create presentations. I included a simple switch to choose black on white for printout. Is there any possibility to also invert the colors of included graphics (maybe only black on white) or define some substitution rules for colors in included graphics?

  • Which picture format do you use? Commented Nov 8, 2011 at 13:44
  • I use PDF where possible, PNG otherwise.
    – bnord
    Commented Nov 8, 2011 at 14:09
  • 1
    I don't think you can change all colors of an included PDF or PNG. Maybe there is some color filter setting available in the PDF standard, but I would simply invert the images manually and then use conditionals to include either the one set of the other. Commented Nov 8, 2011 at 14:33
  • 1
    Take a look also at tex.stackexchange.com/questions/3322/…
    – Joseph Wright
    Commented Nov 8, 2011 at 14:36
  • I guess you can do some imageMagick magic by calling the externam tool if some switch is set. From what I know LaTeX uses pictures without actually doing anything with them so picture manipulations are not possible internally
    – Martin H
    Commented Nov 8, 2011 at 14:36

4 Answers 4


If you use PNG or another bitmap file, you can preprocess your file with Imagemagick.

convert -negate in.png out.png

This also works for PDFs. However, the vector data is rasterised and that's not what you aim for.


You can preprocess the file with inkscape. Load the pdf file, then select Extensions → Colour → Negative, and the paper size of the size of your imported PDF. This yields a non-rasterised, inverted PDF.

  • Using convert for png's works just fine but what Inkscape does with my imported PDFs is not useable.
    – bnord
    Commented Nov 9, 2011 at 7:54
  • You don't describe what unusable is. But keep in mind that a white parts in PDFs are often not white, but transparent. They have to be transformed to black.
    – Marco
    Commented Nov 9, 2011 at 10:18
  • Yes sorry, as a test I imported a PDF generated by graphviz (dot) and one by mathematica, all the text was replaced by some cryptic symbols, changing the import settings didn't help. Of course I can change that in dot but I was looking for a robust way working with more or less arbitrary input.
    – bnord
    Commented Nov 9, 2011 at 14:33

One can use:

\includegraphics[width=4cm,decodearray={1 0 1 0 1 0}]{images/amande_noir.png}

decodearray basically takes for each color component (here RGB, so 3) a tupple (a,b): 0 in the original image is mapped to a, and 1 in the original image is mapped to b:

enter image description here

(if your image is cmyk or grayscale, you need to adapt the number of tupples)

MWE amande_noir.png:

\includegraphics[width=2cm,decodearray={1 0 1 0 1 0}]{example-image-a.png}
  • Please include a small, but compilable test file in your answer. If a future user faces a problem with your answer, a compilable test file will help them determine if they might be using the solution incorrectly or if something changed in the mean time. Commented Jul 10 at 11:48
  • @samcarter_is_at_topanswers.xyz done, not sure why it fails with example-image-a
    – tobiasBora
    Commented Jul 10 at 12:41
  • @ tobiasBora Thanks! Commented Jul 10 at 12:46
  • 1
    It works fine with \includegraphics[width=2cm,decodearray={1 0 1 0 1 0}]{example-image-a.png} Commented Jul 10 at 12:47
  • 1
    Without the extension, pdflatex will default to example-image-a.pdf Commented Jul 10 at 19:47

Not a LaTeX solution but AFAIK FoxIt Reader can change colors at the preferences: edit → preferences → document colors. Adobe Reader has Edit → Preferences → Accessibility → Replace Document Colors. And at the internet I found that Mac OSX can invert the whole sceen with CTRL-OPT-CMD-8.


If you use METAPOST to generate graphics, then you can use metafun to change the color. See Section 8.5 of the metafun manual, which has an example of converting a colored image to black and white at the end of the section (on page 205).

  • Some time ago I tried to use this mechnism to process files converted to mp by pstoedit, but the compilation failed with errors (I don't recall what the issue was). Seems that mp is picky about the input.
    – Marco
    Commented Nov 9, 2011 at 11:41
  • @Marco: I have only rried this with hand written metapost. If you can find the offending image that failed, it might be worthwhile to file a bug report.
    – Aditya
    Commented Nov 9, 2011 at 14:32

You must log in to answer this question.

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