I am defining page margins with geometry, adding a footer and header. I want the body of the text (not the footer or header) to be enclosed in a box (every page).

This is a similar question to What is the easiest way to get borders around a page in LaTeX? and other that I found, but them all are planned for a full border around the whole page (for cropping needs, for instance).

Suggestions are welcome.

2 Answers 2


Not sure if this is the best solution, but the tikzpagenodes provides tikz anchors for each block (text, footer, header...) and background provides \AddEverypageHook to add text on every page. Combining the two gives:

enter image description here

  \tikz[remember picture,overlay]{
    \draw (current page text area.north east) -- (current page text area.north west)
          -- (current page text area.south west) -- (current page text area.south east) -- cycle;


By adding options to the tikz drawing, you can easily customize it with dashed lines, colors…

  • Perfect. As you say, there might be a cleaner solution, but for me it works great. Thanks
    – Alberto
    Sep 21, 2021 at 14:00

It can also be done with no packages.


    \put({\dimexpr 1in+\oddsidemargin-\fboxrule},{\dimexpr -1in-\topmargin-\headheight-\headsep-\textheight-\fboxrule})%
    \put({\dimexpr 1in+\evensidemargin-\fboxrule},{\dimexpr -1in-\topmargin-\headheight-\headsep-\textheight-\fboxrule})%


\noindent\verb|\fboxsep| = \the\fboxsep
  • Nice suggestion....
    – MadyYuvi
    Sep 21, 2021 at 15:17
  • How to exclude the first page?
    – Stephen
    Jun 8, 2023 at 8:02
  • @Stephen - \ifnum\value{page}=1\else ... \fi Jun 8, 2023 at 12:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .