# Box around every page body

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.

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:

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

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

It can also be done with no packages.

\documentclass{article}

\ifodd\value{page}
{\fbox{\rule{0pt}{\textheight}\rule{\textwidth}{0pt}}}
\else