I am writing a book and would like to put a red, 5pt thick frame around all pages, except around one page in the middle of the book, which contains a figure that is bigger than the frame.

The frame should be placed 1cm above the upper text margin, 1cm under the bottom margin and 1.5cm from the left and right margins; it should not suround the header or the footer, which both should be just outside the frame.

I am using XeLaTeX, but have not descided if I am going to use the memoir or the KOMA-script class for the book. It might depend on this answer.

  • Welcome to TeX.SX. – Claudio Fiandrino Feb 10 '13 at 17:38
  • Welcome to TeX.SE. Just a remark: your figure should not exceed the printing area of the page, i.e. the text body + header + footer + margin notes area. – yo' Feb 10 '13 at 17:39
  • Please read the related links on the right first. – kiss my armpit Feb 10 '13 at 17:44
  • I have looked at other posts, I still can't draw a border that satisfies my specified distance from the text. I tried pgfpages, but it shrinks the text and puts the border outside the header and footer. I think tikz is what I need, but I am not sure how to make a border around all pages with it. – user25750 Feb 10 '13 at 19:52
  • @tohecz I want to turn of the frame on one page. The picture is not really bigger than the printing area, I just tried to keep the question as general as possible. – user25750 Feb 10 '13 at 19:57

Here's a self-documented fully working code. You should of course set up your desired headers (fancyhdr package) and page geometry (geometry package). The code strongly relies on package fancyhdr and keeping the center head empty!



% the head clashes with the box, so we change the page geometry


% we use center head to place the box in it
  \smash{% occupy no vertical space
    \raise\dimexpr-\headsep-\textheight-1cm\relax% move down by text heiht + head sep + 1cm so that it sits 1cm below the text
    \hbox to 0pt{% start a box occupying zero space
      \color{red}% colour
      \fboxsep0pt % \fbox should not add any extra spacing
      \fboxrule5pt % line width
      \hss\fbox{% \hss is infinitely shrinkable space
        % phantom rule occupying exactly the right space:
        % width of the text + 2*1.5cm
        % height of the text + 2*1cm

\fancyhead[R]{\thepage} % print the page number in the right head

\pagestyle{fancy} % use the newly defined style

% new style {nofancy}
  \ps@@fancy % copy the default {fancy} style
  \fancyhead[C]{} % make the center head empty




  • Very grateful for your help! However, this code fails to draw a frame around the first page of a new chapter, which has a special header/footer style. – user25750 Feb 13 '13 at 21:21
  • Please edit your question and add a Minimal Working Example. Then I'll be able to modify the solution so that it suits exacttly your situation. – yo' Feb 13 '13 at 22:06

Redefining the current \fbox to use different margins allows to use the simple \fancypage command from the package fancybox



\thisfancypage{}{}% no frame
  • 1
    This method puts all text into a box, which influence the marigins. It might work, but I am afraid the code is too advanced for me. – user25750 Feb 13 '13 at 21:23
  • @user25750: it does not influence the margins and it only redefines the current \fbox command, that's all. – user2478 Feb 14 '13 at 8:40

I experimented a bit and found a solution using the background and tikz packages. I still don't understand how the position option works in the background package - I am not sure from where to where it measures. By playing around with the parameters, I found this solution:

\draw [ultra thick] (0,0) rectangle (0.75\textwidth,0.73\textheight);
\draw [ultra thick] rectangle (0.75\textwidth,0.73\textheight);

It still remains to work out how to turn off the background when not needed.

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.