Boxes – How to Draw a Box Around Every Page Body in LaTeX

boxesframegeometry

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.

Best Answer

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

\documentclass{article}
\usepackage{tikzpagenodes}
\usepackage[contents={}]{background}
\AddEverypageHook{%
  \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;
  }
}

\begin{document}
Hello
\newpage
Hello
\end{document}

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