# Invert Background and Text Colours across Whole Document with pdflatex

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.

\documentclass{article}
\usepackage{xcolor}

\pagecolor[rgb]{0.5,0.5,0.5}
\color[rgb]{1,1,1}
\begin{document}

Hello \clearpage World

\end{document}

• Problems if you have some red, blue, ... text, figures, ... and what you want is to invert everything. :( Feb 17 '14 at 11:50
• This will not work on the color of Enumerate section 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.
• For which OS does this work? 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
\newcommand{\setbackgroundcolour}{\pagecolor[rgb]{0.19,0.19,0.19}}
\newcommand{\settextcolour}{\color[rgb]{0.77,0.77,0.77}}
\newcommand{\invertbackgroundtext}{\setbackgroundcolour\settextcolour}

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


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.