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?

4
  • The entire margins or just part thereof?
    – Joseph Wright
    Dec 25, 2010 at 13:32
  • @Joseph, all pages on the document. Dec 25, 2010 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. Dec 25, 2010 at 14:40
  • you have to redefine the two/three rule commands from geometry.
    – user2478
    Dec 25, 2010 at 17:38

3 Answers 3

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}
2
  • Thanks, worked for me. To include the footer area, do \rule{\textwidth}{\textheight}. Apr 12, 2014 at 21:32
  • This exactly answers the question, thank you. May 16, 2020 at 14:54
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.

2
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 .-)

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.