跨多个比对的 aboxed

跨多个比对的 aboxed

我想将最后一行全部放在一个方框中,但编译时,它只将第一个方程式放在方框中,甚至不打印第二个方程式。有人知道如何解决这个问题吗?

这是我的 MWE。

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{mathtools}

\begin{document}

\begin{alignat*}{3}
    \left| x \right. & \left. - 2 \right| & &=1 &\\
    x - 2 &= 1& &\text{ or } & x - 2 &= -1\\
    \Aboxed{x &= 3& &\text{ or }& x &= 1}
\end{alignat*}

\end{document}

我本来想附上一张它生成的图像,但由于我是新用户,所以它不允许我附上。:)

答案1

可以手动创建一个正确宽度的框来跨越最后一行的条目:

在此处输入图片描述

\documentclass[12pt]{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}

\begin{alignat*}{3}
  \left| x \right. & \left. - 2 \right| & &=1 &\\
  x - 2 &= 1& &\text{ or } & x - 2 &= -1\\
  \rlap{\kern\dimexpr-\fboxsep-\fboxrule\relax\fbox{\phantom{$x=3\text{ or\ \ }x - 2 = 1$}}}% Phantom box
  x &= 3& &\text{ or }& x &= 1
\end{alignat*}

\end{document}​

这里的方法是创建一个带有虚假(或\phantom)内容的框,该框与通过 生成的输出相匹配alignat*。 Minor \kerning 允许根据\fbox分离(\fboxsep)和规则宽度(\fboxrule)进行适当的放置。

相关内容