Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

Boxed Page

share|improve this question
    
Have a look at package mdframed. –  Johannes_B Mar 22 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 at 13:07

2 Answers 2

up vote 4 down vote accepted

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}

\newcommand{\addframe}{%
  \AddToShipoutPicture{%
  \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}
\addframe
\lipsum[1-10]
\clearpage
\removeframe
\lipsum[1-10]
\clearpage
\addframe
\lipsum[1-10]
\end{document} 

Output:

enter image description here

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}

\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}%
}

\usepackage{lipsum} % just for the example

\begin{document}
\addframe
\lipsum[1-10]
\clearpage
\lipsum[1-10]
\clearpage
\addframe
\lipsum[1-10]
\end{document} 
share|improve this answer
    
@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 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 at 16:26
    
@Rob Happy to help :-) –  karlkoeller Mar 22 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}
share|improve this answer
    
Seems i slightly missread your question –  Johannes_B Mar 22 at 13:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.