Skip to content
Travis Scholten edited this page Sep 9, 2016 · 3 revisions

Partly for completeness, we have incorporated most of the original FAQ page into this project's GitHub wiki pages. It is our hope this will make it more transparent for users of qcircuit to get the information they require.

Questions

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.

(Update 22 July 2014: Users should use the qcircuit.sty file.)

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.

Clone this wiki locally