General ⇒ Box around equations spanning several lines?
Box around equations spanning several lines?
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!
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!
NEW: TikZ book now 40% off at Amazon.com for a short time.
Re: Box around equations spanning several lines?
The empheq package, from the mh bundle, can do that, and much more.
B.A.
B.A.
Box around equations spanning several lines?
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
by writing
Compare also the following groups of formulas.
This example also shows how to add some space between the frame and the formulas.
Code: Select all
\begin{align*}
E&=mc^2 \\
b^2&=a^2+2\int_a^b x\,dx
\end{align*}
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*}
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}
Re: Box around equations spanning several lines?
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.
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.
Box around equations spanning several lines?
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 formulasby writingCode: Select all
\begin{align*} E&=mc^2 \\ b^2&=a^2+2\int_a^b x\,dx \end{align*}
Compare also the following groups of formulas.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*}
This example also shows how to add some space between the frame and the 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}
Neat!!!!

Thanks for posting this!!
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Box around equations spanning several lines?
Using the empheq package looks much more simpler to me. Nevertheless it is good to know that there are alternatives.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. [...]
Best regards
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Box around equations spanning several lines?
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.
-- 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.