![使用 empheq 包对带框的多行方程进行行号编号会留下额外的空白](https://linux22.com/image/332807/%E4%BD%BF%E7%94%A8%20empheq%20%E5%8C%85%E5%AF%B9%E5%B8%A6%E6%A1%86%E7%9A%84%E5%A4%9A%E8%A1%8C%E6%96%B9%E7%A8%8B%E8%BF%9B%E8%A1%8C%E8%A1%8C%E5%8F%B7%E7%BC%96%E5%8F%B7%E4%BC%9A%E7%95%99%E4%B8%8B%E9%A2%9D%E5%A4%96%E7%9A%84%E7%A9%BA%E7%99%BD.png)
我使用 empheq 包将跨越多行的方程式放在方框内(使用 align)。方程式有 6 行,整个方框应接收一个数字 (1),为此我\nonumber \\
在其他 5 行上使用命令。如果方程式相对较窄,这种方法有效。
但是,如果方程很宽,行号会放在方框下方,但会包含额外的空白行(我认为是 6 行,与方程的数量一样多)。我怎样才能让方程号直接位于方框方程的下方(右侧)?
\documentclass[11pt]{article}
\usepackage{empheq}
\newcommand*\widefbox[1]{\fbox{\hspace{2em}#1\hspace{2em}}}
\begin{document}
\begin{empheq}[box=\widefbox]{align}
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz
\end{empheq}
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm
\end{document}
结果:
另一种修改是让第一行不包含\nonumber \\
命令,在这种情况下行号会上移,但到下一行仍然会有多余的空白。
\begin{empheq}[box=\widefbox]{align}
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz \dots abcdefghijklmnopqrstuvwxyz \nonumber
\end{empheq}
结果:
谢谢!
答案1
问题部分来自于您的盒子比\linewidth
– 更宽,并且可能存在错误。我建议,本着@Barbara Beeton 评论的精神,用\widefbox
一个简单的\boxed
命令和一个alignedat
环境来模仿您:
\documentclass[11pt]{article}
\usepackage{showframe}
\usepackage{empheq}
\newcommand*\widefbox[1]{\fbox{\hspace{1em}#1\hspace{1em}}}
\begin{document}
\begin{equation}%
\boxed{\qquad \begin{alignedat}{2} & abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz & \qquad & \\
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \\
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \\
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \\
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \\
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz
\end{alignedat}}
\end{equation}
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm
\end{document}
但是,如果您不使用边注,我建议您加载geometry
使用更合理边距的包:
\documentclass[11pt]{article}
\usepackage[showframe]{geometry}
\usepackage{empheq}
\newcommand*\widefbox[1]{\fbox{\hspace{2em}#1\hspace{2em}}}
\begin{document}
\begin{empheq}[box=\widefbox]{align}
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz \nonumber \\
& abcdefghijklmnopqrstuvwxyz ... abcdefghijklmnopqrstuvwxyz
\end{empheq}
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm
\end{document}}