# Is there any easy way to put boxes around text of selected pages with the page number below the box?

I'd like to be able to create boxes around a whole page or selection of pages with the box extending the full length of the page but with the bottom edge of the box above the page number as in the attached example. It would be ideal if this could be defined as an environment so that all pages in that environment are boxed. This environment could be used to set an executive summary off from the rest of the document.

Any hints or suggestions would be much appreciated.

• Have a look at package mdframed. – Johannes_B Mar 22 '14 at 12:41
• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – karlkoeller Mar 22 '14 at 13:07

With tikz and eso-pic. I've defined two commands, \addframe and \removeframe which, respectively, add the frame and remove the frame in the page.

MWE:

\documentclass{article}

\usepackage{tikzpagenodes}
\usetikzlibrary{calc}

\usepackage{eso-pic}

\begin{tikzpicture}[remember picture, overlay]
\draw[line width=1pt]
($(current page text area.north west) +(-5mm,5mm)$)
rectangle
($(current page text area.south east) +(5mm,-5mm)$);
\end{tikzpicture}%
}%
}

\newcommand{\removeframe}{\ClearShipoutPicture}

\usepackage{lipsum} % just for the example

\begin{document}
\lipsum[1-10]
\clearpage
\removeframe
\lipsum[1-10]
\clearpage
\lipsum[1-10]
\end{document}


Output:

You can adjust the parameters (1pt for the thickness and 5mm for the distance from the text) as you want.

Alternatively, you can define \addframe in this way

\newcommand{\addframe}{%
\begin{tikzpicture}[remember picture, overlay]
\draw[line width=1pt]
($(current page text area.north west) +(-5mm,5mm)$)
rectangle
($(current page text area.south east) +(5mm,-5mm)$);
\end{tikzpicture}%
}


and use \addframe in every page where you need the frame, as in the following MWE:

\documentclass{article}

\usepackage{tikzpagenodes}
\usetikzlibrary{calc}

\begin{tikzpicture}[remember picture, overlay]
\draw[line width=1pt]
($(current page text area.north west) +(-5mm,5mm)$)
rectangle
($(current page text area.south east) +(5mm,-5mm)$);
\end{tikzpicture}%
}

\usepackage{lipsum} % just for the example

\begin{document}
\lipsum[1-10]
\clearpage
\lipsum[1-10]
\clearpage
\lipsum[1-10]
\end{document}

• @HarishKumar I know, but since the OP have mentioned "selection of pages" I thought this is the best solution... Anyway, I've added the alternative. – karlkoeller Mar 22 '14 at 15:54
• The selection of pages was important--the ability to just put the command at the beginning of all text that should be boxed (which could run for multiple pages) is very helpful and picked up in the first solution (which I thought was great) – Rob Mar 22 '14 at 16:26
• @Rob Happy to help :-) – karlkoeller Mar 22 '14 at 17:05

You can use package mdframed to do this. mdframed is very customizable, you can define a backgroundcolor and much more things.

If you want your boxes to appear everywere using the same style, best practice is to define a new environment with newmdenv, setinng some style options. In this case, the standard is used, a single frame around the box. You can later overrule the settings locally by giving options to the environment, as seen in the second example.

\documentclass{article}
\usepackage{mdframed}
\newmdenv{boxed}
\usepackage{blindtext}
\begin{document}
\blindtext
\begin{boxed}
\blindtext

\blindtext
\begin{description}
\item [something] \blindtext
\item [something else] \blindtext[2]
\end{description}
\end{boxed}

\blindtext

\begin{boxed}[backgroundcolor=yellow]
\blindtext
\end{boxed}
\end{document}

• Seems i slightly missread your question – Johannes_B Mar 22 '14 at 13:59