[Tex/LaTex] Changing Colors of Document

color

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.

Best Answer

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}