From ae34f484404571c09a61f3bde45d083a51cb0ac5 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 18 Aug 2021 03:00:59 +0000 Subject: CTAN sync 202108180300 --- graphics/pgf/contrib/yquant/README.md | 75 ++- graphics/pgf/contrib/yquant/doc/yquant-doc.pdf | Bin 680322 -> 711688 bytes graphics/pgf/contrib/yquant/doc/yquant-doc.tex | 428 +++++++++++------ graphics/pgf/contrib/yquant/tex/yquant-config.tex | 22 +- graphics/pgf/contrib/yquant/tex/yquant-draw.tex | 218 +++++++-- graphics/pgf/contrib/yquant/tex/yquant-env.tex | 15 +- graphics/pgf/contrib/yquant/tex/yquant-lang.tex | 77 +-- .../pgf/contrib/yquant/tex/yquant-langhelper.tex | 5 + graphics/pgf/contrib/yquant/tex/yquant-prepare.tex | 47 +- .../pgf/contrib/yquant/tex/yquant-registers.tex | 1 + graphics/pgf/contrib/yquant/tex/yquant-tools.tex | 104 ++-- graphics/pgf/contrib/yquant/tex/yquant.sty | 11 +- .../contrib/yquant/tex/yquantlanguage-groups.sty | 527 +++++++++++++++++++++ 13 files changed, 1229 insertions(+), 301 deletions(-) create mode 100644 graphics/pgf/contrib/yquant/tex/yquantlanguage-groups.sty (limited to 'graphics/pgf/contrib/yquant') diff --git a/graphics/pgf/contrib/yquant/README.md b/graphics/pgf/contrib/yquant/README.md index d8d8e1afaa..e8f39e3df0 100644 --- a/graphics/pgf/contrib/yquant/README.md +++ b/graphics/pgf/contrib/yquant/README.md @@ -7,16 +7,18 @@ It builds on and interacts with TiKZ, which brings an enourmous flexibility for A detailed reference with lots of examples is provided in the PDF version of this Readme. We will sketch some basic usage. -Now yquant also understands circuits written in the qasm language! +Now yquant also understands circuits written in the qasm language and provides a simple interface for circuit equations! -## License -This material is subject to the LaTeX Project Public License 1.3c. +Support the development: +- [![PayPal](https://img.shields.io/badge/donate-via%20PayPal-blue.svg?style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UTR3MRBYJ825A&source=url) +- ![Bitcoin](https://img.shields.io/badge/donate-BTC-blue.svg?style=flat) 3KBFpoJuA4eSPLGXEf3jicqaV1czhK36fH +- ![Ethereum](https://img.shields.io/badge/donate-ETH-blue.svg?style=flat) 0xE0F774221290b1E41ea62c2dd9af5dbD3df7c685 ## Examples -Many more examples and explanations can be found in the [PDF version](https://github.com/projekter/yquant/raw/master/doc/latex/yquant/yquant-doc.pdf) of this Readme. +Many more examples and explanations can be found in the [PDF version](doc/latex/yquant/yquant-doc.pdf) of this Readme. ### Simple teleportation circuit -![ex-01.png](https://github.com/projekter/yquant/raw/master/markdown/ex-01.png) +![ex-01.png](markdown/ex-01.png) ```LaTeX \begin{tikzpicture} \begin{yquant} @@ -35,7 +37,7 @@ Many more examples and explanations can be found in the [PDF version](https://gi ``` ### Three-qubit phase estimation circuit with QFT and controlled-U -![ex-02.png](https://github.com/projekter/yquant/raw/master/markdown/ex-02.png) +![ex-02.png](markdown/ex-02.png) ```LaTeX \begin{tikzpicture} \begin{yquant} @@ -58,7 +60,7 @@ Many more examples and explanations can be found in the [PDF version](https://gi ``` ### Three-qubit FT QEC circuit with syndrome measurement -![ex-03.png](https://github.com/projekter/yquant/raw/master/markdown/ex-03.png) +![ex-03.png](markdown/ex-03.png) ```LaTeX \begin{tikzpicture} \begin{yquant} @@ -93,34 +95,39 @@ Many more examples and explanations can be found in the [PDF version](https://gi ``` ### Error correction -![ex-04.png](https://github.com/projekter/yquant/raw/master/markdown/ex-04.png) +![ex-04.png](markdown/ex-04.png) ```LaTeX -% \usetikzlibrary{fit, quotes} +% \usetikzlibrary{quotes} \begin{tikzpicture} \begin{yquant} qubit {} msg[3]; - [name=inits] - qubit {$\ket0$} syndrome[3]; - - [name=scnot0] - cnot syndrome[0] | msg[0]; - cnot syndrome[0] | msg[1]; - cnot syndrome[1] | msg[1]; - cnot syndrome[1] | msg[2]; - cnot syndrome[2] | msg[0]; - cnot syndrome[2] | msg[2]; - [name=smeas] - dmeter {$M_{\symbol{\numexpr`a+\idx}}$} syndrome; + nobit syndrome[3]; + + [this subcircuit box style={dashed, "Syndrome Measurement"}] + subcircuit { + qubit {} msg[3]; + [out] + qubit {$\ket0$} syndrome[3]; + + cnot syndrome[0] | msg[0]; + cnot syndrome[0] | msg[1]; + cnot syndrome[1] | msg[1]; + cnot syndrome[1] | msg[2]; + cnot syndrome[2] | msg[0]; + cnot syndrome[2] | msg[2]; + + dmeter {$M_{\symbol{\numexpr`a+\idx}}$} syndrome; + } (msg[-2], syndrome[-2]); + ["Recovery"] box {$\mathcal R$} (msg) | syndrome; discard syndrome; \end{yquant} - \node[draw, dashed, fit=(inits-2) (scnot0-p0) (smeas-2), "Syndrome Measurement"] {}; \end{tikzpicture} ``` ### Lots of controls -![ex-05.png](https://github.com/projekter/yquant/raw/master/markdown/ex-05.png) +![ex-05.png](markdown/ex-05.png) ```LaTeX \begin{tikzpicture} \begin{yquant*} @@ -133,4 +140,26 @@ Many more examples and explanations can be found in the [PDF version](https://gi discard a[2, 3]; \end{yquant*} \end{tikzpicture} +``` + +### Circuit equations +![ex-06.png](markdown/ex-06.png) +```LaTeX +% \useyquantlanguage{groups} +\begin{tikzpicture} + \begin{yquantgroup} + \registers{ + qubit {} q[2]; + } + \circuit{ + h -; + cnot q[1] | q[0]; + h -; + } + \equals + \circuit{ + cnot q[0] | q[1]; + } + \end{yquantgroup} +\end{tikzpicture} ``` \ No newline at end of file diff --git a/graphics/pgf/contrib/yquant/doc/yquant-doc.pdf b/graphics/pgf/contrib/yquant/doc/yquant-doc.pdf index 0a1e1d144a..29379b0f77 100644 Binary files a/graphics/pgf/contrib/yquant/doc/yquant-doc.pdf and b/graphics/pgf/contrib/yquant/doc/yquant-doc.pdf differ diff --git a/graphics/pgf/contrib/yquant/doc/yquant-doc.tex b/graphics/pgf/contrib/yquant/doc/yquant-doc.tex index 2b2469e463..218aabcbb7 100644 --- a/graphics/pgf/contrib/yquant/doc/yquant-doc.tex +++ b/graphics/pgf/contrib/yquant/doc/yquant-doc.tex @@ -18,7 +18,7 @@ \usepackage[compat=newest]{yquant} \usepackage{braket,hyphenat,microtype,hologo,minted,import,ragged2e} \usetikzlibrary{quotes,fit,shapes.symbols,backgrounds,quantikz} -\useyquantlanguage{qasm} +\useyquantlanguage{qasm,groups} \usepackage{amsmath,adjustbox,cleveref} \usepackage[framemethod=tikz]{mdframed} % END_FOLD @@ -217,7 +217,7 @@ This document outlines the scope and usage of the \Yquant{} package. It contains both a reference and a huge number of examples. \Yquant{} is a package that makes typesetting quantum circuits easy; the package is available on CTAN. - This beta version~0.4.1 \emph{should} be stable and interfaces are not very likely to change in an incompatible way in the future. + This beta version~0.5 \emph{should} be stable and interfaces are not very likely to change in an incompatible way in the future. \compat{New in 0.4}Sometimes, backwards\hyp incompatible changes are required or advisable, in which case a compatibility setting will allow to revert back to the old behavior (rather, to maximize compatibility, this is an opt\hyp in setting: unless you choose the new behavior, you will get the old one). Please do report all issues and desirable additions on \href{https://github.com/projekter/yquant/issues}{GitHub}. @@ -333,7 +333,7 @@ This allows certain features that are expected to break old layout or functionality to revert to their previous behavior. Every feature affected by the \texttt{compat} key is documented in this manual. Once a compatibility version is selected in a document, it cannot be changed any more. - Compatibility versions will include the major and minor, but not the patch level version number. + Compatibility versions will include the major and minor, but not the patch level version number (though not every major or minor version will necessarily introduce new compatibility versions). Bugs that clearly violated behavior described in this manual will be fixed without a possibility to revert back. Changes that are not supposed to result in a (more than marginally) different result will not be included in the compatibility layer. If you find this to be wrong in a particular case, please file a bug report. @@ -962,6 +962,34 @@ IndexSingle = ?number? | ( [ ?number? ], "-", [ ?number? ] ); Hence, the most prominent application of this key is if the wires before and after the subcircuit are \gate{nobit}s, which provides a clean way to build up circuit equations with perfectly aligned wires (examples can be found in \cref{sec:examples}). \end{option} + \begin{option}[New in 0.5]{operators/subcircuit/name mangling}!prefix or discard! + This option defines how named nodes within subcircuits are made available to the outer circuit: + \begin{itemize} + \item \texttt{prefix or discard} \\ + If the subcircuit itself has a name $s$ and the inner gate has a name $g$, the outer circuit can refer to the inner gate via the name \texttt{$s$-$g$}. + Note that $s$ itself may not only consist of the user\hyp specified name, but may instead already be suffixed by \texttt{-0}, \texttt{-1}, \dots, if the subcircuits were assigned to multiple targets. + + If the subcircuit itself has no name, works as \texttt{discard}. + \item \texttt{prefix or transparent} \\ + If the subcircuit itself has a name, as works as \texttt{prefix or discard}; else, works as \texttt{transparent}. + \item \texttt{transparent} \\ + The inner gates are always available in the outer circuit by their original names. + Note that this may potentially lead to naming conflicts, which are always resolved by the latest name overwriting all previous declarations without notice. + \item \texttt{discard} \\ + The inner gates will not be available in the outer circuit. + \end{itemize} + Note that if a new gate is defined via \tex!\yquantdefinegate!---which internally uses subcircuits---the value of this option at the time of declaration is the relevant one, not the one at the time of usage. + This can be influenced via \style{/yquant/operators/subcircuit/name mangling reset}. + \end{option} + + \begin{option}[New in 0.5]{operators/subcircuit/name mangling reset}!true! + The current value of \style{/yquant/operators/subcircuit/name mangling} will be reset at the beginning of a subcircuit to the value it had upon declaration of the subcircuit only if this option is \texttt{true} upon \emph{using} the subcircuit (which typically will only make a difference if the subcircuit was defined via \tex!\yquantdefinegate! at some earlier stage). + \begin{warning} + Setting this value to \tex!false! has the potential of breaking the corresponding subcircuit/custom gate, as it may internally reference gates by names that are no longer the correct ones. + Do not use this property without a very good reason and thorough understanding of what is happening. + \end{warning} + \end{option} + \begin{option}[New in 0.4]{operators/subcircuit/seamless}!/yquant/operators/subcircuit/frameless, /yquant/register/default name=, /yquant/circuit/seamless! This option carries out multiple actions that are responsible to let the current subcircuit appear in a ``seamless'' state: \begin{itemize} @@ -1024,6 +1052,7 @@ IndexSingle = ?number? | ( [ ?number? ], "-", [ ?number? ] ); All nodes in the subcircuit will then have the name \texttt{\textit{}-\textit{}}. Note that here, \texttt{\textit{}} is the \emph{full} name of the subcircuit, which includes the \tex!-\idx! suffix, \compat{New in 0.4.1}unless there is only a single target register. For nested subcircuits, you will get multiple prefixes. + \compat{New in 0.5}The prefixing behavior can be influenced by \style{/yquant/operators/subcircuit/name mangling}. \subsection{Shapes and the drawing pipeline} All \Yquant{} shapes have the anchors available you would typically expect from a \TikZ{} shape of the given outline. @@ -1402,6 +1431,8 @@ IndexSingle = ?number? | ( [ ?number? ], "-", [ ?number? ] ); \begin{itemize} \item \compat{New in 0.4}\yquant!frameless! \\ This \style{/yquant/operators/subcircuit/frameless} style is activated with this shorthand. + \item \compat{New in 0.5}\yquant!name mangling! \\ + This shorthand will pass the value of the attribute directly to the configuration key \style{/yquant/operators/subcircuit/name mangling}. \item \compat{New in 0.4}\yquant!seamless! \\ The \style{/yquant/operators/subcircuit/seamless} style is activated with this shorthand (implies \yquant!frameless!). \item \yquant!value=! (required) \\ @@ -1871,42 +1902,27 @@ qubit {$\ket{q_{\idx}} = \Ifcase\idx\relax \ket\psi \Else \ket0 \Fi$} q[3]; As the \pkg{qcircuit} manual uses a bit larger separation between the operators than \Yquant's default, we globally say\\*\tex!\yquantset{operator/separation=1em}!. \subsubsection{I. Introduction} - \begin{example}% + \begin{example}% \begin{codeexample*} -\begin{tikzpicture} - \begin{yquant}[operators/subcircuit/frameless] - nobit q[3]; - - subcircuit { - [out] - qubit {} q[3]; - box {$U$} q[2] | q[0, 1]; - } (q); - discard -; - - [draw=none] - box {$=$} (-); - - subcircuit { - [out] - qubit {} q[3]; - box {$V$} q[2] | q[1]; - cnot q[1] | q[0]; - box {$V^\dagger$} q[2] | q[1]; - cnot q[1] | q[0]; - box {$V$} q[2] | q[0]; - } (q); - discard -; - \end{yquant} -\end{tikzpicture} +% \useyquantlanguage{groups} +\begin{yquantgroup} + \registers{ + qubit {} q[3]; + } + \circuit{ + box {$U$} q[2] | q[0, 1]; + } + \equals + \circuit{ + box {$V$} q[2] | q[1]; + cnot q[1] | q[0]; + box {$V^\dagger$} q[2] | q[1]; + cnot q[1] | q[0]; + box {$V$} q[2] | q[0]; + } +\end{yquantgroup} \end{codeexample*} - The best way to realize circuit equalities is with the help of \texttt{frameless} subcircuits. - The \texttt{[frameless]} attribute can either be specified on each subcircuit individually or, as done here, globally via the corresponding style. - In this way, we can specify all subcircuits individually. - All wires that are identical in the circuits must be outer wires; but in fact, we do not want them to be visible outside of the subcircuits. - Consequently, we initialize them in the outer circuit as \gate{nobit}s, declare them with the \texttt{[out]} attribute, and discard them right after the subcircuit. - It is important not to discard them within the subcircuit, as the wires would then not extend to the same horizontal final position. - The equality sign is realized very easily by means of a \gate{box} gate that spans all registers and from which we remove the border. + The best way to realize circuit equalities is with the help of \pkg{groups} language extension, which is documented in \cref{sec:foreign:groups}. \end{example} \begin{example} @@ -2494,7 +2510,7 @@ qubit {$\ket{q_{\idx}} = \Ifcase\idx\relax \ket\psi \Else \ket0 \Fi$} q[3]; In general, any macros that are used within a \TikZ{} path or a \Yquant{} operation must not be fragile, or must be preceded with \tex!\protect!. In this example, \tex!\\! is a robust command (at least in newer kernels), so protection is not required. - Since it may occur quite frequently that \Yquant{} is used within a \tex!center! environment or in \tex!\centering! mode (in which \tex!\\! is still fragile), \Yquant{} takes care of this (it actually robustifies \tex!\@centercr!, which is the meaning of \tex!\\! in these surroundings). + Since it may occur quite frequently that \Yquant{} is used within a \tex!center! environment or in \tex!\centering! mode (in which \tex!\\! is still fragile), \Yquant{} takes care of this (it actually robustifies \tex!\@centercr!, which is the meaning of \tex!\\! in these surroundings---and which is now incorporated into the \LaTeX{} kernel as of June~2021). In order to change the style of an individual wire, we use \gate{addstyle}. To make the final line shorter, we change the operator separation by issuing \tex!\yquantset! at the end. @@ -2824,7 +2840,6 @@ qubit {$\ket{q_{\idx}} = \Ifcase\idx\relax \ket\psi \Else \ket0 \Fi$} q[3]; \Yquant{} does not provide a mechanism for vertical labels, but you may of course just insert line breaks at appropriate positions (and set the \texttt{align} property of the labels). - \clearpage \subsubsection{VI. Spacing} \paragraph{A. Local adjustment}\leavevmode \begin{example} @@ -2872,6 +2887,7 @@ qubit {$\ket{q_{\idx}} = \Ifcase\idx\relax \ket\psi \Else \ket0 \Fi$} q[3]; Also note that the \style{/yquant/operator/minimum width} style is unsuitable for the given task: it would not change the visual width, only what \Yquant{} assumes its width to be. \end{example} + \clearpage \paragraph{B. Global Adjustment}\leavevmode \begin{example} \begin{codeexample*} @@ -2902,7 +2918,7 @@ qubit {$\ket{q_{\idx}} = \Ifcase\idx\relax \ket\psi \Else \ket0 \Fi$} q[3]; \clearpage \paragraph{C. Alignment}\leavevmode - \begin{example} + \begin{example} \begin{codeexample} \begin{tikzpicture} \begin{yquant*} @@ -2920,123 +2936,84 @@ $=$ \end{codeexample} Not specifying anything for the vertical alignment will lead to the common \TikZ{} problem: the baseline will be at the bottom, which is particularly bad in this case due to the missing $X$ gate. The keys for minimal register sizes do not help here, since they only affect \Yquant's internal handling, but not the bounding box calculated by \TikZ. - The recommended way to draw circuit equations is always with \texttt{frameless} \gate{subcircuit}s; only this will guarantee perfect wire alignment in all cases. + The recommended way to draw circuit equations is always with the \pkg{groups} language extension. \begin{codeexample} -\begin{tikzpicture} - \begin{yquant} - nobit q[2]; - - [frameless] - subcircuit { - [out] - qubit {} q[2]; - x q[0]; - cnot q[1] | q[0]; - } (q); - discard -; - - [draw=none] - box {$=$} (q); - - [frameless] - subcircuit { - [out] - qubit {} q[2]; - cnot q[1] | q[0]; - x q; - } (q); - discard -; - \end{yquant} -\end{tikzpicture} +% \useyquantlanguage{groups} +\begin{yquantgroup} + \registers{ + qubit {} q[2]; + } + \circuit{ + x q[0]; + cnot q[1] | q[0]; + } + \equals + \circuit{ + cnot q[1] | q[0]; + x q; + } +\end{yquantgroup} \end{codeexample} \end{example} - \begin{example} + \clearpage + \begin{example} \begin{codeexample*} -\begin{tikzpicture} - \begin{yquant} - qubit {$\ket x$} q; - qubit {$\ket y$} q[+1]; - - [seamless] - subcircuit { - [in] - qubit {} q[2]; - - h q[0]; - cnot q[1] | q[0]; - output {\quad$\mapsto$} (-); - } (q); - - [draw=none, inner sep=0pt] - box {$\ket{\psi_{x, y}}$} (q); - - [seamless] - subcircuit { - [out] - qubit {} q[2]; +% \useyquantlanguage{groups} +\begin{yquantgroup} + \registers{ + qubit {} q[2]; + } + \circuit{ + init {$\ket x$} q[0]; + init {$\ket y$} q[1]; - init {$\mapsto$\quad} (q); - cnot q[1] | q[0]; - h q[0]; - } (q); + h q[0]; + cnot q[1] | q[0]; + output {} (-); + } + \equals[$\mapsto\quad\ket{\psi_{x, y}}\quad\mapsto$] + \circuit{ + init {} (q); + cnot q[1] | q[0]; + h q[0]; output {$\ket x$} q[0]; output {$\ket y$} q[1]; - \end{yquant} -\end{tikzpicture} + } +\end{yquantgroup} \end{codeexample*} Here, we do not have a circuit equation (i.e., logical statements involving multiple rather independent circuits), but a circuit progression. - We start with some ``outer'' states (note we could again have used the \tex!\symbol! trick to make the declaration a bit shorter), let them enter into the first subcircuit and define an output of this. - In the opposite way, we proceed after giving the state. - Where to put the actual labels (e.g., the \gate{box} could also have contained $\mapsto \ket{\psi_{x, y}} \mapsto$ and the \gate{output} and \gate{init} gates could have been empty) is up to the user. - - Note that we used \texttt{seamless} instead of \texttt{frameless}, which gives a tighter spacing that is more suitable if initializers or outputs are present. + Since only in one circuit we have a description of the registers, we declare them without an initial text and put their initialization into \gate{init} gates. + The mapping in between is done by using the optional argument of the \tex!\equals! macro. + In order to obtain the braces at the ends, we use empty \gate{output} and \gate{init} gates. \end{example} \clearpage \subparagraph{1. Perfecting Vertical Alignment}\leavevmode - \begin{example} + \begin{example} \begin{codeexample*} -\begin{tikzpicture} - \begin{yquant} - nobit q[2]; - - [frameless] - subcircuit { - [out] - qubit {} q; - [out] - qubit {$\ket0$} q[+1]; - - cnot q[0] | q[1]; - cnot q[1] | q[0]; - cnot q[0] | q[1]; - } (q); - discard -; - - [draw=none] - box {$=$} (q); - - [frameless] - subcircuit { - [out] - qubit {} q; - [out] - qubit {$\ket0$} q[+1]; - - cnot q[1] | q[0]; - cnot q[0] | q[1]; - } (q); - discard -; - \end{yquant} -\end{tikzpicture} +% \useyquantlanguage{groups} +\begin{yquantgroup} + \registers{ + qubit {} q; + qubit {$\ket0$} q[+1]; + } + \circuit{ + cnot q[0] | q[1]; + cnot q[1] | q[0]; + cnot q[0] | q[1]; + } + \equals + \circuit{ + cnot q[1] | q[0]; + cnot q[0] | q[1]; + } +\end{yquantgroup} \end{codeexample*} - Using \gate{subcircuit}s here looks like an overkill, but it is the best way both for logical consistency and also to achieve perfect horizontal alignment. \end{example} - \clearpage \paragraph{D. Scaling}\leavevmode \begin{example} \begin{codeexample*} @@ -3054,6 +3031,7 @@ $=$ In earlier versions, there was a bug that required \Yquant{} to reset the \texttt{transform shape} key for \texttt{label}s, which would then require you to scale those manually. \end{example} + \clearpage \subsubsection{VII. Typesetting} \paragraph{A. Global Styling}\leavevmode \begin{example} @@ -3106,7 +3084,6 @@ $=$ \Yquant{} properly splits discontiguous multi\hyp qubit operations. \end{example} - \clearpage \paragraph{B. Per-Gate Styling}\leavevmode \begin{example} \begin{codeexample} @@ -3200,7 +3177,6 @@ $=$ Here, we used the key \style{/yquant/this subcircuit box style} to influence only the style of the subcircuit box itself instead of providing global options that apply to every object in the subcircuit (you wouldn't want the label be assigned to every single gate). \end{example} - \clearpage \begin{example} \begin{codeexample*} % \usetikzlibrary{quotes} @@ -3278,9 +3254,167 @@ $=$ \end{example} \endgroup - \section{Foreign language support}\label{sec:foreign} + \section{Foreign language support and extensions}\label{sec:foreign} \Yquant{} is built in various modules, so that it is not hard to use the quantum circuit rendering backend, but expose a different language frontend. \compat{New in 0.3}\Yquant{} not only understands its own language, but also others. + \compat{New in 0.5}Although we refer to ``foreign languages,'' additional extension packages of the \Yquant{} language itself are also covered in this section and can be loaded by the same syntax. + + \subsection[groups]{\compat{New in 0.5}groups}\label{sec:foreign:groups} + By saying \tex!\useyquantlanguage{groups}! in the preamble after loading \Yquant{} itself, additional support for groups of \Yquant{} circuits is loaded. + Various circuits in a group share a common set of registers, are appropriately aligned horizontally if on the same line and can also be aligned vertically among multiple lines. + The main intended use is for circuit equations. + + This extension provides the environment \tex!yquantgroup!. + You may use this environment within a \tex!tikzpicture!; in this case, all page\hyp break related features are not available. + You may alternatively use the environment outside of a \tex!tikzpicture!; in this case, it will start and end the pictures appropriately. + + As with \tex!yquant!, the environment accepts optional options that are passed to \tex!\yquantset!; a starred form is available that allows for the lazy creation of registers---but note that \emph{shared} registers must always be created explicitly; only if some circuits in the group have additional registers, the lazy creation applies. + + \subsubsection{General usage} + \begin{minted}{tex} +% preamble: +% \usepackage[compat=]{yquant} +% \useyquantlanguage{groups} +\begin{tikzpicture}% tikz options possible. This environment may be omitted. + % tikz commands go here + \begin{yquantgroup}% yquant(group) options possible. + \registers{ + % arbitrary shared register declaration go here + } + % any of \circuit, \equals, \\, \shiftright + % if the tikzpicture environment was omitted: also allows + % \pagebreak, \newpage, \clearpage, \cleardoublepage + % in most cases, TikZ commands are also allowed + \end{yquantgroup} + % tikz commands go here +\end{tikzpicture} + \end{minted} + + \subsubsection{Special macros} + \paragraph*{\tex!\registers!} + The \tex!\registers! macro can and must only be used once in a \tex!yquantgroup! environment. + It contains the declaration of all the registers that are shared among the various circuits within a group. + Basically, if you follow the convention in a usual \Yquant{} circuit to first declare all the registers, then use the gates, then you would put the declaration part in the \tex!\registers! macro. + However, note that it is in principle also possible to mix register declarations with other gates and \TikZ{} commands. + + In case you do not use the \gate{import} gate in any of the circuits within the group and you do not declare own registers, the behavior is very straightforward: basically, the content of \tex!\registers! is copied verbatim at the beginning of each circuit. + Otherwise, the general rule is: importing a register will ensure that all non\hyp declaration commands that preceded this register declaration are executed; and importing the last register will additionally execute all succeeding commands within \tex!\registers!. + + \paragraph*{\tex!\circuit[