GeneralBox around equations spanning several lines?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
nrqed
Posts: 5
Joined: Mon Jan 21, 2008 1:38 am

Box around equations spanning several lines?

Post by nrqed »

How can one draw a box around multiline equations?
For single line equations, \boxed works great. But I haven't been able to figure out how to use it for multiline equations. Is there any way to use \boxed then? Or any other method?


Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

balf
Posts: 158
Joined: Sat Jan 12, 2008 1:11 am

Re: Box around equations spanning several lines?

Post by balf »

The empheq package, from the mh bundle, can do that, and much more.

B.A.
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Box around equations spanning several lines?

Post by Juanjo »

Thanks, balf, for bringing to my attention the empheq package. I didn't know it. After a quick review, it seems great and very useful. Anyway, there are simple alternatives to frame multiline formulas provided that they are not numbered or there are just one centered equation number for the whole set of formulas. For example, we can frame the formulas

Code: Select all

\begin{align*}
   E&=mc^2 \\
   b^2&=a^2+2\int_a^b x\,dx
\end{align*}
by writing

Code: Select all

\begin{equation*}
   \boxed{
   \begin{aligned}
      E&=mc^2 \\
      b^2&=a^2+2\int_a^b x\,dx
   \end{aligned}
   }
\end{equation*}
Compare also the following groups of formulas.

Code: Select all

\begin{gather}
   E=mc^2 \notag \\
   b^2=a^2+2\int_a^b x\,dx \\
   (a+b)^n=\sum_{k=0}^n\binom{n}{k}a^{n-k}b^k \notag
\end{gather}

\begin{equation}
  \addtolength{\fboxsep}{5pt}
   \boxed{
   \begin{gathered}
      E=mc^2 \\
      b^2=a^2+2\int_a^b x\,dx \\
      (a+b)^n=\sum_{k=0}^n\binom{n}{k}a^{n-k}b^k
   \end{gathered}
   }
\end{equation}
This example also shows how to add some space between the frame and the formulas.
nrqed
Posts: 5
Joined: Mon Jan 21, 2008 1:38 am

Re: Box around equations spanning several lines?

Post by nrqed »

Thanks! The empheq package of the mh bundle does exactly what I need.

But I still need help. I have downloaded and extracted the mh bundle on my (Windows) machine. I have MikTeX 2.5 and TeXnicCenter installed. What must I do so that I can start using the empheq package in TeXnicCenter? I don't know where to put my mh bundle and what to do so that I will be able to use empheq in TeXnicCenter.

Thanks again.
nrqed
Posts: 5
Joined: Mon Jan 21, 2008 1:38 am

Box around equations spanning several lines?

Post by nrqed »

Juanjo wrote:Thanks, balf, for bringing to my attention the empheq package. I didn't know it. After a quick review, it seems great and very useful. Anyway, there are simple alternatives to frame multiline formulas provided that they are not numbered or there are just one centered equation number for the whole set of formulas. For example, we can frame the formulas

Code: Select all

\begin{align*}
   E&=mc^2 \\
   b^2&=a^2+2\int_a^b x\,dx
\end{align*}
by writing

Code: Select all

\begin{equation*}
   \boxed{
   \begin{aligned}
      E&=mc^2 \\
      b^2&=a^2+2\int_a^b x\,dx
   \end{aligned}
   }
\end{equation*}
Compare also the following groups of formulas.

Code: Select all

\begin{gather}
   E=mc^2 \notag \\
   b^2=a^2+2\int_a^b x\,dx \\
   (a+b)^n=\sum_{k=0}^n\binom{n}{k}a^{n-k}b^k \notag
\end{gather}

\begin{equation}
  \addtolength{\fboxsep}{5pt}
   \boxed{
   \begin{gathered}
      E=mc^2 \\
      b^2=a^2+2\int_a^b x\,dx \\
      (a+b)^n=\sum_{k=0}^n\binom{n}{k}a^{n-k}b^k
   \end{gathered}
   }
\end{equation}
This example also shows how to add some space between the frame and the formulas.

Neat!!!! :D

Thanks for posting this!!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Box around equations spanning several lines?

Post by localghost »

Juanjo wrote:[...] Anyway, there are simple alternatives to frame multiline formulas provided that they are not numbered or there are just one centered equation number for the whole set of formulas. [...]
Using the empheq package looks much more simpler to me. Nevertheless it is good to know that there are alternatives.


Best regards
Thorsten
balf
Posts: 158
Joined: Sat Jan 12, 2008 1:11 am

Re: Box around equations spanning several lines?

Post by balf »

You shouldn't download any package that is in The MiKTeX distribution (that is, almost every package): you download and install it with miktex's package manager (mpm). For other packages: you should install them manually, respecting the TDS hierarchy, preferably in a TeXMFlocal directory (declared as the root of a texmf hierarchy via miktex'ssettings). Here's an example: shortlst is not a part of miktex. I've installed:
-- shortlst.sty in ...\TeXMFlocal\tex\latex\shortlst\
-- the docs in ...\TeXMFlocal\doc\latex\shortlst\
and then refreshed the FNDB with miktex's settings.

Btw, miktex 2.5 should now be updated to miktex 2.7! It is not supported any more.

Regards,
B.A.
Post Reply