我想在这最后两行周围加一个方框
\begin{equation}
\begin{split}
\left\langle\vec{u}\right\rangle&=\frac{1}{4}\Re\left(\epsilon_0\vec{\overset{\sim}{E}}\cdot\vec{\overset{\sim}{E}}^*+\frac{1}{\mu_0}\vec{\overset{\sim}{B}}\cdot\vec{\overset{\sim}{B}}^*\right) \\
&=\frac{1}{4}\left[\epsilon_0\left(\frac{\pi\omega B_0}{\left(\frac{\omega}{c}\right)^2-k^2}\right)^2\left[\left(\frac{n}{b}\right)^2\cos^2\left(\frac{m\pi}{a}x\right)\sin^2\left(\frac{n\pi}{b}y\right)+\left(\frac{m}{a}\right)^2\sin^2\left(\frac{m\pi}{a}x\right)\cos^2\left(\frac{n\pi}{b}y\right)\right]\right. \\
&\qquad+\frac{1}{\mu_0}\left(\frac{\pi kB_0}{\left(\frac{\omega}{c}\right)^2-k^2}\right)^2\left[\left(\frac{m}{a}\right)^2\sin^2\left(\frac{m\pi}{a}x\right)\cos^2\left(\frac{n\pi}{b}y\right)+\left(\frac{n}{b}\right)^2\cos^2\left(\frac{m\pi}{a}x\right)\sin^2\left(\frac{n\pi}{b}y\right)\right. \\
&\qquad\qquad\left.\left(\frac{\left(\frac{\omega}{c}\right)^2-k^2}{\pi k}\right)\cos^2\left(\frac{m\pi}{a}x\right)\cos^2\left(\frac{n\pi}{b}y\right)\right] \\
%Box starting here
&=\left(\frac{\pi B_0}{2\left[\left(\frac{\omega}{c}\right)^2-k^2\right]}\right)^2\left[\left(\epsilon_0\omega+\frac{k}{\mu_0}\right)\left[\left(\frac{n}{b}\right)^2\cos^2\left(\frac{m\pi}{a}x\right)\sin^2\left(\frac{n\pi}{b}y\right)\right.\right. \\
&\qquad\left.\left.+\left(\frac{m}{a}\right)^2\sin^2\left(\frac{m\pi}{a}x\right)\cos^2\left(\frac{n\pi}{b}y\right)\right]+\left(\frac{\left(\frac{\omega}{c}\right)^2-k^2}{\pi\mu_0k}\right)\cos^2\left(\frac{m\pi}{a}x\right)\cos^2\left(\frac{n\pi}{b}y\right)\right]
%and ending here
\end{split}
\end{equation}
\begin{equation}
\begin{split}
\left\langle\vec{S}\right\rangle&=\frac{1}{2\mu_0}\Re\left(\vec{\overset{\sim}{E}}\times\vec{\overset{\sim}{B}}^*\right) \\
&=\frac{1}{2\mu_0}\Re\left(\frac{i\pi B_0}{\left(\frac{\omega}{c}\right)^2-k^2}\left[\left\langle\frac{-n\omega}{b}\left[\cos\left(\frac{m\pi}{a}x\right)\sin\left(\frac{n\pi}{b}y\right)\right],\frac{m\omega}{a}\left[\sin\left(\frac{m\pi}{a}x\right)\cos\left(\frac{n\pi}{b}y\right)\right],0\right\rangle\right.\right. \\
&\qquad\times\left\langle\frac{mk}{a}\left[\sin\left(\frac{m\pi}{a}x\right)\cos\left(\frac{n\pi}{b}y\right)\right],\frac{nk}{b}\left[\cos\left(\frac{m\pi}{a}x\right)\sin\left(\frac{n\pi}{b}y\right)\right],\right. \\
&\qquad\qquad\left.\left.\left.\frac{-i\left[\left(\frac{\omega}{c}\right)^2-k^2\right]}{\pi}\cos\left(\frac{m\pi}{a}x\right)\cos\left(\frac{n\pi}{b}y\right)\right\rangle\right]\right) \\
&=\frac{1}{2\mu_0}\Re\left(\frac{i\pi B_0}{\left(\frac{\omega}{c}\right)^2-k^2}\left\langle\frac{-im\omega\left[\left(\frac{\omega}{c}\right)^2-k^2\right]}{\pi a}\sin\left(\frac{m\pi}{a}x\right)\cos\left(\frac{m\pi}{a}x\right)\cos^2\left(\frac{n\pi}{b}y\right),\right.\right. \\
&\qquad\frac{in\omega\left[\left(\frac{\omega}{c}\right)^2-k^2\right]}{\pi b}\cos^2\left(\frac{m\pi}{a}x\right)\sin\left(\frac{n\pi}{b}y\right)\cos\left(\frac{n\pi}{b}y\right), \frac{-n^2\omega k}{b^2}\left[\cos^2\left(\frac{m\pi}{a}x\right)\sin^2\left(\frac{n\pi}{b}y\right)\right] \\
&\qquad\qquad\left.\left.-\frac{m^2\omega k}{a^2}\left[\sin^2\left(\frac{m\pi}{a}x\right)\cos^2\left(\frac{n\pi}{b}y\right)\right]\right\rangle\right) \\
&\fbox{$=\frac{\omega B_0}{2\mu_0}\left\langle\frac{m}{a}\sin\left(\frac{m\pi}{a}x\right)\cos\left(\frac{m\pi}{a}x\right)\cos^2\left(\frac{n\pi}{b}y\right),\frac{n}{b}\cos^2\left(\frac{m\pi}{a}x\right)\sin\left(\frac{n\pi}{b}y\right)\cos\left(\frac{n\pi}{b}y\right),0\right\rangle$}
\end{split}
\end{equation}
答案1
该amsmath
包提供了一个宏,\boxed
专门用于此目的。请注意,我在指令aligned
内包含了一个环境\boxed
。我还用 替换了所有实例,\left(\frac{\omega}{c}\right)
以(\omega/c)
使公式看起来更紧凑。
在以下解决方案中,=
符号不在框内。如果它必须位于框内,则需要替换
%Box starting here
&=\boxed{\begin{aligned}[t]
&\biggl(\frac{\pi B_0}{2\left[(\omega/c)^2-k^2\right]}\biggr)^{\!2}
和
%Box starting here
&\boxed{\begin{aligned}
&=\biggl(\frac{\pi B_0}{2\left[(\omega/c)^2-k^2\right]}\biggr)^{\!2}
在下面给出的代码中。
\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry} % set page parameters appropriately
\usepackage{amsmath}
\usepackage{mleftright} % for tightly-spaced \left...\right constructs
\mleftright
\begin{document}
\begin{equation}
\begin{split}
\langle\vec{u}\mkern1.5mu\rangle
&=\frac{1}{4}\Re\Bigl( \epsilon_0\vec{\widetilde{E}}\cdot\vec{\widetilde{E}}^*
+\frac{1}{\mu_0}\vec{\widetilde{B}}\cdot\vec{\widetilde{B}}^* \Bigr) \\
&=\frac{1}{4}
\Biggl[
\epsilon_0
\left(\frac{\pi\omega B_0}{(\omega/c)^2-k^2}\right)^{\!2}
\left[\left(\frac{n}{b}\right)^2\cos^2
\left(\frac{m\pi}{a}x\right)\sin^2
\left(\frac{n\pi}{b}y\right)
+\left(\frac{m}{a}\right)^2\sin^2
\left(\frac{m\pi}{a}x\right)\cos^2
\left(\frac{n\pi}{b}y\right)\right] \\
&\qquad+\frac{1}{\mu_0}
\left(\frac{\pi kB_0}{(\omega/c)^2-k^2}\right)^{\!2}
\left[\left(\frac{m}{a}\right)^2\sin^2
\left(\frac{m\pi}{a}x\right)\cos^2
\left(\frac{n\pi}{b}y\right)
+\left(\frac{n}{b}\right)^2\cos^2
\left(\frac{m\pi}{a}x\right)\sin^2
\left(\frac{n\pi}{b}y\right)\right. \\
&\qquad\qquad
\left(\frac{(\omega/c)^2-k^2}{\pi k}\right)\cos^2
\left(\frac{m\pi}{a}x\right)\cos^2
\left(\frac{n\pi}{b}y\right)
\Biggr] \\
%Box starting here
&=\boxed{\begin{aligned}[t]
&\biggl(\frac{\pi B_0}{2\left[(\omega/c)^2-k^2\right]}\biggr)^{\!2}
\Biggl[
\left(\epsilon_0\omega+\frac{k}{\mu_0}\right)
\biggl[\left(\frac{n}{b}\right)^2\cos^2
\left(\frac{m\pi}{a}x\right)\sin^2
\left(\frac{n\pi}{b}y\right) \\
&\qquad+\left(\frac{m}{a}\right)^2\sin^2
\left(\frac{m\pi}{a}x\right)\cos^2
\left(\frac{n\pi}{b}y\right)\biggr]
+\left(\frac{(\omega/c)^2-k^2}{\pi\mu_0k}\right)\cos^2
\left(\frac{m\pi}{a}x\right)\cos^2
\left(\frac{n\pi}{b}y\right)
\Biggr]
\end{aligned}}
%and ending here
\end{split}
\end{equation}
\end{document}
答案2
\Aboxed
来自的命令允许mathtools
将对齐点包含在框架框中。为了包含多行,我使用multlined
来自同一包的环境, aligned
对于上面的行:
\documentclass{article}
\usepackage{geometry}
\usepackage{mathtools}
\begin{document}
\begin{equation}
\begin{split}
\left\langle\vec{u}\right\rangle&=\frac{1}{4}\Re\left(\epsilon_0\vec{\overset{\sim}{E}}\cdot\vec{\overset{\sim}{E}}^*+\frac{1}{\mu_0}\vec{\overset{\sim}{B}}\cdot\vec{\overset{\sim}{B}}^*\right) \\
&=\begin{alignedat}[t]{2} \frac{1}{4}\Biggl[& \epsilon_0\left(\frac{\pi\omega B_0}{\left(\frac{\omega}{c}\right)^2-k^2}\right)^{\mkern-5mu 2} \left[\left(\frac{n}{b}\right)^2\cos^2\left(\frac{m\pi}{a}x\right)\sin^2\left(\frac{n\pi}{b}y\right)+\left(\frac{m}{a}\right)^2\sin^2\left(\frac{m\pi}{a}x\right)\cos^2\left(\frac{n\pi}{b}y\right)\right] & & \\
& +\frac{1}{\mu_0}\left(\frac{\pi kB_0}{\left(\frac{\omega}{c}\right)^2 - k^2}\right)^{\mkern-5mu 2} \biggl[\left(\frac{m}{a}\right)^2\sin^2\left(\frac{m\pi}{a}x\right)\cos^2\left(\frac{n\pi}{b}y\right)\\%
& & \mathllap{+\left(\frac{n}{b}\right)^2\cos^2\left(\frac{m\pi}{a}x\right)\sin^2\left(\frac{n\pi}{b}y\right)
\left(\frac{\left(\frac{\omega}{c}\right)^2-k^2}{\pi k}\right)\cos^2\left(\frac{m\pi}{a}x\right)\cos^2\left(\frac{n\pi}{b}y\right)\Biggr]} &
\end{alignedat}\\
%Box starting here
\Aboxed{&=\begin{multlined}[t] \left(\frac{\pi B_0}{2\left[\left(\frac{\omega}{c}\right)^2-k^2\right]}\right)^{\mkern-5mu 2} \left[\left(\epsilon_0\omega+\frac{k}{\mu_0}\right)\left[\left(\frac{n}{b}\right)^2\cos^2\left(\frac{m\pi}{a}x\right)\sin^2\left(\frac{n\pi}{b}y\right)\right.\right. \\
\left.\left.+\left(\frac{m}{a}\right)^2\sin^2\left(\frac{m\pi}{a}x\right)\cos^2\left(\frac{n\pi}{b}y\right)\right]+\left(\frac{\left(\frac{\omega}{c}\right)^2-k^2}{\pi\mu_0k}\right)\cos^2\left(\frac{m\pi}{a}x\right)\cos^2\left(\frac{n\pi}{b}y\right)\right]
\end{multlined}}
%and ending here
\end{split}
\end{equation}
\end{document}