I have quite an embarrassing error on my hands. I tried to display a function with multiple conditions. For that purpose, I used array
, and was very successful at first. But things went wrong when I tried to align some parts of longer conditions with the &
. This is the code that causes error:
\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}
I get the following errors (I copy-pasted from the log file):
! 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
However, if I simply remove the &
's, my code compiles just fine. Here's a 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}
I tried enveloping everything in align
, align*
and aligned
environments, but without success. I really don't know what to do anymore. Any help would be appreciated.
\left
in one group (eg array cell) and\right
in another. use\bigl[
and\bigr]
(or whatever size you want)\big[
doesn't suit my equation height perfectly I'm going to use the\phantom
command to display the two brackets. I don't know why I didn't think of this solutions before. Anyway, shoutout to Bernard and David for leading me to the solution.