I'm looking for a way to use color in qcircuit (based on xy-pic). I'd like to be able to add a background color for a gate, and for a gategroup. For exemple, how can I change this code:


\Qcircuit @C=1em @R=1em {
& \ctrl{2} & \qw & \gate{H} & \ctrl{1} &
\gate{H} & \qw \\
& \qw & \ctrl{1} & \gate{H} & \targ &
\gate{H} & \qw \\
& \targ & \targ & \gate{Z} & \qw & \ctrl{-1} &
\qw \gategroup{1}{4}{2}{6}{.7em}{-}

so that it produces something like that:

enter image description here

Thank you !


There is no convenient way to do this using Qcircuit and Xy-pic. I generally use the pgf package to draw colored boxes behind the regions of the circuit of interest. Aligning the colors precisely with the circuit elements is a pain, but it can be done as shown below:

enter image description here

This was typeset using the following code:

\input{Qcircuit}% using  Qcircuit version 2.5
    \Qcircuit @C=1em @R=1em {
        & \ctrl{2} & \qw & \gate{H} & \ctrl{1} & \gate{H} & \qw \\
        & \qw & \ctrl{1} & \gate{H} & \targ & \gate{H} & \qw \\
        & \targ & \targ & \gate{Z} & \qw & \ctrl{-1} & \qw

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.