修复方程中的对齐问题

修复方程中的对齐问题

我希望获得比使用以下代码所获得的更典型的对齐(我希望这很明显):

\[                                                                                                                                                                           
 \hat\delta = \left \{                                                                                                                                                       
   \begin{array}{lr}                                                                                                                                                         
    \hat\delta(q_i, \epsilon) &= q_i \\                                                                                                                                      
    \hat\delta(q_i, ax) &= \hat\delta(\delta(q_i, a), x) : a\in\Sigma, x\in\Sigma^*                                                                                          
     \end{array}                                                                                                                                                             
   \right.                                                                                                                                                                   
\]

得出的结果为:奇怪的排列

看到上面的图片后,我认为很明显我希望将 = 符号和 q_i 移到对齐的左侧。我该如何实现呢?

谢谢大家的帮助!

答案1

我认为等号不应该对齐,所以一个简单的cases环境就足够了。不过,我还添加了“对齐”版本。

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\noindent
First attempt, like I would do it; there's
no need to align the equals signs:
\[
\hat\delta =
\begin{cases}
\hat\delta(q_i, \epsilon) = q_i, \\
\hat\delta(q_i, ax) = \hat\delta(\delta(q_i, a), x), & a\in\Sigma,\ x\in\Sigma^*
\end{cases}
\]
Second attempt, aligning the equals signs:
\[
\renewcommand{\arraystretch}{1.2}
\hat\delta =
\left\{
\begin{array}{@{}l@{}ll@{}}
\hat\delta(q_i, \epsilon) &{}= q_i, \\
\hat\delta(q_i, ax) &{}= \hat\delta(\delta(q_i, a), x), & a\in\Sigma,\ x\in\Sigma^*
\end{array}
\right.
\]
\end{document}

在此处输入图片描述

答案2

另一种可能性是

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{equation*}
  \hat\delta
  = \left\{
  \begin{aligned}
    \hat\delta(q_{i}, \epsilon)
      &= q_{i} \\
    \hat\delta(q_{i}, ax)
      &= \hat\delta(\delta(q_{i}, a),x)
         \qquad \text{for } a \in \Sigma, x \in \Sigma^{\ast}
  \end{aligned}
  \right.
\end{equation*}
or
\begin{equation*}
  \hat\delta
  = \left\{
  \begin{alignedat}{2}
    &\hat\delta(q_{i}, \epsilon)
      &&= q_{i} \\
    &\hat\delta(q_{i}, ax)
      &&= \hat\delta(\delta(q_{i}, a),x)
          \qquad \text{for } a \in \Sigma, x \in \Sigma^{\ast}
  \end{alignedat}
  \right.
\end{equation*}

\end{document}

输出

答案3

使用casesalign*环境将在标志周围提供更好的空间=。对于 的解决方案align*,加载empheq带有选项的包overload允许更简单的语法:

\documentclass[11pt, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern} 
\usepackage[overload]{ empheq}

\begin{document}

\begin{align*}[left = {\hat\delta =\empheqlbrace}]
   \hat\delta(q_i, \epsilon) &= q_i \\
   \hat\delta(q_i, ax) &= \hat\delta(\delta(q_i, a), x) : a\in\Sigma, x\in\Sigma^*
\end{align*}

\[ \hat\delta =
   \begin{cases}
      \hat\delta(q_i, \epsilon)= q_i \\
      \hat\delta(q_i, ax)= \hat\delta(\delta(q_i, a), x) : a\in\Sigma, x\in\Sigma^*
   \end{cases} \]

\end{document}

结果:

输出

相关内容