1

What if I want to set a padding around the page body (on all pages), draw a frame/border around it, and then add some margin?

The geometry package doesn't seem to have an option for this among its basic options because it doesn't separate padding and margin.

(I'm asking this question about the whole page body, rather than about a box explicitly coded in the sources.

I'm dealing with LaTeX.)

What I want to achieve -- each page is printed like this:

>outer margin< | >left<  >mpwidth< >text body< >right< | >outer margin<
               |                     ......            |
               |                    Text text          |         
               |         marginpar  Text text          |         
               |                    Text text          |         
               |                     ......            |

Then, I'd also like to change the color of the frame depending on the text (with a command from the text). The frame/border style could be fancier than just a plain rule/line. The piece inside the frame is like a complete customizable page layout: a custom left margin width, a custom right margin width, and a custom marginpar width. This doesn't cross the frame. The frame is at a fixed distance from the edge of the paper ("outer margin").

  • tikzpagenodes provides hooks into locations around the page for drawing a frame. What do you mean by "[adding] some margin"? – Werner Jul 05 '13 at 21:40
  • Can you upload a small picture showing what do you want to achieve? – Marco Daniel Jul 05 '13 at 21:40
  • 1
    Hmm, actually, there have been almost identical questions (some of them with good answers): http://tex.stackexchange.com/questions/801/what-is-the-easiest-way-to-get-borders-around-a-page-in-latex?rq=1 , http://tex.stackexchange.com/questions/15052/draw-true-page-border , http://tex.stackexchange.com/questions/73480/how-to-set-colored-ruled-margins-for-different-pages , http://tex.stackexchange.com/questions/97594/put-a-frame-around-all-pages-except-one-in-a-book , http://tex.stackexchange.com/q/73611/3463 , http://tex.stackexchange.com/q/57444/3463 , http://tex.stackexchange.com/q/18851/3463 – imz -- Ivan Zakharyaschev Jul 05 '13 at 21:41
  • @Werner By "adding margin" I meant giving an explict value for the margin between the frame/border and the edge of the paper. – imz -- Ivan Zakharyaschev Jul 05 '13 at 21:42
  • @Marco I've plotted the layout I'm talking about. – imz -- Ivan Zakharyaschev Jul 05 '13 at 21:51
  • @imz--IvanZakharyaschev: If one of the questions you linked answers your question, feel free to cast the first close vote. – Werner Jul 05 '13 at 21:56
  • @Werner Perhaps, I'll try to make use of some of the methods mentioned there first. – imz -- Ivan Zakharyaschev Jul 05 '13 at 22:02

1 Answers1

3

I think the package background in combination with tikzpagenodes is a good choise.

As a starting point you can use:

Add background colour to margin notes area

However there is one disclaimer. The package background can change the color of the frame only for the whole page.

Here an example where you can control the distance between the frame and the text by the new two dimensions \xinnersep and \yinnersep:

\documentclass{book}
\usepackage{tikzpagenodes}
\usepackage{background}
\usepackage{lipsum}
\newlength{\xinnersep}
\setlength{\xinnersep}{1.5cm}
\newlength{\yinnersep}
\setlength{\yinnersep}{0.5cm}
\backgroundsetup{
scale=1,
angle=0,
contents={%
 \begin{tikzpicture}[remember picture,overlay]
  \draw[blue,line width=2pt,] ([xshift=-\xinnersep,yshift=\yinnersep]current page text area.north west) --
                                             ([xshift=\xinnersep,yshift=\yinnersep]current page text area.north east) -- 
                                             ([xshift=\xinnersep,yshift=-\yinnersep]current page text area.south east) -- 
                                             ([xshift=-\xinnersep,yshift=-\yinnersep]current page text area.south west) -- cycle;
 \end{tikzpicture}%
}}

\begin{document}
\lipsum[1-15]
\end{document}
Marco Daniel
  • 95,681