如何对齐框内的数学等式?

如何对齐框内的数学等式?

代码

 \[\boxed{\begin{split}
     3\mathrm{d}6 + \text{ability} + \text{skill} & \ge 10 + \text{ability} + \text{skill} \\
     &\text{or} \\
    3\mathrm{d}6 + \text{ability} + \text{skill} & \ge 10 + \text{ability} + 4 \\
     &\text{or} \\
    3\mathrm{d}6 + \text{ability} + 4 & \ge 10 + \text{ability} + \text{skill} \\
     &\text{or} \\
    3\mathrm{d}6 + \text{ability} + 4 & \ge 10 + \text{ability} + 4
 \end{split}}\]

作品。

但是代码

 \[\begin{split}
     \boxed{3\mathrm{d}6 + \text{ability} + \text{skill} & \ge 10 + \text{ability} + \text{skill}} \\
     &\text{or} \\
    \boxed{3\mathrm{d}6 + \text{ability} + \text{skill} & \ge 10 + \text{ability} + 4} \\
     &\text{or} \\
    \boxed{3\mathrm{d}6 + \text{ability} + 4 & \ge 10 + \text{ability} + \text{skill}} \\
     &\text{or} \\
    \boxed{3\mathrm{d}6 + \text{ability} + 4 & \ge 10 + \text{ability} + 4}
 \end{split}}\]

没有。

我怎样才能让它工作?

答案1

以下是一些选项:

在此处输入图片描述

\documentclass{article}

\usepackage{amsmath,eqparbox}

\begin{document}

\[
  \boxed{
    \begin{aligned}
      3\mathrm{d}6 + \text{ability} + \text{skill} & \ge 10 + \text{ability} + \text{skill} \\
        &\text{or} \\
      3\mathrm{d}6 + \text{ability} + \text{skill} & \ge 10 + \text{ability} + 4 \\
        &\text{or} \\
      3\mathrm{d}6 + \text{ability} + 4 & \ge 10 + \text{ability} + \text{skill} \\
        &\text{or} \\
      3\mathrm{d}6 + \text{ability} + 4 & \ge 10 + \text{ability} + 4
    \end{aligned}
  }
\]

\begin{gather*}
  \boxed{\eqmakebox[LHS][r]{$3\mathrm{d}6 + \text{ability} + \text{skill}$}
    \eqmakebox[RHS][l]{${}\geq 10 + \text{ability} + \text{skill}$}} \\
    \text{or} \\
  \boxed{\eqmakebox[LHS][r]{$3\mathrm{d}6 + \text{ability} + \text{skill}$} 
    \eqmakebox[RHS][l]{${}\geq 10 + \text{ability} + 4$}} \\
    \text{or} \\
  \boxed{\eqmakebox[LHS][r]{$3\mathrm{d}6 + \text{ability} + 4$}
    \eqmakebox[RHS][l]{${}\geq 10 + \text{ability} + \text{skill}$}} \\
    \text{or} \\
  \boxed{\eqmakebox[LHS][r]{$3\mathrm{d}6 + \text{ability} + 4$}
    \eqmakebox[RHS][l]{${}\geq 10 + \text{ability} + 4$}}
\end{gather*}

\newlength{\LHSlong}\newlength{\LHSshort}%
\newlength{\RHSlong}\newlength{\RHSshort}%
\newcommand{\LHSfill}{\hspace*{\dimexpr\LHSlong-\LHSshort}}%
\newcommand{\RHSfill}{\hspace*{\dimexpr\RHSlong-\RHSshort}}%
\settowidth{\LHSlong}{$3\mathrm{d}6 + \text{ability} + \text{skill}$}%
\settowidth{\RHSlong}{${}\geq 10 + \text{ability} + \text{skill}$}%
\settowidth{\LHSshort}{$3\mathrm{d}6 + \text{ability} + 4$}%
\settowidth{\RHSshort}{${}\geq 10 + \text{ability} + 4$}%
\begin{gather*}
  \boxed{3\mathrm{d}6 + \text{ability} + \text{skill} \geq 10 + \text{ability} + \text{skill}} \\
    \text{or} \\
  \boxed{3\mathrm{d}6 + \text{ability} + \text{skill} \geq 10 + \text{ability} + 4} \RHSfill \\
    \text{or} \\
  \LHSfill\boxed{3\mathrm{d}6 + \text{ability} + 4 \geq 10 + \text{ability} + \text{skill}} \\
    \text{or} \\
  \LHSfill\boxed{3\mathrm{d}6 + \text{ability} + 4 \geq 10 + \text{ability} + 4}\RHSfill
\end{gather*}

\end{document}

最后一个选项依赖于这样一个事实:您的构造似乎是确定性的,具有两个固定的Left/ RightHSides。因此,我们能够测量它们的宽度并使用它来校正太短的方程边。

相关内容