# How to put a framed box around text + math enviroment

I am looking for something like \fbox but it seems that you cannot use it when a math environment is included. However its not only a math environment (then you could use \boxed I know) but also text, I need to be in a frame.

example:

\rdmframeboxaroundwhatever{

blablabla

\begin{align}
Formula of the universe
\end{align}

Hoaray

}

-

## migrated from stackoverflow.comNov 29 '11 at 14:33

This question came from our site for professional and enthusiast programmers.

Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. –  Torbjørn T. Nov 29 '11 at 15:03

Wrap the math and text in a minipage, then put that in the fbox:

\documentclass{minimal}

\begin{document}
\fbox{%
\begin{minipage}{4 in}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed fringilla
purus bibendum odio ultricies non bibendum massa condimentum. Morbi
scelerisque pulvinar quam, sed porta ipsum blandit ac.
$$\frac{Lorem}{Ipsum}=Do^2lr+\int_i^t\,d(amet)$$
Sed felis arcu, pretium ut vulputate at, feugiat vitae orci. In hac
habitasse platea dictumst. Integer mollis vulputate dui. Fusce
eget sollicitudin purus.
\end{minipage}}
\end{document}

-
This won't break across pages whereas the mdframed solution will. –  Seamus Nov 29 '11 at 16:30

You could take a look at mdframed, which also allows pagebreaks, and allows you to customize the look of the frame. A simple example, which puts a box similar to \fbox around the content.

\documentclass{article}
\usepackage{mdframed}
\usepackage{lipsum} % for creating dummy text

\begin{document}
\begin{mdframed}
\lipsum[1]
$$f(x) = \sin(x)$$
\lipsum[2]
\end{mdframed}
\end{document}


A second example, showing some more of what the package can do. See the manual for the full story.

\documentclass{article}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}
\mdfdefinestyle{MyFrame}{%
linecolor=blue,
outerlinewidth=2pt,
roundcorner=20pt,
innertopmargin=\baselineskip,
innerbottommargin=\baselineskip,
innerrightmargin=20pt,
innerleftmargin=20pt,
backgroundcolor=gray!50!white}

\begin{document}

\begin{mdframed}[style=MyFrame]
\lipsum[1]
$$f(x) = \sin(x)$$
\lipsum[2]
\end{mdframed}
\end{document}


-

My combination of a frame box and math (trying to align the formula vertically as well as horizontally - give more space when the math gets really tall and allow more room horizontally for better visual effect):

\framebox{

\parbox[t][1.0cm]{4.50cm}{

$p \;=\; -\, \dfrac{17}{23}\;;\; \quad q \;=\; \dfrac{10}{23}$

Tip: You can mark code sch as I did in my edit by either indenting it with four spaces, or selecting the block and clicking the button marked {} above the text field (keyboard shortcut, Ctrl + K). –  Torbjørn T. Nov 29 '11 at 15:37