Package: qpic
A compiler from quantum circuits to graphical representations.Free software: GNU GPLv3 licenseDocumentation:⟨q|pic⟩ manualFeaturesThe ⟨q|pic⟩ language provides a concise, readable, ASCII format for
describing quantum circuits.qpicconverts ⟨q|pic⟩ files to the
scientific paper standard of LaTeX using TikZ graphic commands.Automatic placement of circuit components.Human readable.Input ⟨q|pic⟩ syntax can be produced by other scripts.Can be included in LaTeX documents in TikZ or PDF form.⟨q|pic⟩ produces high quality graphics quickly. The following graphic
illustrating part of a ripple carry adderis compiled from the ⟨q|pic⟩ codea W a a\oplus{c}
b W b b\oplus{c}
c W c \mbox{MAJ}(a,b,c)

a b c G \rotatebox{90}{MAJ}
=
+b c
+a c
a b +cExamplesBasic quantum teleportation circuitThis classic diagram derives from the following code:a W |\psi\rangle
b c W |\beta_{00}\rangle<
c W |\psi\rangle
a +b
a H
a b M
c X b:owire
c Z a:owireDecorated quantum teleportation circuit⟨q|pic⟩ has additional features for commenting or highlighting parts of
a circuit.This diagram derives from the following:PREAMBLE \providecommand{\K}[1]{\left|#1\right\rangle} # Define ket command
a  W \K{\phi} [x]
x1 W type=o # Empty wire used for positioning
x0 W style=dashed # Dividing line
x2 W type=o # Empty wire used for positioning
b0 W \K{0} [y]
b1 W \K{0} \K{\phi}

VERTICAL 0
b1 H    % $\K{\phi}\K{0}(\K{0}{+}\K{1})$
+b0 b1  % $(\alpha\K{0}{+}\beta\K{1})(\K{00}{+}\K{11})$
b0 x1 PERMUTE
+b0 a   %$\scriptstyle\alpha\K{0}(\K{00}{+}\K{11}){+}\beta\K{1}(\K{10}{+}\K{01})$
a H     % $\sum_{x,y}\K{xy}(\alpha\K{y}{+}(-1)^x\beta\K{\bar{y}})$
a b0 M  % $[xy](\alpha\K{y}{+}(-1)^x\beta\K{\bar{y}})$
x1 x2 a b0 PERMUTE
+b1 b0  % $[xy](\alpha\K{0}{+}(-1)^x\beta\K{1})$
b1 a    % $[xy](\alpha\K{0}{+}\beta\K{1})$

# Colored boxes
b0 b1 x1 x2 @ 0 2 fill=green style=rounded_corners %% $[qq]$ Quantum entanglement
a b0 x2 x1 @ 6 6 fill=blue style=rounded_corners %% \hspace{.5cm}$2[c\rightarrow c]$ Classical channelFor an explanation ofqpiccommands and more examples, see theofficial documentation.InstallationRecommended installation method ispip. Current
versions of Python 2 and 3 include pip. For older versions, usepip
installation instructions.pip install qpicIf you do not have permission to install or wish to installqpicas
a single user, add$HOME/.local/binto your$PATHand install
usingpip install--userqpicUninstallTo uninstallqpicsimply typepip uninstall qpicStand alone scriptTo try out the basic script without installation:Download the fileqpic.py. (located in theqpicdirectory)Runpython qpic.py your_file.qpic > your_file.tex.Running ⟨q|pic⟩qpicgenerates TikZ code by default.qpiccan also generate pdf
files usingpdflatexand png files usingconvert(from
ImageMagic).Create TikZ filediagram.tikzqpic-ftikz diagram.qpicCreate PDF filediagram.pdfqpic-fpdf diagram.qpicCreate PNG filediagram.pngqpic-fpng diagram.qpicUsing ⟨q|pic⟩ with LaTeXIncluding graphics in LaTeX documentsThere are two main methods for including ⟨q|pic⟩ in LaTeX documents.
Each has its advantage in certain areas. They are:Include TikZ code directlyInclude as a PDF graphicTikZqpic my_graphic.qpicproduces a TikZ file namedmy_graphic.tikz,
which can be directly included into a normal LaTeX document. You will
need to add\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,decorations.pathmorphing}to the preamble of your paper. Graphics can then be included with the
command:\input{filename.tikz}In some cases, additional TeX commands may be required in the preamble.
(These will be in the.tikzfile preceded by%!.) See the full
⟨q|pic⟩ documentation for when additional packages are required.PDFqpic-fpdf my_graphic.qpicwill produce a PDF file namedmy_graphic.pdf. This graphic can be viewed directly with a PDF
viewer. To insert the graphic into a LaTeX document, add the following
line to the preamble:\usepackage{graphicx}and include the file using the command:\includegraphics{my_graphic.pdf}This method requires the document to be processed with pdfLaTeX. For
further information see the full⟨q|pic⟩ documentation.History1.1.0 (2023-11-13)Update for Python 3.11+1.0.3 (2022-11-16)Handle deprecation of collections.Mapping in Python 3.10+1.0.2 (2016-04-20)Fix Python3 unicode bug.1.0.1 (2016-03-18)Convert README to ReStructuredText for PyPi.1.0.0 (2016-03-09)First release on PyPI.