I'm trying to typeset a circuit using Qcircuit and running into some spacing and alignment issues. Here is the portion that is giving me trouble (this will be embedded in a larger diagram):

\usepackage[braket]{Qcircuit}% using  qcircuit version 2.5
\Qcircuit @C=1em @R=1em @!R {
&                             &&         &\mbox{Black box $\times 3$} \\
&                             &&\gate{H} &\qw &\qw &\qw&\measuretab{A} \\
&\push{\Psi_{GHZ}\Rightarrow} &&\qw      &\gate{H}  &\qw      &\qw &\measuretab{B} \\
&                             &&\qw      &\qw       &\gate{H} &\qw &\measuretab{C}\\
&                             &&\dstick{S_A}\cwx[-3]&\dstick{S_B}\cwx[-2] &\dstick{S_C}\cwx

The result is:

render of the latex code above

The dashed boxes are all in the right place but I would like for them to be equally sized and nicely aligned & spaced, as well as the \psi_{GHZ} aligned with the big brace. I've tried various things to do with varying row & group spacings, \vphantom, \vspace, and \push (as described in the Qcircuit documentation) but nothing seems to help much. How do I achieve the desired effect?


1 Answer 1


Like it says in the Qcircuit tutorial, \gategroup only uses the four corner objects for sizing the enclosing box. The problem you're having is that the entries at the corners are different sizes. You can get around this by extending the boxes out to empty entries and then placing invisible struts of the appropriate size in those entries using \push and \rule. Here's my rendition of the circuit you were trying to make:

enter image description here

Here's the code used to typeset it:

\input{Qcircuit}% using  qcircuit version 2.5
\Qcircuit @C=.5em @R=1em @!R {
& & & & & & & \mbox{Black box $\times 3$} \\
& & & \qw & \push{\rule{0em}{1.2em}} \qw & \gate{H} & \qw & \qw & \qw & \qw & \qw & \qw & \measuretab{A} \\
& \push{\Psi_{GHZ}\Rightarrow\ \ } & & \qw &\push{\rule{0em}{1.2em}} \qw & \qw &\qw&\gate{H} & \qw & \qw & \qw & \qw & \measuretab{B} \\
& & & \qw & \push{\rule{0em}{1.2em}} \qw & \qw & \qw & \qw & \qw & \gate{H} & \qw & \qw & \measuretab{C} \\
& & & & & \dstick{S_A}\cwx[-3] & &\dstick{S_B}\cwx[-2] & & \dstick{S_C} \cwx

Note that, to get things to look right, I had to reduce the base column spacing and add more wire commands. The issue with the location of your label on the left was fixed by setting the region sized by the bracket to only the leftmost column.

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.