1

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.

2
  • This must be a duplicate, you can not have \left in one group (eg array cell) and \right in another. use \bigl[ and \bigr] (or whatever size you want) Commented Mar 18, 2017 at 22:38
  • I think I found a way to set things right. Because \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.
    – God bless
    Commented Mar 19, 2017 at 9:33

2 Answers 2

2

Here is another (simpler) code to obtain what you want, if I've well understood. I simply use a dcases environment from mathtools, and define a \braket command with \DeclarePairedDelimiter, again from mathtools:

\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}

enter image description here

3
  • Um, thank you very much, but when I try to compile your code, I get the same two errors and overfull box. Thank you for your time. Please help?
    – God bless
    Commented Mar 19, 2017 at 9:28
  • @Gregor Perčič: Sorry, a problem with my clipboard manager. I posted the code in your post instead og mine. Fixed. Thanks for pointing it!
    – Bernard
    Commented Mar 19, 2017 at 11:12
  • No problem. Your help is very valued. I really love LaTeX community, as it is the friendliest I know!
    – God bless
    Commented Mar 19, 2017 at 11:16
0

So, here is the simpler solution. Nevertheless, I want to thank everyone for awesome care and amount of effort that manifested in their answers. Your help is much appreciated.

As my comment tells, I found the solution by \right. and \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}

enter image description here

1
  • this may work Ok in this case but is not a good solution in general. It does not try to make the [ and ] the same size, it just sort of works here as the fraction on the left is a similar size to the fraction on the right. Also it adds extra horiziontal space, each of \right. and \left. add \nulldelimiterspace horizontal space. Commented Mar 19, 2017 at 9:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .