# How to set a certain color (other than white) to margin areas?

I want to set a certain color to the margin areas (which is the region outside the content box of \textwidth by \textheight but inside the paper of course :-) ).

How to change this from within the latex document as opposed to change the geometry.sty?

• The entire margins or just part thereof? – Joseph Wright Dec 25 '10 at 13:32
• @Joseph, all pages on the document. – xport Dec 25 '10 at 13:34
• @Joseph, More precisely, all margins (left,right,top, bottom) for all pages on the document. Margin areas = Paper area minus content area. – xport Dec 25 '10 at 14:40
• you have to redefine the two/three rule commands from geometry. – user2478 Dec 25 '10 at 17:38

And here an example without pstricks:

\documentclass[12pt]{article}
\usepackage{geometry}
\usepackage{eso-pic,xcolor,lipsum}
\pagecolor{red}
\AtTextLowerLeft{\color{white}%
\rule[-\footskip]{\textwidth}{\dimexpr\textheight+\footskip}}}
\begin{document}
\lipsum
\end{document}

• Thanks, worked for me. To include the footer area, do \rule{\textwidth}{\textheight}. – Richard Hansen Apr 12 '14 at 21:32
• This exactly answers the question, thank you. – Peter Flynn May 16 at 14:54

In ConTeXt, this can be done using

\setupbackgrounds[page][background=color,backgroundcolor=red]
\setupbackgrounds[text][background=color,backgroundcolor=white]


The first line sets the background color of the entire page to red, and the second line sets the background color of the text area to white.

Here is a variant with pstricks and eso-pic packages:

\usepackage{calc}
\usepackage{pstricks}
\usepackage[texcoord]{eso-pic}

% ...

\newdimen\botX
\newdimen\rightY

\setlength{\botX}{\paperwidth-1.3in}
\setlength{\rightY}{-\paperheight+1.3in}

\psframe[
linewidth=0pt,linecolor=lightgray,
fillstyle=solid,fillcolor=lightgray]
(0,0)(\paperwidth,-\paperheight)
\psframe[
linewidth=0pt,linecolor=white,
fillstyle=solid,fillcolor=white]
(1.3in,-1.3in)(\botX,\rightY)
}


It would be better to ask TeX for exact margins (in example above i took exact margins i've provided to geometry package).

On the other hand --- it's possible to make shaded area smaller or like that. Round corner, let's say .-)