When using pdflatex is there a simple way to invert the colors to give white text on a black background across the whole document? I'd like the colours to be inverted whilst I write and edit the document, and then to be able to switch back to black text on a white background for the final version


You can do this with the xcolor package.



Hello \clearpage World

  • 4
    Problems if you have some red, blue, ... text, figures, ... and what you want is to invert everything. :(
    – Andrestand
    Feb 17 '14 at 11:50
  • This will not work on the color of Enumerate section
    – Gur Telem
    Jun 24 '20 at 21:08

As no LaTeX solution:

  • If you use evince as pdf viewer you can simply press Ctrl+I to invert any document. It will keep that setting for just that document even if you change and reload the document.
  • Yo can use xcalib -i -a to invert a whole screen.
  • 1
    For which OS does this work?
    – doncherry
    Feb 5 '12 at 8:36
  • @doncherry certainly for xubuntu 16.04. ;) Jul 31 '19 at 9:57

I recommend a more understandable way to write it using commands, based in the words of Lamport, "The LaTeX commands describe the logical structure of a Document' (See LaTeX - User's Guide and Reference Manual, Sect 2.2).

%Commands definitions

%Command execution. 
%If this line is commented, then the appearance remains as usual.

A bit more work, but a more readable document. Moreover, when you do not want to change the colours, you have only to comment out the command \invertbackgroundtext

Note: instead of 0.5 and 1, I used 0.19 for background and 0.77 for text—I think these colours give a lesser eye strain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.