Q-circuit is a macro package for drawing quantum circuit diagrams in LaTeX. On this page you'll find everything you need to start making quantum circuit diagrams of your own.


Note: now the Qcircuit package has been released in CTAN--the LaTeX package channel. Please visit the new GitHub site for the latest version and download information. This site may not be maintained regularly. Thanks for your understanding.


Q-circuit requires both Xy-pic and the ifpdf package. Some distributions of LaTeX come with these packages and some do not. You can find information regarding Xy-pic at http://www.tug.org/applications/Xy-pic/. Information about the ifpdf package is available at http://www.ctan.org/pkg/ifpdf.

To install Q-circuit simply place the file Qcircuit.tex in the tex/latex subdirectory of your TeX tree and execute the command that updates the tree. I recommend putting it in $TEXMFLOCAL/tex/latex/Qcircuit if possible.

For my installation of TeX (MiKTeX on Windows XP) this corresponds to placing the file in C:\Program Files\texmf\tex\latex\Qcircuit and executing the command initexmf --update-fndb.

If you're running TeXShop on Mac OS X and your login is Steve (like Steve Flammia), the indicated directory is /users/Steve/Library/texmf/tex/latex/Qcircuit. No update is required.

Linux users will need to locate the appropriate base tex directory, which can be tricky. Try locate texmf. The update command is simply texhash, though depending on the directory that you use it may be necessary to run this as root, e.g. executing sudo texhash in a terminal. For my installation of TeXLive in Ubuntu, I've found it simplest just to place Qcircuit.tex in ~/texmf/tex/latex/Qcircuit (which is /home/beastin/texmf/tex/latex/Qcircuit for me) and to execute texhash from a terminal.

If installing is too much trouble, you can just put Qcircuit.tex in the same directory as the tex file you're compiling. This is also what you need to do for submission to the arXiv.


To actually use Q-circuit in a document simply place the command \input{Qcircuit} in the preamble.

Getting started

Q-circuit is distributed with a full fledged tutorial that teaches you how to typeset practically any quantum circuit. While a great deal of material is covered, it is presented in a tiered fashion that makes it easy to learn just enough to get the job done.

Still having problems? Check the FAQ.

Source code and contributions

If you want to make contributions to the latest development of the Qcircuit package, you can now commit your improvements to the GitHub open source repository. Suggestions and bugs can also be reported to the issue tracker. Volunteers from the open source community will continue the long-term development of the software.


Q-circuit was originally written by Steve Flammia and Bryan Eastin and is distributed under the GNU General Public License. Basically, this means you are free to use it in any way that doesn't defraud us or limit other people's rights.

Q-circuit is now very well known among those who typeset quantum circuit diagrams, so Steve and I no longer ask that you acknowledge your use of the package. Thanks to everyone who mentioned us in the past!


University of New Mexico Information Physics
Bryan Eastin's Research Page
Steve Flammia's Research Page
CQuIC Open-source Projects on GitHub

Last updated in Feb of 2016.