2

I have a many pdf documents written in standard LaTeX format. I was interested, is it possible to make my pages be black but my text be white? In other words, invert black/white, I am curious how nice it would look like.

4

Colors can be set via package color. It is important to set the color to white in the preamble. Then package color uses this color as \normalcolor. LaTeX uses this color at various places. For example, it resets the color in header and footers to make them independent from the color that is active at the time the output routine is called.

\documentclass{article}
\usepackage{blindtext}
\usepackage{color}
\pagecolor{black}
\color{white}

\begin{document}
\blinddocument
\end{document}

Page 1 Page 2 Page 3

Switching colors

Also the colors can be switched on a page level. Some pages can be put as white on black and others as black on white.

The page color can be turned off by \nopagecolor. This is only supported by few drivers (pdftex.def, dvips.def). For other drivers, \pagecolor{white} can be used.

The \normalcolor is more tricky, the following example hacks into the internals to define \whiteonblack and \blackonwhite, which also changes the \normalcolor accordingly.

\documentclass{article}
\usepackage{blindtext}
\usepackage{color}

\makeatletter
\let\default@color@black\current@color
\newcommand*{\blackonwhite}{%
  \newpage
  \let\default@color\default@color@black
  \normalcolor
  \@ifundefined{no@page@color}{%
    \pagecolor{white}%
  }{%
    \nopagecolor
  }%
}
\color{white}
\let\default@color@white\current@color
\newcommand*{\whiteonblack}{%
  \newpage
  \let\default@color\default@color@white
  \normalcolor
  \pagecolor{black}%
}
\pagecolor{black}
\makeatother

\begin{document}
\blinddocument
\blackonwhite \blinddocument
\whiteonblack \blinddocument
\end{document}
6
  • Thank you, but my page numbering disappears! (Presummably stays as black). – Nicolas Bourbaki Jun 24 '15 at 5:40
  • 1
    @NicolasBourbaki No, as you can see, the page numbers are correctly set in white. You have to move \color{white} to the preamble. See my updated answer with a little more explanation. – Heiko Oberdiek Jun 24 '15 at 5:46
  • @HeikoOberdiek \pagecolor command is from color package? – juanuni Jun 24 '15 at 5:57
  • @juanuni Yes, \pagecolor is defined in package color. It is supported in drivers pdftex.def, dvips.def, dvipdfmx.def, for example. – Heiko Oberdiek Jun 24 '15 at 6:01
  • @HeikoOberdiek thanks. Your solution makes all pages in color. There are something like \thispagecolor? (for a specific page) – juanuni Jun 24 '15 at 6:04
3

Try this:

\documentclass{article}
\usepackage{color,lipsum}
\pagecolor{black}
\color{white}

\begin{document}
\lipsum[2-4]
\end{document}

enter image description here

3
  • Thank you. Two problems. (i) I get a bunch of random words in the beginning. (ii) My page numbering disappears! – Nicolas Bourbaki Jun 24 '15 at 5:38
  • 1
    \color{white} should be moved before \begin{document}. Then this color becomes the \normalcolor instead of the default black and the page number will reappear as white on black. – Heiko Oberdiek Jun 24 '15 at 5:45
  • @Heiko Oberdiek Thank you for pointing out. Edited my answer for page number colour in white. – Ambika Vanchinathan Jun 24 '15 at 6:01

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.