2

I've written the following code for a quantum circuit using the qcircuit package and everything looks how I want it to look except that the curly brackets enclosing the bottom 2 lines are too far away.

I understand that my code for getting the labels on the dotted lines is probably not the best way of achieving this, but the main problem I'm concerned with is getting the curly braces closer to the circuit.

\begin{equation*}
\Qcircuit @C=1.4em @R=1em {
&&&  \lstick{\ket{\psi}} \ar@{.}[]+<0.5em,1em>;[d]+<0.5em,-3em>  & \ctrl{1} 
\ar@{.}[]+<1em,1em>;[d]+<1em,-3em> & \gate{H} \ar@{.}[]+<1.5em,1em>;[d]+ 
<1.5em,-3em> & \meter \ar@{.}[]+<1.5em,1em>;[d]+<1.5em,-3em> & \ustick{M_{1}} 
\cw & \cw & \cw & \control \cw \cwx[2] \\
&&&  & \targ & \qw & \meter & \ustick{M_{2}} \cw & \control \cw \cwx[1] \\
&&&  & \qw & \qw & \qw & \qw & \gate{X^{M_{2}}} & \qw & \gate{Z^{M_{1}}} & 
\ar@{.}[]+<-1em,-0.5em>;[u]+<-1em,6em> \qw \\
&&& & \hspace{-2em} \ket{\psi_{0}} & \hspace{-2.2em} \ket{\psi_{1}} & 
\hspace{-2.2em} \ket{\psi_{2}} & \hspace{-0.5em} \ket{\psi_{3}} & 
\hspace{15em} \ket{\psi_{4}} 
\inputgroupv{2}{3}{0.7em}{1.1em}{\ket{\Phi^{+}}} \\
}
\end{equation*}

The \inputgroupv line of code is the way I've got the curly braces that are currently there but changing the "0.7em" and "1.1em" values doesn't seem to help in getting the bracket closer.

Any help would be appreciated! Output

  • 1
    Welcome to TeX.SX! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). Please don't put only a screenshot of your code, otherwise, we can't cut and paste it. – CarLaTeX Apr 27 '18 at 20:08
  • I think you need \left { and consequently \right . at the end (left and right counts have to match. – albert Apr 28 '18 at 17:41
1

Why the empty columns?

\documentclass{article}
\usepackage{amsmath,braket}
\usepackage{qcircuit}

\begin{document}

\begin{equation*}
\Qcircuit @C=1.4em @R=1em {
  \lstick{\ket{\psi}} \ar@{.}[]+<0.5em,1em>;[d]+<0.5em,-3em>  & \ctrl{1}
\ar@{.}[]+<1em,1em>;[d]+<1em,-3em> & \gate{H} \ar@{.}[]+<1.5em,1em>;[d]+
<1.5em,-3em> & \meter \ar@{.}[]+<1.5em,1em>;[d]+<1.5em,-3em> & \ustick{M_{1}}
\cw & \cw & \cw & \control \cw \cwx[2] \\
  & \targ & \qw & \meter & \ustick{M_{2}} \cw & \control \cw \cwx[1] & & & \\
  & \qw & \qw & \qw & \qw & \gate{X^{M_{2}}} & \qw & \gate{Z^{M_{1}}} &
\ar@{.}[]+<-1em,-0.5em>;[u]+<-1em,6em> \qw \\
 & \hspace{-2em} \ket{\psi_{0}} & \hspace{-2.2em} \ket{\psi_{1}} &
\hspace{-2.2em} \ket{\psi_{2}} & \hspace{-0.5em} \ket{\psi_{3}} &
\hspace{15em} \ket{\psi_{4}}
\inputgroupv{2}{3}{0.7em}{1.1em}{\ket{\Phi^{+}}} \\
}
\end{equation*}

\end{document}

enter image description here

Sorry, I can't debug the error

! Xy-pic error: in entry "3,9": No [u] (is "2,9") from here.
\xyerror@ ...#2}\fi \errmessage {Xy-pic error: #1}
                                                  }
l.24 }

Adding &&& at the end of the second row makes the error disappear (provided by beastin, see comments), but it's not really clear whether the result is like you really want.

  • I'm not sure why I had those empty columns at the front, I think it was from trying to get the curly brackets with a different method, but the code you've suggested has fixed my issue, thank you! – Matthew L Apr 29 '18 at 14:37
  • The error is caused by the lack of an entry at "2,9" (which is being used to position things). I added a few columns to the second row of the code. That should fix things. (I don't have easy access to a compiler with \inputgroupv, so I didn't test it.) – beastin Apr 29 '18 at 15:04
  • @beastin Thanks. I approved the edit, although the last dotted line turns out to be longer than the others. At least this doesn't raise an error. – egreg Apr 29 '18 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.