General ⇒ Box around equations spanning several lines?
Box around equations spanning several lines?
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!
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Re: Box around equations spanning several lines?
B.A.
Box around equations spanning several lines?
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?
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
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Box around equations spanning several lines?
-- 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.