# Equations in a box - table doesn't work

I want to put some limit equations in a table but all I get are errors such as "! Missing \$ inserted." and "! You can't use \eqno' in math mode.". Am I doing something wrong or is there another way to do this. This is what I have:

\begin{tabular}{| l |}  \hline
Text is here\\
$$\lim_{n\to \infty} (x_n + y_n) = a + b$$\\
Text is here\\   \hline
Text is here\\
$$\lim_{n\to \infty} (x_n \cdot y_n) = a \cdot b$$\\  \hline
\end{tabular}

-

If you only want a left and a right vertical line to emphasize that text, you can use the mdframed package.

In this particular case, I've defined a new environment frametext to achieve that (it has also the advantage to go over page breaks)

\newmdenv[%
leftmargin = -10pt,
rightmargin = -10pt,
topline = false,
bottomline = false,
linewidth = 0.4pt
]{frametext}


Full MWE

\documentclass{article}

\usepackage[framemethod=TikZ]{mdframed}

\usepackage{lipsum} % just for the example

\newmdenv[%
leftmargin = -10pt,
rightmargin = -10pt,
topline = false,
bottomline = false,
linewidth = 0.4pt
]{frametext}

\begin{document}

\section{1st}

\lipsum[1]

\section{2nd}

\lipsum[1]

\begin{frametext}
\lipsum[2]
$$\lim_{n\to \infty} (x_n + y_n) = a + b$$
\lipsum[3]
\end{frametext}

\lipsum[1]

\end{document}


Output:

If you instead want a complete box, remove the lines

topline = false,
bottomline = false,


from the definition of frametext.

-

If you want a box around some text you can use the following (of course, it is possible to make a more flexible code):

\documentclass{article}
\usepackage{lipsum} %% for dummy text
\usepackage{calc}
\begin{document}
\lipsum[1]

\noindent\fbox{%
\parbox[t]{\linewidth-2\fboxsep-2\fboxrule}{%
\lipsum[4]
$$\lim_{n\to \infty} (x_n + y_n) = a + b$$
\lipsum[6]
}}

\lipsum[2]
\end{document}


-
Thank you, that is exactly what I needed! –  Skaiste Jan 4 '14 at 15:03
@Skaiste Note that page breaks can not occur within a \parbox, take a look at mdframed, e.g. tex.stackexchange.com/questions/36524/… for a solution that allows page breaks. –  Torbjørn T. Jan 4 '14 at 15:22

equation is a display environment so has to be used in vertical (par) mode you can not use it in horizontal (LR) mode. using equation in an l column is like using it in an \mbox and you get the same error in either case. You need a p column which is a \parbox and equation` will then work, just as in the other answer which uses an explicit parbox.

-