# Coloring only the text area

I use the geometry package to define paper size and text area of a (one page) document:

\usepackage[
paperwidth=420mm,
paperheight=297mm,
text={365mm,270mm},
centering
]{geometry}


I wish to color the background of the specified text area. I use this.

\usepackage{color}
\pagecolor{magenta}


This, however, colors the whole paper (420*297 mm2), rather than just the text area (365*270 mm2).

How do I color only the text area?

You can use the tikzpagenodes package:

\documentclass{article}
\usepackage{tikzpagenodes}
\usepackage{lipsum}
\usepackage{showframe}

\newcommand\ColorTextArea{%
\begin{tikzpicture}[remember picture,overlay]
\fill[cyan!20]
(current page text area.north west) rectangle (current page text area.south east);
\end{tikzpicture}%
}
\begin{document}
\ColorTextArea
\lipsum[1-3]

\end{document}


The showframe package was only used to have some frames for the page layout to help visualization.

\ColorTextArea only affects the page in which it was invoked. If you want the effect for all the pages, use the atbegshi package:

\documentclass{article}
\usepackage{tikzpagenodes}
\usepackage{lipsum}
\usepackage{atbegshi}
\usepackage{showframe}

\newcommand\ColorTextArea{%
\begin{tikzpicture}[remember picture,overlay]
\fill[cyan!20]
(current page text area.north west) rectangle (current page text area.south east);
\end{tikzpicture}%
}

\AtBeginShipout{\ColorTextArea}
\AtBeginShipoutFirst{\ColorTextArea}

\begin{document}
\lipsum[1-40]

\end{document}


This way it is automatically done every page.

\documentclass{article}
\usepackage{everypage}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{calc}