6

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?

Display Name
  • 46,933

3 Answers3

10

And here an example without pstricks:

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

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.

Aditya
  • 62,301
  • But I am not using ConTeXt. – Display Name Dec 30 '10 at 12:22
  • 4
    I posted the ConTeXt solution in case some ConTeXt user wants to achieve the same effect. See the discussion at [http://meta.tex.stackexchange.com/questions/524/why-are-there-so-few-context-questions/532#532](the meta site) – Aditya Dec 30 '10 at 12:39
0

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}

\AddToShipoutPicture{%
  \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 .-)

brownian
  • 529