方程式未正确对齐

方程式未正确对齐

我必须写出以下等式在此处输入图片描述

我已经准备好 MWE,但它没有正确对齐,

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{mathtools, nccmath}
\usepackage{array}
\begin{document}
    \begin{equation}
        \begin{array}{rl}
            L_{Y_{1} X_{1}} L_{Y_{0} X_{0}}\left(\left|I_{1}\right\rangle\right) & =L_{Y_{1} X_{1}} L_{Y_{0} X_{0}}\left(\frac{1}{2^{n}} \sum_{y=0}^{2^{n}-1} \sum_{x=0}^{2^{n}-1}\left|P_{y x}\right\rangle\left|y^{\prime}\right\rangle\left|x^{\prime}\right\rangle\right)\\
            & =\frac{1}{2^{n}}(\sum_{y=0}^{2^{n}-1} \sum_{x=0}^{2^{n}-1}\left|P_{yx}\right\rangle\left|y^{\prime}\right\rangle\left|x^{\prime}\right\rangle+U_{Y X}\left(\left|P_{Y_{0} X_{0}}\right|\right)\left|Y_{0} X_{0}\right\rangle+U_{Y X}\left(\left|P_{Y_{1} X_{1}}\right\rangle\right)\left|Y_{1} X_{1}\right\rangle \\
            & =\frac{1}{2^{n}}(\begin{array}{c}
                \sum_{y=0}^{2^{n}-1} \sum_{x=0}^{2^{n}-1}\left|P_{y x}\right\rangle\left|y^{\prime}\right\rangle\left|x^{\prime}\right\rangle+\left|p_{Y_{0} X_{0}}^{2} p_{Y_{0} X_{0}}^{3^{\prime}} \cdots p_{Y_{0} X_{0}}^{0^{\prime}} p_{Y_{0} X_{0}}^{1^{\prime}}\right\rangle\left|Y_{0} X_{0}\right\rangle \\
                y x \neq Y_{0} X_{0}, Y_{1} X_{1}
            \end{array}\\
            \qquad+\left|p_{Y_{1} X_{1}}^{2^{\prime}} p_{Y_{1} X_{1}}^{3^{\prime}} \cdots p_{Y_{1} X_{1}}^{0^{\prime}} p_{Y_{1} X_{1}}^{1^{\prime}}\right\rangle\left|Y_{1} X_{1}\right\rangle
        \end{array})
    \end{equation}
\end{document}

请帮助我。

答案1

我想出了与 Enevevet 类似的解决方案,但间距更好。

  1. @{}在数组中使用它来抑制列间距。
  2. {}我在最后一个等式中的 + 之前添加,以便在两边获得适当的二元运算符间距。
  3. 我放入\displaystyle数组列以获得一致的布局。
\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{mathtools, nccmath}
\usepackage{array}
\begin{document}
  \begin{align*}
     L_{Y_{1} X_{1}} L_{Y_{0} X_{0}}\left(\left|I_{1}\right\rangle\right) & 
     =L_{Y_{1} X_{1}} L_{Y_{0} X_{0}}\left(\frac{1}{2^{n}} \sum_{y=0}^{2^{n}-1} \sum_{x=0}^{2^{n}-1}
     \left|P_{yx}\right\rangle\left|y'\right\rangle\left|x'\right\rangle\right)\\
     & =\frac{1}{2^{n}}\left(
       \underset{y x \neq Y_{0} X_{0}, Y_{1} X_{1}}
         {\sum_{y=0}^{2^{n}-1} \sum_{x=0}^{2^{n}-1}\left|P_{yx}\right\rangle\left|y'\right\rangle\left|x'\right\rangle}
       +U_{Y X}\left(\left|P_{Y_{0} X_{0}}\right|\right)\left|Y_{0} X_{0}\right\rangle+U_{Y X}\left(\left|P_{Y_{1}X_{1}}
       \right\rangle\right)\left|Y_{1} X_{1}\right\rangle\right) \\
     & =\frac{1}{2^{n}}\left(\begin{array}{@{}>{\displaystyle}r@{}>{\displaystyle}l@{}}
        \underset{y x \neq Y_{0} X_{0}, Y_{1} X_{1}}
           {\sum_{y=0}^{2^{n}-1} \sum_{x=0}^{2^{n}-1}\left|P_{y x}\right\rangle\left|y'\right\rangle\left|x'\right\rangle} &
           {}+\left|p_{Y_{0} X_{0}}^{2'} p_{Y_{0} X_{0}}^{3'} \cdots p_{Y_{0} X_{0}}^{0'} p_{Y_{0} X_{0}}^{1'}\right\rangle\left|Y_{0} X_{0}\right\rangle \\
     & {}+\left|p_{Y_{1} X_{1}}^{2'} p_{Y_{1} X_{1}}^{3'} \cdots p_{Y_{1} X_{1}}^{0'} p_{Y_{1} X_{1}}^{1'}\right\rangle\left|Y_{1} X_{1}\right\rangle
     \end{array}\right)\\
  \end{align*}
\end{document}

在此处输入图片描述

答案2

还有一种可能性:我将方程嵌套在环境中fleqn(来自nccmath),并使用命令\DeclarePairedDelimiterfrommathtools定义 an\abs和 a\ket命令,这使代码更具可读性。最后,我加载了geometry更多合适的边距,以便方程式可以适应:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{nccmath,amssymb}
\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}
\DeclarePairedDelimiter\ket\lvert\rangle

\begin{document}

\begin{fleqn}[\parindent]
    \begin{equation}
        \begin{aligned}
          & L_{Y_1 X_1} L_{Y_0 X_0}\bigl(\ket{I_1}\bigr)= L_{Y_1 X_1} L_{Y_0 X_0}\left(\frac{1}{2ⁿ} ∑_{y=0}^{2ⁿ-1} ∑_{x=0}^{2ⁿ-1}\ket{P_{y x}} \ket{y'}\ket{x'}\right)\\
            & =\frac{1}{2ⁿ}\Biggl(∑_{y=0}^{2ⁿ-1}\smashoperator{∑_{\substack{x=0\\[0.5ex]y x ≠ Y_0 X_0, Y_1 X_1}}^{2ⁿ-1}} %
            \ket{P_{yx}}\ket{y'}\ket{x'}+U_{Y X}\bigl(\abs{P_{Y_0 X_0}}\bigr)\ket{Y_0 X_0}+ U_{Y X}\bigl(\ket{P_{Y_1 X_1}}\bigr)\ket{Y_1 X_1}\Biggr) \\
   & =\begin{aligned}[t]\frac{1}{2ⁿ}\Biggl(
 ∑_{y=0}^{2ⁿ-1} \smashoperator{∑_{\substack{x=0\\y x ≠ Y_0 X_0, Y_1 X_1}}^{2ⁿ-1}}\ket{P_{y x}}\ket{y'}\ket{x'}& +\ket[\big]{p_{Y_0 X_0}^2 p_{Y_0 X_0}^{3' }⋯ p_{Y_0 X_0}^{0'} p_{Y_0 X_0}^{1'}}\ket{Y_0 X_0} \\[-4ex]
 & +\ket[\big]{p_{Y_1 X_1}^{2'} p_{Y_1 X_1}^{3'} ⋯ p_{Y_1 X_1}^{0'} p_{Y_1 X_1}^{1'}}\ket{Y_1 X_1} \Biggr)
 \end{aligned}
 \end{aligned}
    \end{equation}
    \end{fleqn}

\end{document} 

在此处输入图片描述

答案3

对于最后一个方程,我会使用multlined。在我看来,带有它的方程结构更合乎逻辑。由于方程很宽,因此使用包\MoveEqLeft中定义的。它还会加载,因此无需单独加载它。mathtoolsamsmath

\documentclass{article}
\usepackage{geometry}
\usepackage{amssymb}
\usepackage{mathtools}

%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%


\begin{document}
  \begin{align*}
  \MoveEqLeft
L_{Y_{1} X_{1}} L_{Y_{0} X_{0}}\left(\left|I_{1}\right\rangle\right)    \\ 
    & = L_{Y_{1} X_{1}} L_{Y_{0} X_{0}}\left(\frac{1}{2^{n}} 
            \sum_{y=0}^{2^{n}-1} \sum_{x=0}^{2^{n}-1}
            \left|P_{yx}\right\rangle\left|y'\right\rangle\left|x'\right\rangle\right)\\
     & = \frac{1}{2^{n}}\left(
            \underset{y x \neq Y_{0} X_{0}, Y_{1} X_{1}}
            {\sum_{y=0}^{2^{n}-1} \sum_{x=0}^{2^{n}-1}\left|P_{yx}\right\rangle\left|y'\right\rangle\left|x'\right\rangle}
            + U_{Y X}\left(\left|P_{Y_{0} X_{0}}\right|\right)\left|Y_{0} X_{0}\right\rangle 
            + U_{Y X}\left(\left|P_{Y_{1}X_{1}}
        \right\rangle\right)\left|Y_{1} X_{1}\right\rangle\right) \\
    & = \frac{1}{2^{n}}\left(%
        \begin{multlined}
        \underset{y x \neq Y_{0} X_{0}, Y_{1} X_{1}}
           {\sum_{y=0}^{2^{n}-1} \sum_{x=0}^{2^{n}-1}\left|P_{y x}\right\rangle\left|y'\right\rangle\left|x'\right\rangle} \\
            + \left|p_{Y_{0} X_{0}}^{2'} p_{Y_{0} X_{0}}^{3'} \cdots p_{Y_{0} X_{0}}^{0'} p_{Y_{0} X_{0}}^{1'}\right\rangle\left|Y_{0} X_{0}\right\rangle
            + \left|p_{Y_{1} X_{1}}^{2'} p_{Y_{1} X_{1}}^{3'} \cdots p_{Y_{1} X_{1}}^{0'} p_{Y_{1} X_{1}}^{1'}\right\rangle\left|Y_{1} X_{1}\right\rangle
     \end{multlined}\right)
  \end{align*}
\end{document}

在此处输入图片描述

(红线表示文本区域边框)

答案4

我会先使用align环境,然后再array使用环境。对于两个和下面的下标,我使用了\underset因为下标是两个和共同的。最后,我得到了:

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{mathtools, nccmath}
\usepackage{array}
\begin{document}
        \begin{align*}
            L_{Y_{1} X_{1}} L_{Y_{0} X_{0}}\left(\left|I_{1}\right\rangle\right) & =L_{Y_{1} X_{1}} L_{Y_{0} X_{0}}\left(\frac{1}{2^{n}} \sum_{y=0}^{2^{n}-1} \sum_{x=0}^{2^{n}-1}\left|P_{y x}\right\rangle\left|y^{\prime}\right\rangle\left|x^{\prime}\right\rangle\right)\\
            & =\frac{1}{2^{n}}\left(\underset{y x \neq Y_{0} X_{0}, Y_{1} X_{1}}{\displaystyle\sum_{y=0}^{2^{n}-1} \sum_{x=0}^{2^{n}-1}}\left|P_{yx}\right\rangle\left|y^{\prime}\right\rangle\left|x^{\prime}\right\rangle+U_{Y X}\left(\left|P_{Y_{0} X_{0}}\right|\right)\left|Y_{0} X_{0}\right\rangle+U_{Y X}\left(\left|P_{Y_{1} X_{1}}\right\rangle\right)\left|Y_{1} X_{1}\right\rangle\right) \\
            & =\frac{1}{2^{n}}\left(\begin{array}{rl}
                \underset{y x \neq Y_{0} X_{0}, Y_{1} X_{1}}{\displaystyle\sum_{y=0}^{2^{n}-1} \sum_{x=0}^{2^{n}-1}}\left|P_{y x}\right\rangle\left|y^{\prime}\right\rangle\left|x^{\prime}\right\rangle &+\left|p_{Y_{0} X_{0}}^{2} p_{Y_{0} X_{0}}^{3^{\prime}} \cdots p_{Y_{0} X_{0}}^{0^{\prime}} p_{Y_{0} X_{0}}^{1^{\prime}}\right\rangle\left|Y_{0} X_{0}\right\rangle \\
                &+\left|p_{Y_{1} X_{1}}^{2^{\prime}} p_{Y_{1} X_{1}}^{3^{\prime}} \cdots p_{Y_{1} X_{1}}^{0^{\prime}} p_{Y_{1} X_{1}}^{1^{\prime}}\right\rangle\left|Y_{1} X_{1}\right\rangle
                \end{array}\right)
            \end{align*}
\end{document}

它看起来是这样的: LaTeX 输出

注意:你忘了下\prime标后面的2代码第三行下

相关内容