6

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\\
   \begin{equation}
        \lim_{n\to \infty} (x_n  + y_n) = a + b
   \end{equation}\\
   Text is here\\   \hline
   Text is here\\
   \begin{equation}
        \lim_{n\to \infty} (x_n  \cdot y_n) = a \cdot b
   \end{equation}\\  \hline
\end{tabular}
Ethan Bolker
  • 9,333
  • 3
  • 42
  • 69
Skaiste
  • 63

3 Answers3

11

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]
\begin{equation}
\lim_{n\to \infty} (x_n  + y_n) = a + b
\end{equation}
\lipsum[3]
\end{frametext}

\lipsum[1]

\end{document} 

Output:

enter image description here

If you instead want a complete box, remove the lines

topline = false,
bottomline = false,

from the definition of frametext.

enter image description here

karlkoeller
  • 124,410
5

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]
\begin{equation}
\lim_{n\to \infty} (x_n  + y_n) = a + b
\end{equation}
\lipsum[6]
}}

\lipsum[2]
\end{document}

enter image description here

Sigur
  • 37,330
  • 3
    @Skaiste Note that page breaks can not occur within a \parbox, take a look at mdframed, e.g. http://tex.stackexchange.com/questions/36524/how-to-put-a-framed-box-around-text-math-enviroment/36528#36528 for a solution that allows page breaks. – Torbjørn T. Jan 04 '14 at 15:22
5

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.

David Carlisle
  • 757,742