Quill is a package for creating quantum circuit diagrams in Typst.
Note, that this package is in beta and may still be undergoing breaking changes. As new features like data types and scoped functions will be added to Typst, this package will be adapted to profit from the new paradigms.
Meanwhile, we suggest importing everything from the package in a local scope to avoid polluting the global namespace (see example below).
Create circuit diagrams by calling the function quantum-circuit()
with any number of positional arguments — just like the built-in Typst functions table()
or grid()
. A variety of different gate and instruction commands are available and plain numbers can be used to produce any number of empty cells just filled with the current wire style. A new wire is started by adding a [\ ]
item.
#{
import "@preview/quill:0.2.0": *
quantum-circuit(
lstick($|0〉$), gate($H$), ctrl(1), rstick($(|00〉+|11〉)/√2$, n: 2), [\ ],
lstick($|0〉$), 1, targ(), 1
)
}
As a shorthand for simple gates you can also just write $H$
instead of the more lengthy gate($H$)
.
Refer to the user guide for a full documentation of this package.
Some show-off examples, loosely replicating figures from Quantum Computation and Quantum Information by M. Nielsen and I. Chuang.
- New features:
- Add arbitrary labels to any
gate
(also derived gates such asmeter
,ctrl
, ...),gategroup
orslice
that can be anchored to any of the nine 2d alignments. - Add optional gate inputs and outputs for multi-qubit gates (see gallery).
- Implicit gates (breaking change
⚠️ ): a content item automatically becomes a gate, so you can just type$H$
instead ofgate($H$)
(of course, thegate()
function is still important in order to use the many available options).
- Add arbitrary labels to any
- Other breaking changes
⚠️ :slice()
has nodx
anddy
parameters anymore. Instead, labels are handled throughlabel
exactly as ingate()
. Also thewires
parameter is replaced withn
for consistency with other multi-qubit gates.- Swap order of row and column parameters in
annotate()
to make it consistent with built-in Typst functions.
- Improvements:
- Improve layout (allow row/column spacing and min lengths to be specified in em-lenghts).
- Automatic bounds computation, even for labels.
- Improve meter (allow multi-qubit gate meters and respect global (per-circuit) gate padding).d
- Fixes:
lstick
/rstick
braces broke with Typst 0.7.0.lstick
/rstick
bounds.
- Documentation
- Add section on creating custom gates.
- Add section on using labels.
- Explain usage of
slice()
andgategroup()
.
Initial Release