在“数组”环境中尝试将函数与多个条件对齐时出错

在“数组”环境中尝试将函数与多个条件对齐时出错

我遇到了一个相当尴尬的错误。我试图显示一个具有多个条件的函数。为此,我使用了array,一开始非常成功。但当我尝试对齐一些较长条件的部分用&。这是导致错误的代码:

\documentclass{article}

\usepackage{amsmath, array}

\begin{document}

\[
\text{R.H.S of } (7) \rightarrow \left\{
\begin{array}{ll}
\vspace{12px}
| 1 \rangle \left[ \cfrac{2\beta}{\sqrt{\alpha^2 + 4\beta^2}} \; | B \rangle \qquad & D_1 \text{ clicks, probability } \alpha^2/4 + \beta^2 - \cfrac{\alpha}{\sqrt{\alpha^2 + 4\beta^2}} \; | A \rangle \right], \\
\vspace{12px}
| 2 \rangle \; | A \rangle, \qquad & D_2 \text{ clicks, probability } \alpha^2/4 \\
|\text{scattered} \rangle \; | A \rangle, \qquad & \text{no clicks, probability } \alpha^2/2
\end{array}
\right.
\]

\end{document}

我收到以下错误(我从日志文件中复制粘贴):

! Missing \right. inserted.
<inserted text> 
\right .
l.11 ...pha^2 + 4\beta^2}} \; | B \rangle \qquad &
D_1 \text{ clicks, probab...
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.

! Extra \right.
l.11 ...lpha^2 + 4\beta^2}} \; | A \rangle \right]
, \\
I'm ignoring a \right that had no matching \left.


Overfull \hbox (64.53404pt too wide) detected at line 17

但是,如果我简单地删除&'s,我的代码就可以编译。这是一个 MWE:

\documentclass{article}

\usepackage{amsmath, array}

\begin{document}

\[
\text{R.H.S of } (7) \rightarrow \left\{
\begin{array}{ll}
\vspace{12px}
| 1 \rangle \left[ \cfrac{2\beta}{\sqrt{\alpha^2 + 4\beta^2}} \; | B \rangle \qquad D_1 \text{ clicks, probability } \alpha^2/4 + \beta^2 - \cfrac{\alpha}{\sqrt{\alpha^2 + 4\beta^2}} \; | A \rangle \right], \\
\vspace{12px}
| 2 \rangle \; | A \rangle, \qquad D_2 \text{ clicks, probability } \alpha^2/4 \\
|\text{scattered} \rangle \; | A \rangle, \qquad \text{no clicks, probability } \alpha^2/2
\end{array}
\right.
\]

\end{document}

我尝试将所有内容封装在alignalign*aligned环境中,但没有成功。我真的不知道该怎么办了。任何帮助都将不胜感激。

答案1

如果我理解得没错的话,下面是另一个(更简单的)代码来获取您想要的内容。我只是使用dcases来自的环境mathtools,并再次\braket使用来自 mathtools 的命令来定义命令:\DeclarePairedDelimiter

\documentclass{article}

\usepackage{mathtools, array}
\DeclarePairedDelimiter{\braket}{\lvert}{\rangle}

\begin{document}

\begin{gather*}
\text{R.H.S of } (7) \rightarrow% \left\{
\begin{dcases}%{ll}
\vspace{12px}
\braket{1}
\Biggl[ %
\cfrac{2\beta}{\sqrt{\alpha^2 + 4\beta^2}} \; \braket{B} & D_1 \text{ clicks, probability }\frac{ \alpha^2}{4} + \beta^2 - \cfrac{\alpha}{\sqrt{\alpha^2 + 4\beta^2}} \; \braket{A}\Biggr],
\\
\vspace{12px}
\braket{2}\,\braket{A}, & D_2 \text{ clicks, probability }\frac{ \alpha^2}{4} \\
\braket{\text{scattered}}\,\braket{A}, & \text{no clicks, probability } \frac{\alpha^2}{2}
\end{dcases}
\end{gather*}

\end{document}

在此处输入图片描述

答案2

因此,这是更简单的解决方案。不过,我还是要感谢大家在回答中表现出的极大关心和努力。非常感谢您的帮助。

正如我的评论所说,我通过\right.和找到了解决方案\left

\documentclass{article}

\usepackage{amsmath, array}

\begin{document}

\[
\text{R.H.S of } (7) \rightarrow \left\{
\begin{array}{ll}
\vspace{12px}
| 1 \rangle \left[ \cfrac{2\beta}{\sqrt{\alpha^2 + 4\beta^2}}\right. \; | B \rangle \qquad & D_1 \text{ clicks, probability } \alpha^2/4 + \beta^2 - \left. \cfrac{\alpha}{\sqrt{\alpha^2 + 4\beta^2}} \; | A \rangle \right] , \\
\vspace{12px}
| 2 \rangle \; | A \rangle, \qquad & D_2 \text{ clicks, probability } \alpha^2/4 \\
|\text{scattered} \rangle \; | A \rangle, \qquad & \text{no clicks, probability } \alpha^2/2
\end{array}
\right.
\]

\end{document}

在此处输入图片描述

相关内容