19

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

19

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}
  • 3
    Problems if you have some red, blue, ... text, figures, ... and what you want is to invert everything. :( – Andrestand Feb 17 '14 at 11:50
7

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. ;) – loved.by.Jesus Jul 31 at 9:57
0

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.

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.