# Creating an environment able to span over multiple pages or columns

I'm trying to create an environment able to understand when it's on a single/two columns layout and to span over multiple pages or columns having different style for the two cases. I would want to obtain something like this example:

http://dl.dropbox.com/u/9439473/share/target.pdf

I tried framed and mdframed package but they seem not to be quite configurable for my needs and seem to have problems with 2-columns layout. Can you advise me a quite configurable package which can do what i need (see the attachment) or if not, is there a command which i can use to understand when i reached the end of page or column?

To solve my problem I'm trying to use TikZ nodes to create the frame, and i would understand when it's time to go on the next page/column to create a new node and put there the following text, but i don't know how to create the partially dashed line on corners, and how to detect the end of page or column. Any suggestion?

-
Mmm, see my answer to Test if a paragraph has a page break in it? which is somehow similar to what you want. It could be used to create some style like the one in your example file. – Martin Scharrer Jul 2 '11 at 15:34

It is also possible to raise the lines with package xhfill

\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}

\usepackage{mdframed,xcolor}
\newcounter{example}
\newenvironment{example}
{\begin{mdframed}[linewidth=2,
backgroundcolor=black!15,
skipbelow=\baselineskip,
skipabove=\baselineskip]
\refstepcounter{example}
\hrulefill~Example~\theexample~\hrulefill\par}
{\par\noindent\hrulefill\par\end{mdframed}}

\begin{document}
\blindtext
\begin{example}
\blindtext
\end{example}
\blindtext

\end{document}


-