Q-circuit FAQ



Questions

Why is Q-circuit (suddenly) generating lots of errors?
Can I put a label and a gate in the same entry?
How come my circuit isn't centered? / Why do my labels stick out?
How can I place a label between rows?
Why can't I center circuits inside figures?
How can I vertically center a circuit in a line of text?
How do I color parts of my circuit?
What's new in version 1.1?
What's new in version 1.2?
What's new in version 2?


Answers

Why is Q-circuit (suddenly) generating lots of errors?
If Q-circuit was previously working for you and suddenly stopped or if you're getting errors other than "File `Qcircuit.tex' not found." then the problem is most likely that you are using Xy-pic version 3.8 or later and Q-circuit version 1.2 or earlier. You should switch to version 2 or later of Qcircuit.tex.


Can I put a label and a gate in the same entry?
No. In §5B of the tutorial it says, "A label can be placed anywhere that a gate command might normally appear." This means that you can't put a label and a gate command in the same entry, just like you can't put two gates in the same entry. Basically, a label is a kind of gate.


How come my circuit isn't centered? / Why do my labels stick out?
Like it says in §5B, "labels are treated as having zero size". This prevents them from mangling the layout of the circuit, but also means they are not considered when calculating it's size. The following circuit demonstrates a simple hack for labels that stick out to the left and those that stick out above.

\Qcircuit @C=1em @R=1em {
\push{\rule{0em}{1em}} & & \dstick{label} \\
\push{\rule{2em}{0em}} & \lstick{label} & \gate{A}
}


How can I place a label between rows?
If you're not too picky about where the label goes you can use \dstick or \ustick. If you need precision try something like the following code.

\Qcircuit @C=1em @R=1em {
& \gate{A} & \qw & & &\gate{B} & \qw \\
& \gate{C} & \qw & \raisebox{2em}{=} & &\gate{D} & \qw
}


Why can't I center circuits inside figures?
I don't know, but you can typically fix the problem by placing the \Qcircuit command inside an equation environment, an \mbox command, or a \centerline command.

Thus, the following code inserts a centered figure.

\begin{figure}[h]
\mbox{
\Qcircuit @C=1em @R=1em {
& \gate{X} & \qw
}
}
\caption{NOT Gate}
\end{figure}

If all else fails, try inserting the \centering command followed by the magical \leavevmode command inside your figure environment.


How can I vertically center a circuit in a line of text?
If you're content with having the top row of your circuit centered, you can achieve that by invoking the math environment using $.

The best way I know to vertically center the entire circuit in a line of text is to use the array environment. An example using this method is below.

$\begin{array}{c}
\Qcircuit @C=1em @R=1em {
& \gate{X} & \qw
}
\end{array}$


How do I color parts of my circuit?
Alas, LaTeX views the wires and gate outlines as a single object, so you cannot color them separately. The entire circuit or any text argument can be colored in the normal manner.


What's new in version 1.1? 8/2004
Two single qubit measurement gates have been added. The \meter command typesets a meter and the \measureD command typesets a D-shaped measurement gate which takes a single argument which determines the label. Also \measurebub has been renamed \measure and the orginal measure command has been discontinued.

Two multiple qubit measurement gates have been added. The commands are called \multimeasure and \multimeasureD. They work in exactly the same way as \multigate except they produce a rounded box and a D-shaped box respectively.

Several other modifications were made to impove connectivity and the general appearance of the gates.


What's new in version 1.2? 4/2006
The ability to typeset cluster states has been added by changing the definition of \Qcircuit and adding the commands \node and \link. \Qcircuit now takes an optional argument that places you in cluster state mode by specifying the size of nodes in the cluster. \node draws a circle, placing the mandatory argument inside; the optional argument is used as a (small) secondary label. \link is analogous to the other quantum wire commands but for the fact that it takes two arguments which are mandatory and allow the user to specify a target entry of both a different row and column.

\multimeasure has been modified slightly to improve its appearance when an empty argument is passed.

\targ has been modified to improve its appearance when circuits are typeset in different font sizes, i.e. in figures.

The command \pureghost has been added so that the left pointing wires can be omitted from multi-line measurement gates.


What's new in version 2? 9/2011
Nothing has been added. The ability to typeset cluster states has been removed. Q-circuit has been completely rewritten to work with Xy-pic version 3.8 and higher.