# Framebox and minipage causes white space and is not float

I have a \framebox (I don't insist on using this command) and a minipage that causes whitespace, because the drawn box is not allowing any text before or after and it itself does not break over pages. The code looks like this:

\framebox{%
\begin{minipage}{\textwidth}
\begin{center}
Title Goes Here
\end{center}
Contents go here
\end{minipage}
}


Am I using the correct command? If so, how can I break it over pages? or if it is not possible to break it, I must give it a label and caption (just like a table or figure) and make it inline with text so that I can refer it in the article, but I don't know that either.

-
use package mdframed. See documentation on how it has to be used –  Herbert May 26 '11 at 10:27
Thanks. That's it. Would you please state it as an answer so that I can mark it as correct answer. –  Yasser Sobhdel May 26 '11 at 10:44
Is there anything like it for blocks of math (I mean between two $, like$\phi^\rho\$ and so). When such a block reaches end of line, it goes further to margins and I must correct it manually. Is there a way to correct it another way? –  Yasser Sobhdel May 26 '11 at 10:46
I don't get "the drawn box is not allowing any text before or after". This is not the behaviour of \framebox. –  Martin Scharrer May 26 '11 at 11:01
I mean the box is larger than half of the page, and it causes the previous page to have white spaces. and it starts at the beginning of next page. –  Yasser Sobhdel May 26 '11 at 13:42

Something you can also give a try is this code from the memoir manual for a framed environment with a caption. It can break across pages and gives a continuation caption. It can also be referred to with a \ref

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

\usepackage{framed}
\makeatletter
\newcommand\framename{Frame}
\newcounter{framecnt}
\setcounter{framecnt}{0}
\newcommand{\TitleFrame}[2]{%
\fboxrule=\FrameRule
\fboxsep=\FrameSep
\vbox{\nobreak \vskip -0.7\FrameSep
\rlap{\strut#1}\nobreak\nointerlineskip% left justified
\vskip 0.7\FrameSep
\noindent\fbox{#2}}}
\newenvironment{titledframe}[2][\FrameFirst@Lab\ (cont.)]{%
\refstepcounter{framecnt}%
\def\FrameFirst@Lab{\textbf{\framename\ \theframecnt:\ #2}}%
\def\FrameCont@Lab{\textbf{#1}}%
\def\FrameCommand##1{%
\TitleFrame{\FrameFirst@Lab}{##1}}%
\def\FirstFrameCommand##1{%
\TitleFrame{\FrameFirst@Lab}{##1}}%
\def\MidFrameCommand##1{%
\TitleFrame{\FrameCont@Lab}{##1}}%
\def\LastFrameCommand##1{%
\TitleFrame{\FrameCont@Lab}{##1}}%
\MakeFramed{\hsize\textwidth
\FrameRestore}}%
{\endMakeFramed}
\makeatother

\begin{document}
\begin{titledframe}{A titled frame}\label{frm:A}
\blindtext[6]
\end{titledframe}

\begin{titledframe}{A New frame}\label{frm:B}
\blindtext[1]
\end{titledframe}
In frames~\ref{frm:A} and \ref{frm:B}
\end{document}

-
Do you know anything for formulae, is it possible to have an script or so t automatically break the formula to the next line when it is exceeding the usual length and entering the margin? –  Yasser Sobhdel May 26 '11 at 15:16
@Yasser Sobhdel: No unfortunately not. There are a lot of rules regarding where to break a single equation into multi-line ones. I think it is very close to impossible to automate that. –  Danie Els May 26 '11 at 15:20