texlive[54527] Master: yquant (24mar20)

commits+karl at tug.org commits+karl at tug.org
Tue Mar 24 21:57:30 CET 2020


Revision: 54527
          http://tug.org/svn/texlive?view=revision&revision=54527
Author:   karl
Date:     2020-03-24 21:57:29 +0100 (Tue, 24 Mar 2020)
Log Message:
-----------
yquant (24mar20)

Modified Paths:
--------------
    trunk/Master/tlpkg/bin/tlpkg-ctan-check
    trunk/Master/tlpkg/libexec/ctan2tds
    trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/yquant/
    trunk/Master/texmf-dist/doc/latex/yquant/README.md
    trunk/Master/texmf-dist/doc/latex/yquant/yquant-doc.pdf
    trunk/Master/texmf-dist/doc/latex/yquant/yquant-doc.tex
    trunk/Master/texmf-dist/tex/latex/yquant/
    trunk/Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex
    trunk/Master/texmf-dist/tex/latex/yquant/yquant-config.tex
    trunk/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
    trunk/Master/texmf-dist/tex/latex/yquant/yquant-env.tex
    trunk/Master/texmf-dist/tex/latex/yquant/yquant-lang.tex
    trunk/Master/texmf-dist/tex/latex/yquant/yquant-langhelper.tex
    trunk/Master/texmf-dist/tex/latex/yquant/yquant-registers.tex
    trunk/Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex
    trunk/Master/texmf-dist/tex/latex/yquant/yquant-tools.tex
    trunk/Master/texmf-dist/tex/latex/yquant/yquant.sty
    trunk/Master/tlpkg/tlpsrc/yquant.tlpsrc

Added: trunk/Master/texmf-dist/doc/latex/yquant/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/yquant/README.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/yquant/README.md	2020-03-24 20:57:29 UTC (rev 54527)
@@ -0,0 +1,131 @@
+# yquant
+Typesetting quantum circuits in a human-readable language
+
+yquant is a LaTeX package that allows to quickly draw quantum circuits. It bridges the gap between the two groups of packages that already exist: those that use a logic-oriented custom language, which is then translated into TeX by means of an external program; and the pure TeX versions that mainly provide some macros to allow for an easier input.
+yquant is a pure-LaTeX solution - i.e., it requires no external program - that introduces a logic oriented language and thus brings the best of both worlds together.
+It builds on and interacts with TiKZ, which brings an enourmous flexibility for customization of individual circuit.
+
+A detailed reference with lots of examples is provided in the PDF version of this Readme. We will sketch some basic usage.
+
+## 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.
+
+### Simple teleportation circuit
+![ex-01.png](https://github.com/projekter/yquant/raw/master/markdown/ex-01.png)
+```LaTeX
+\begin{tikzpicture}
+  \begin{yquant}
+    qubit {$\ket{\reg_{\idx}}$} q[3];
+
+    h q[1];
+    cnot q[2] | q[1];
+    cnot q[1] | q[0];
+    h q[0];
+    measure q[0-1];
+
+    z q[2] | q[1];
+    x q[2] | q[0];
+  \end{yquant}
+\end{tikzpicture}
+```
+
+### Three-qubit phase estimation circuit with QFT and controlled-U
+![ex-02.png](https://github.com/projekter/yquant/raw/master/markdown/ex-02.png)
+```LaTeX
+\begin{tikzpicture}
+  \begin{yquant}
+    qubit {$\ket{j_{\idx}} = \ket0$} j[3];
+    qubit {$\ket{s_{\idx}}$} s[2];
+
+    h j;
+    box {$U^4$} (s) | j[0];
+    box {$U^2$} (s) | j[1];
+    box {$U$} (s) | j[2];
+    h j[0];
+    box {$S$} j[1] | j[0];
+    h j[1];
+    box {$T$} j[2] | j[0];
+    box {$S$} j[2] | j[1];
+    h j[2];
+    measure j;
+  \end{yquant}
+\end{tikzpicture}
+```
+
+### Three-qubit FT QEC circuit with syndrome measurement
+![ex-03.png](https://github.com/projekter/yquant/raw/master/markdown/ex-03.png)
+```LaTeX
+\begin{tikzpicture}
+  \begin{yquant}
+    qubit {$\ket{q_{\idx}}$} q[3];
+    qubit {$\ket{s_{\idx}} = \ket0$} s[2];
+    cbit {$c_{\idx} = 0$} c[2];
+
+    h s[0];
+    cnot s[1] | s[0];
+    cnot s[0] | q[0];
+    cnot s[1] | q[1];
+    cnot s[1] | s[0];
+    h s[0];
+    measure s;
+    cnot c[0] | s[0];
+    cnot c[1] | s[1];
+    discard s;
+
+    init {$\ket0$} s;
+    h s[0];
+    cnot s[1] | s[0];
+    cnot s[0] | q[1];
+    cnot s[1] | q[2];
+    cnot s[1] | s[0];
+    h s[0];
+    measure s;
+
+    box {Process\\Syndrome} (s, c);
+    box {$\mathcal R$} (q) | s, c;
+  \end{yquant}
+\end{tikzpicture}
+```
+
+### Error correction
+![ex-04.png](https://github.com/projekter/yquant/raw/master/markdown/ex-04.png)
+```LaTeX
+% \usetikzlibrary{fit, 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;
+    ["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)
+```LaTeX
+\begin{tikzpicture}
+   \begin{yquant*}
+      zz (a[0, 2]);
+      cnot a[1] ~ a[0];
+      zz (a[2, 3]);
+      h a[3] | a[0] ~ a[1];
+      measure a[2, 3];
+      box {$U$} (a[0, 1]) | a[3] ~ a[2];
+      discard a[2, 3];
+   \end{yquant*}
+\end{tikzpicture}
+```
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/latex/yquant/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/yquant/yquant-doc.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/yquant/yquant-doc.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/yquant/yquant-doc.pdf	2020-03-24 20:54:13 UTC (rev 54526)
+++ trunk/Master/texmf-dist/doc/latex/yquant/yquant-doc.pdf	2020-03-24 20:57:29 UTC (rev 54527)

Property changes on: trunk/Master/texmf-dist/doc/latex/yquant/yquant-doc.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/yquant/yquant-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/yquant/yquant-doc.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/yquant/yquant-doc.tex	2020-03-24 20:57:29 UTC (rev 54527)
@@ -0,0 +1,2651 @@
+\documentclass{scrartcl}
+
+\title{yquant.sty package documentation}
+\subtitle{Typesetting quantum circuits in a human-readable language}
+\author{Benjamin Desef}
+
+% BEGIN_FOLD Packages
+\RequirePackage{fontspec}
+\setmainfont{XCharter}[Scale=.98]
+\RequirePackage[osf, semibold]{sourcesanspro}
+\RequirePackage[math-style=ISO, bold-style=ISO, sans-style=italic]{unicode-math}
+
+\usepackage{xcolor}
+\definecolor{darkblue}{RGB}{5, 10, 122}
+\usepackage[english]{babel}
+\usepackage[colorlinks, linkcolor=darkblue, bookmarksdepth=paragraph]{hyperref}
+\usepackage{yquant,braket,hyphenat,microtype,hologo,minted}
+\usetikzlibrary{quotes,fit,shapes.symbols,backgrounds,quantikz}
+\usepackage{amsmath,adjustbox,cleveref}
+\usepackage[framemethod=tikz]{mdframed}
+% END_FOLD
+
+\makeatletter
+
+% BEGIN_FOLD Minted configuration
+\begingroup
+\catcode`\&=11
+% I use Intel Python, which requires using the `activate' command first
+\renewcommand{\MintedPygmentize}{activate && pygmentize}
+\endgroup
+
+\definecolor{boxGrayBody}{gray}{.94}
+\definecolor{boxRedHead} {RGB} {178, 34,  34}
+\definecolor{boxRedBody} {RGB} {255, 255, 192}
+\definecolor{boxBlueHead}{RGB} {118, 152, 199}
+\definecolor{boxBlueBody}{RGB} {242, 247, 255}
+\definecolor{mintgreen}  {RGB} {11,  97,  11}
+\setminted{frame=none, linenos=false, fontsize=\footnotesize, breaklines, bgcolor=boxGrayBody}
+\setmintedinline{bgcolor={}, fontsize=}
+
+\newmintinline[yquant]{text}{}
+\newmintinline[tex]{tex}{}
+\newmintinline[ebnf]{ebnf}{}
+% END_FOLD
+
+% BEGIN_FOLD Block environments (options, code examples, ...)
+\def\unskipOpt{\vskip-5mm }
+\let\unpatched at minted@inline at iii=\minted at inline@iii%
+\def\patched at minted@inline at iii#1{%
+   \unpatched at minted@inline at iii{#1}%
+   \par%
+   \endgroup\vskip-\parskip%
+   \noindent\ignorespaces%
+}
+\newenvironment{option}[1]{\vskip5mm%
+   \noindent\begin{minipage}[t]{\linewidth}%
+      \begingroup%
+         \let\minted at inline@iii=\patched at minted@inline at iii%
+         \raggedleft%
+         \hspace*{-1cm}%
+         \phantomsection\label{style:/yquant/#1}%
+         \texttt{\textcolor{gray}{/yquant/}\textcolor{mintgreen}{#1}}\hfill default: %
+         \tex}{%
+   \end{minipage}}
+
+\newsavebox\codeexamplebox
+\newenvironment{codeexample}{%
+   \VerbatimEnvironment%
+   \let\FVB at VerbatimOut\minted at FVB@VerbatimOut
+   \let\FVE at VerbatimOut\minted at FVE@VerbatimOut
+   \minted at configlang{tex}%
+   \minted at fvset
+   \begin{VerbatimOut}[codes={\catcode`\^^I=12},firstline,lastline]{\minted at jobname.pyg}%
+}{
+   \end{VerbatimOut}%
+   \minted at langlinenoson%
+   \savebox\codeexamplebox{\input \minted at jobname.pyg}%
+   \ifdim\wd\codeexamplebox>\dimexpr.5\linewidth-3mm\relax%
+      \wd\codeexamplebox=.5\linewidth% squeeze if necessary
+   \else%
+      \wd\codeexamplebox=\dimexpr\wd\codeexamplebox+3mm\relax% else give some space
+   \fi%
+   \noindent\begin{minipage}{\wd\codeexamplebox}%
+      \centering%
+      \usebox\codeexamplebox%
+   \end{minipage}%
+   \begin{minipage}{\dimexpr\linewidth-\wd\codeexamplebox\relax}%
+      \minted at pygmentize{\minted at lang}%
+   \end{minipage}%
+   \minted at langlinenosoff%
+   \par%
+}
+
+\newenvironment{codeexample*}{%
+   \VerbatimEnvironment%
+   \let\FVB at VerbatimOut\minted at FVB@VerbatimOut
+   \let\FVE at VerbatimOut\minted at FVE@VerbatimOut
+   \minted at configlang{tex}%
+   \minted at fvset
+   \begin{VerbatimOut}[codes={\catcode`\^^I=12},firstline,lastline]{\minted at jobname.pyg}%
+}{
+   \end{VerbatimOut}%
+   \minted at langlinenoson%
+   \begin{adjustbox}{center}
+      \input \minted at jobname.pyg %
+   \end{adjustbox}\nopagebreak
+   \minted at pygmentize{\minted at lang}%
+   \minted at langlinenosoff%
+   \par%
+}
+
+\def\bd at boxextra#1{%
+   \node[anchor=north west] at (current bounding box.north east) {\hskip7pt#1};%
+}
+
+\newcommand*\bd at boxintro[5]{%
+   \begingroup%
+      \setlength{\parskip}{0pt}%
+      \setlength{\parindent}{0pt}%
+      \if\relax\detokenize{#5}\relax%
+         \begin{mdframed}[style=bdBox, backgroundcolor=#4, linecolor=#2,
+                          firstextra=\bd at boxextra{#1}, singleextra=\bd at boxextra{#1}]%
+      \else%
+         \begin{mdframed}[style=bdBox, backgroundcolor=#4,
+                          frametitlefont=\bfseries\sffamily\color{#3},
+                          frametitlebackgroundcolor=#2,
+                          frametitle={\strut#5}, linecolor=#2,
+                          firstextra=\bd at boxextra{#1}, singleextra=\bd at boxextra{#1}]%
+      \fi%
+      \ignorespaces%
+}
+\def\bd at boxoutro{%
+      \end{mdframed}%
+   \endgroup%
+}
+\iffalse% code folding breaks
+   \end{mdframed}
+\fi
+\mdfdefinestyle{bdBox}{
+   skipabove=3pt,
+   skipbelow=0pt,
+   leftmargin=0pt,
+   rightmargin=0pt,
+   innerleftmargin=7pt,
+   innerrightmargin=7pt,
+   innertopmargin=5pt,
+   innerbottommargin=5pt,
+   splittopskip=17pt,
+   frametitlealignment=\raggedright,
+   frametitleaboveskip=3pt,
+   frametitlebelowskip=1.5pt
+}
+\newenvironment*{warning}[1][]{%
+   \bd at boxintro{\raisebox{\baselineskip-\height-6.5pt}{\includegraphics[width=1cm]{Warning.pdf}}}%
+               {boxRedHead}{white}{boxRedBody}{#1}%
+   \ignorespaces%
+}{%
+   \bd at boxoutro%
+}
+\newenvironment*{example}[1][]{%
+   \bd at boxintro{\raisebox{\baselineskip-\height-6.5pt}{\includegraphics[width=1cm]{Bulb.png}}}%
+               {boxBlueHead}{white}{boxBlueBody}{#1}%
+   \ignorespaces%
+}{%
+   \bd at boxoutro%
+}
+% END_FOLD
+
+\def\TikZ{\textcolor{brown}{Ti\textit kZ}}
+\def\pkg#1{\textcolor{brown}{\texttt{#1}}}
+\def\gate#1{\hyperref[gate:#1]{\texttt{#1}}}
+\def\style#1{\hyperref[style:#1]{\texttt{#1}}}
+\def\Yquant{\pkg{yquant}}
+\def\ii{{\symup i}}
+\def\ee{{\symup e}}
+\def\ketbra#1#2{\ket{#1}\!\bra{#2}}
+
+\frenchspacing
+\RequirePackage{scrlayer-scrpage}
+\setcounter{tocdepth}{\subsectiontocdepth}
+\KOMAoptions{DIV=8}
+\addtokomafont{section}{\clearpage}
+\recalctypearea
+
+\begin{document}
+   \maketitle
+   \begin{abstract}
+      \noindent This manual introduces \Yquant, a \LaTeX\hyp only package that outputs quantum circuits.
+      They are entered using a human\hyp readable language that, even from the source code, allows for a fluent understanding of the logic that underlies the circuit.
+      \Yquant{} internally builds on \TikZ{} and can be easily combined with arbitrary \LaTeX{} code.
+      More than forty pages of examples complement the formal manual.
+   \end{abstract}
+   \tableofcontents
+   
+   \clearpage
+   \section{Introduction}
+      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 not yet available on CTAN.
+      This alpha version~0.1.1 \emph{should} be stable and interfaces are not very likely to change in an incompatible way in the future.
+      Please do report all issues and desirable additions.
+      
+      \subsection{How to read the manual}
+         The probably fastest way to start using \Yquant{} is by just scanning through the examples in \cref{sec:examples}.
+         A more formal description of the \Yquant{} grammar and its fundamental concepts can be found in \cref{sec:grammar}.
+         If your desire is to change the appearance of \Yquant{} elements, use the configuration reference in \cref{sec:config}.
+         The full list of all available gates is provided in \cref{sec:gates}.
+         Finally, you may find that \Yquant{} \emph{almost} does what you want, but there is some final tweak that you cannot achieve\dots.
+         Then, have a look at \cref{sec:tikz} (or \cref{sec:alt}).
+      
+      \subsection{Installation}
+         At the moment, clone this repository or download a copy and extract the files to a path visible to your \TeX{} compiler.
+         For example, you may put them in the same directory as your document (if you just want to give a try), or you may extract them to \texttt{tex/latex/yquant} in your local \texttt{texmf} (followed by an update of the file name database).
+      
+      \subsection{Purpose of \Yquant, alternatives}\label{sec:alt}
+         \Yquant{} is the acronym for ``yet another quantum circuit package.''
+         This highlights the fact that nothing that this package provides cannot be achieved by other means.
+         In particular, there are at least the following methods to typeset quantum circuits in \TeX.
+         \begin{itemize}
+            \item Use some external program to draw them and include the output via \tex!\includegraphics!.
+            \item Use either \TeX's own drawing capabilities (the \tex!picture! environment) or other drawing packages such as \TikZ{} or \pkg{pstricks}.
+            \item Use a package specifically designed to draw quantum circuits (if you feel some other package should be mentioned here, please file an issue):
+               \begin{itemize}
+                  \item \pkg{qasm} is probably the first of them (in terms of age).
+                     It was developed to typeset the circuits found in Nielsen and Chuang's famous \emph{Quantum Computation and Quantum Information} book.
+                     \pkg{qasm} consists of a Python~2 script (\texttt{qasm2circ}) that reads a quantum circuit written in a very intuitive language: declare names for your qubits, perform gates on them in each line.
+                     \texttt{qasm2circ} converts those circuits into \TeX{} files that internally make use of the \pkg{xy} package to display the output.
+                     Consequently, the user is restricted to the set of features that \pkg{qasm} directly offers (which is small).
+                     Changes to the output, while possible, will be overwritten if \texttt{qasm2circ} is run again.
+                     \pkg{qasm} output often looks sub\hyp optimal do to the fact that, e.g., rectangles are made up of four lines that do not properly connect and give a crumbly general feeling.
+                     
+                     Maintenance status: last update of \pkg{qasm} in 2005. Also, \pkg{xy} was last updated in 2013, and the script is not compatible out\hyp of\hyp the\hyp box with Python~3, though an automatic conversion should work.
+                  \item \pkg{qcircuit} is probably the most\hyp widely used package.
+                     It provides commands that make it much easier to create quantum circuits using the \pkg{xy} package.
+                     Its syntax therefore is grid\hyp oriented; inferring what a circuit does or locating a gate in the code can be tough.
+                     This is particularly true for multi\hyp qubit gates.
+                     Additionally, the \tex!\xymatrix! syntax is also somewhat cryptic.
+                     \pkg{qcircuit} provides some flexibility within the limits of \pkg{xy} as to configuring the output.
+                     
+                     Maintenance status: last update in 2018; and remember this is \pkg{xy} based, with last update in 2013.
+                  \item \pkg{quantikz} is a relatively recent package that, following the same grid\hyp based approach as \pkg{qcircuit}, instead builds on \TikZ{} as a backend.
+                     As a consequence, it provides the full flexibility of customization that \TikZ{} offers, where hardly anything cannot be done.
+                     It also reduces burdens of the \pkg{xy} syntax.
+                     However, the disadvantages of the grid\hyp based syntax still remain.
+                     
+                     Maintenance status: last update in 2019; the underlying \TikZ{} is actively maintained again by now.
+                  \item \pkg{qpic} follows the approach of \pkg{qasm}: It makes use of an external Python program that reads the quantum circuits in an own language and converts them into \TikZ{} commands.
+                     The language \pkg{qpic} follows is much more powerful than \pkg{qasm}'s.
+                     The disadvantage that modifications in the output code will not remain after running the Python script again is mitigated by the possibility to define own \TeX{} macros.
+                     Being an external program, \pkg{qpic}'s intrinsic set of features (including, e.g., vertically set circuits) are huge.
+                     However, the language \pkg{qpic} uses cannot be understood without a detailed study of the manual, it appears to have been designed with the aim to minimize the length of command names.
+                     A disadvantage of external programs is that the amount of space gates need is not accessible by the script; hence, manual intervention may be required.
+                     
+                     Maintenance status: last update in 2016; the underlying \TikZ{} is actively maintained, and the script is compatible with Python~3.
+               \end{itemize}
+         \end{itemize}
+      
+      \subsection{License}
+          This work may be distributed and/or modified under the conditions of the \LaTeX{} Project Public License, either version~1.3 of this license or (at your option) any later version.
+          The latest version of this license is in
+          \begin{center}
+             \url{http://www.latex-project.org/lppl.txt}
+          \end{center}
+          and version~1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later.
+   
+   \section{Basic elements of \Yquant}\label{sec:grammar}
+      \Yquant, as some of the aforementioned packages, builds on \TikZ.
+      Its basic syntax is similar to \pkg{pgfplots}: Start a \tex!tikzpicture! environment (perhaps passing some options); inside, start a \tex!yquant! environment.
+      
+      Inside the \tex!yquant! environment, \TeX{} will now understand the \Yquant{} language---so \Yquant{} falls into the same category as \pkg{qasm} and \pkg{qpic}, providing a human\hyp readable language for the specification of the circuit that is not fixed to the actual layout.
+      
+      However, \Yquant{} is a \TeX\hyp only package (actually, \hologo{LaTeX2e}, but not \hologo{LaTeX3}) that requires no external script to run---so it also falls into the same category as \pkg{qcircuit} and \pkg{quantikz}.
+      
+      Since it runs entirely within \TeX, you can at any time interject \Yquant{} code with arbitrary \TeX{} or \TikZ{} code (though if it is ``too arbitrary,'' you may need to restart the \Yquant{} interpreter).
+      
+      \subsection{General usage}
+         \begin{minted}{tex}
+% preamble: \usepackage{yquant}
+\begin{tikzpicture}% tikz options possible
+   % tikz commands go here
+   \begin{yquant}% yquant options possible. Watch the newlines!
+      % yquant and tikz commands go here
+   \end{yquant}
+   % tikz commands go here
+\end{tikzpicture}
+         \end{minted}
+         
+         Note that \Yquant{} depends on \pkg{etoolbox}, \TikZ, and \pkg{trimspaces}.
+         Additionally, it requires a moderately recent version of \hologo{LaTeX2e}, using either \hologo{LuaLaTeX}, or (untested), \hologo{pdfLaTeX} or \hologo{XeLaTeX}.
+         
+         \begin{warning}[Optional arguments]
+            The optional arguments for the \tex!yquant! environment have to appear \emph{on the same line} as the environment itself.
+            If you want to put the arguments into a new line, it is crucial to mask the line break by putting a comment symbol after the environment: \tex!\begin{yquant}%!.
+            Without this comment, \Yquant{} will detect your line break (this is one of the few places in \TeX{} where line breaks and spaces are different) and assume that the expression in square brackets instead provides arguments for the following operation!
+         \end{warning}
+      
+      \subsection{Starred vs. unstarred environment}
+         You may choose to use either the \tex!yquant! or the \tex!yquant*! environment.
+         The former one requires you to define all your registers before you use them (though you may decide to define a register after some operations on \emph{different} registers, but before its first usage).
+         
+         The starred form additionally supports the use of undeclared registers: it basically declares a registers upon its first usage.
+         This will always be a \texttt{qubit} register; but if you use the corresponding option and the first usage is an \gate{init} command, you may overwrite this.
+         
+         Additionally, if you refer to the index $i$ of a vector register of length $L < i$, this register will automatically be enlarged to $i \coloneq L$.
+         It is also possible to convert a scalar register into a vector register in this manner.
+         To enlarge a register in the unstarred environment, you must precede the number of registers to be added in the second declaration by a plus sign.
+         Note that in this manner, you may even create discontiguous vectors.
+         
+         \emph{This might be a good point to proceed to the examples \cref{sec:examples}.}
+      
+      \subsection{Formal syntax}
+         Every \Yquant{} command has the same structure (described here in EBNF syntax):
+         \begin{minted}{ebnf}
+Command = { Arguments }, ?command?, [ Value ], [ RegisterList ], Controls, ";";
+Arguments = "[", ?pgfkeys?, "]";
+Value = "{", ?TeX code?, "}";
+Controls = [ "|", [ RegisterSingleList ] ], [ "~", [ RegisterSingleList ] ];
+
+RegisterList = (RegisterSingle | RegisterMulti), [ ",", RegisterList ];
+RegisterSingleList = RegisterSingle, [ ",", RegisterSingleList ];
+
+RegisterSingle = RegisterSingleNoRange | RegisterRange;
+RegisterSingleNoRange = ?name?, [ "[", IndexMultiList, "]" ];
+RegisterMulti = "(", ( RegisterMultiNoRange | RegisterRange ), ")";
+RegisterMultiNoRange = ?name?, [ "[", IndexSingleList, "]" ];
+RegisterRange = [ RegisterUnique ], "-", [ RegisterUnique ];
+RegisterUnique = ?name?, [ "[", ?number?, "]" ];
+
+IndexMultiList = IndexMulti, [ ",", IndexMulti ];
+IndexSingleList = IndexSingle, [ ",", IndexSingle ];
+IndexMulti = IndexSingle | ( "(", IndexSingle, ")" );
+IndexSingle = ?number? | ( [ ?number? ], "-", [ ?number? ] );
+         \end{minted}
+         Note that \Yquant{} is quite tolerant with respect to whitespaces.
+         Virtually every comma in the EBNF notation may consist of an arbitrary (including zero) number of whitespaces.
+         
+         Valid values for
+         \begin{BVerbatim}[commandchars=\\\{\}]
+\PYG{n+ni}{?command?}
+         \end{BVerbatim}
+         \space (case\hyp insensitive) are documented in a \cref{sec:gates}.
+         We use
+         \begin{BVerbatim}[commandchars=\\\{\}]
+\PYG{n+ni}{?pgfkeys?}
+         \end{BVerbatim}
+         \space to describe any valid content passed to the \tex!\pgfkeys! macro (rather, \tex!\yquantset! is invoked with some subtleties); and by
+         \begin{BVerbatim}[commandchars=\\\{\}]
+\PYG{n+ni}{?name?}
+         \end{BVerbatim}
+         \space we denote any valid register name.
+         Register names must not contain any of the control literals used before (semicolon, comma, parentheses, square brackets, dash, pipe, tilde); and you should avoid using special \TeX{} characters.
+         Note that for performance reasons, \Yquant{} does not check whether a register name is valid or not, but expect to either see unintended output or not\hyp so\hyp helpful error messages if you choose an invalid name.
+         \begin{BVerbatim}[commandchars=\\\{\}]
+\PYG{n+ni}{?number?}
+         \end{BVerbatim}
+         \space is a decimal integer larger or equal to zero (in the context of register creation, strictly larger; in this context, it may also contain a leading
+         \begin{BVerbatim}[commandchars=\\\{\}]
+\PYG{l+s+s2}{\PYGZdq{}+\PYGZdq{}}
+         \end{BVerbatim}
+         ).
+         
+      \subsection{Registers}
+         Every quantum circuit is structured by means of \emph{registers}.
+         A register has a \emph{type} that specifies how its wire is drawn, and that may even change during its lifetime.
+         At the moment, \Yquant{} supports four types:
+         \begin{enumerate}
+            \item \gate{qubit} is the most common type, used for a quantum register.
+               It corresponds to a single line.
+            \item \gate{cbit} is a classical register, which can be either declared from the beginning or arises by using measurements.
+               It corresponds to a double line.
+            \item \gate{qubits} is a ``quantum bundle,'' i.e., a bunch of quantum registers that are always addressed in a group as a single register.
+               Operations between bundles of the same length should be interpreted as transversal.
+               It corresponds to a triple line.
+               An alternative (and more common) representation is to use the \gate{qubit} type and a \gate{slash} gate at its very beginning.
+            \item \gate{nobit} is the most obscure type, corresponding to a non\hyp existing wire.
+               Mostly, this register type arises by using the \gate{discard} command.
+               However, it can also be directly declared, which on rare occasions might be necessary (its type can then be changed by means of an \gate{init} or \gate{setwire} pseudo\hyp gate).
+               If you want to declare a register only at a certain horizontal position in the circuit, consider using the \texttt{after} argument instead.
+         \end{enumerate}
+         
+         Registers must be declared before they can be used (though in the \tex!yquant*! environment, this declaration may be implicit, creating a \gate{qubit} register).
+         
+         Registers can have a vector character, i.e., not only a \emph{name}, but also an \emph{index} (or, in the declaration, a \emph{length}).
+         The index (zero\hyp based) or length is specified in square brackets following the name, which closely mimics the OpenQASM language.
+         
+         Since version 0.1.1, vector registers may be non\hyp contiguous: Whenever you create a bunch of registers, it is put at the bottom of the circuit.
+         If you later on again create registers of the same name---either implicitly in the \tex!yquant*! environment, or explicitly by preceding the length of the vectors entries to be added by a plus, as in \yquant!qubit a[+3];!---they will be put to what is \emph{now} the bottom of the circuit, even if some other registers are interspersed.
+         
+         Registers are referenced---i.e., used in operations---by their name and index.
+         If the latter is omitted, all indices of the register are targeted.
+         Multiple registers can be referenced by joining their names in a comma\hyp separated list, or by means of a range specifier: give the name of the first (topmost), a dash, and the last (bottom\hyp most) register.
+         Both are inclusive.
+         In a range specifier, omitting the start name means that the range begins at the first known register; omitting the end name means that the range ends at the last known (at the moment of its use) register.
+         Omitting both indicates a range over all known registers.
+         
+         Since version 0.1.1, it is also possible to use comma\hyp separated lists and ranges within the indices themselves, so that, e.g., \yquant!a[0, 2, 5-], b[-2]! will target the zeroth and second index of \yquant!a!; the remaining indices of \yquant!a! starting from five; and the first three indices of \yquant!b!.
+         However, if you use an \emph{outer} range (i.e., a range between indices of registers with different names), the initial and final register of the range must be unique, i.e., either you omit the index (targeting the first or last register with the given name) or specify a single one.
+         
+         \begin{warning}[Ranges and discontiguous registers]
+            Assume a configuration in which the vector register \yquant!a! begins with one qubit, then the single register \yquant!b! follows, and after that \yquant!a! is continued with another qubit.
+            
+            The range \yquant!a-b! will target \yquant!a[0]! and \yquant!b[0]!, but not \yquant!a[1]!.
+            As \yquant!a! is used as the initial register in the range without an explicit index specification, \Yquant{} automatically translates this into \yquant!a[0]!, while \yquant!b!, being used as the final register, is automatically translated into the last register of name \yquant!b! (which here happens to be \yquant!b[0]!).
+            Ranges between different register names (outer ranges) are \emph{visual} ranges, i.e., they refer to the top\hyp to\hyp bottom order that is visible.
+            Consequently, the register \yquant!a[1]! is left out since it is visually below the others.
+            
+            Likewise, the range \yquant!b-a! will target \yquant!b[0]! and \yquant!a[1]!.
+            
+            Ranges within indices are \emph{logical} ranges.
+            Hence, \yquant!a!, \yquant!a[-]!, \yquant!a[0-]!, \yquant!a[-1]!, and \yquant!a[0-1]! are all equivalent: they all refer to the registers \yquant!a[0]! and \yquant!a[1]!, but never to \yquant!b!, regardless of any visual position.
+         \end{warning}
+         
+         All that was said so far refers to the operation being carried out on each of the registers \emph{individually}, i.e., producing several copies of the operation.
+         This is different from using the operation multiple times on the individual single registers only with regard to the vertical positioning: if specified as a register list with one operation, all copies of the operation will be aligned at the same vertical position (as if an \gate{align} command had been carried out before).
+         \begin{warning}
+            It is forbidden (in the sense of ``not useful,'' but \Yquant{} does not check for this) to list the same register multiple times (explicitly or via ranges) in one operation.
+         \end{warning}
+         
+         Instead of copies of single\hyp register operations, one might want to carry out a multi\hyp register operation.
+         In this case, the desired list of registers (comma separated, range, or both) must be surrounded by parentheses.
+         It is possible to mix single- and multi\hyp register operations arbitrarily.
+         In an index list, you may also choose to surround only certain indices with parenthesis, provided the whole register is not already a multi\hyp register.
+         \begin{warning}
+            Note that some gates, such as the \gate{swap} gate, always require multi\hyp register operations with a fixed number of constituents; others, such as the \gate{slash} pseudo\hyp gate always require single\hyp register operations.
+            Again others are completely flexible.
+            \Yquant{} will prevent you from using a gate in a multi\hyp qubit setting when it may only be used for single registers.
+            All other types of validity checks are up to the user.
+         \end{warning}
+      
+      \subsection{Arguments}
+         Every command may take one or multiple arguments.
+         Those are specified in square brackets that precede the command itself.
+         The content of those square brackets is essentially fed to a \tex!\pgfkeys!-like macro.
+         The default path is set appropriately such that the arguments of the command can be accessed without and path specifiers.
+         If the key is not a valid argument for the command or a global argument and it is not given by an absolute path, it is searched for in the \texttt{/yquant} namespace.
+         If it cannot be found there, it is passed to \style{/yquant/operator style}.
+         
+         Note that commands may have required arguments.
+         If a required argument is missing, an error will be issued.
+         
+         The \texttt{value} attribute can alternatively be given inside curly brackets after the command name and before the register specification.
+         This has the advantage that special characters such as a closing square bracket need not be escaped.
+         If both alternatives are present, the value inside curly brackets takes precedence and a warning is issued.
+      
+      \subsection{Controls}
+         Lots of gates may have controls, i.e., they are only to be executed if some other gate is set or unset.
+         The former case is called a \emph{positive control}, the latter one a \emph{negative control}.
+         Those are indicated by filled and empty circles on the control registers and a vertical line that joins the registers that belong together.
+         
+         The gate specification is followed by the list of target registers.
+         By then writing a pipe (``\yquant!|!''), the list of positive controls is introduced; this mimics the mathematical syntax ``conditioned on'' for probabilities or ``given'' for sets.
+         If there are no positive controls, the list may be empty or, together with the pipe, omitted.
+         Preceded by a tilde (``\yquant!~!''), the list of negative controls then follows; this mimics the syntax of many programming languages that denote logical negation by a tilde.
+         If there are no negative controls, the list may be empty or, together with the pipe, omitted.
+      
+   \section{Configuration}\label{sec:config}
+      \Yquant{} uses \pkg{pgfkeys} to control its options, which are located in the path \texttt{/yquant}.
+      The following list contains all options and styles that are recognized, apart from gate arguments.
+      Those are listed together with their operations.
+      
+      \subsection{Circuit layout}\unskipOpt
+         \begin{option}{register/minimum height}!3mm!
+            \Yquant{} automatically determines the total height of a register as the height of the largest operation.
+            This might be too small for two reasons:
+            \begin{itemize}
+               \item if the register is used only with small gates (e.g., only as a control, or as a swap), and it does not have a label (or one containing only x\hyp height letters).
+               \item if the register is used only with multi\hyp qubit gates.
+                  For those, \Yquant{} cannot decide where to put the height---and it is easy to see that an equal distribution over all affected registers is not necessarily a good solution.
+                  Hence, multi\hyp qubit gates are ignored in the height calculation.
+                  Usually, this is not a problem since those operations are large enough as they take the height of all involved registers and separations.
+            \end{itemize}
+            This key provides an easy alleviation of the problem by requiring a minimal height for every register.
+         \end{option}
+         
+         \begin{option}{register/separation}!1mm!
+            This key controls the amount of vertical space that is inserted between two successive registers.
+         \end{option}
+         
+         \begin{option}{operator/minimum width}!3mm!
+            \Yquant{} automatically determines the width of an operator according to its content.
+            However, single\hyp letter boxes are among the most common operators, and giving them slightly different widths would result in a very uneven spacing, as \Yquant{} does not use a grid layout but stacks the operators horizontally one after each other.
+            Hence, this key provides a minimum width that will be set for every operator.
+            This does not imply that the \emph{visual} appearance (i.e., the \texttt{x radius} key) is enlarged, but that operators of a smaller actual width will be centered in a virtual box of the minimum width.
+         \end{option}
+         
+         \begin{option}{operator/separation}!1mm!
+            This key controls the amount of horizontal space that is inserted between two successive operators.
+         \end{option}
+      
+      \subsection{Register creation}\unskipOpt
+         \begin{option}{register/default name}!\regidx!
+            The printed name that is used by default if a new register is created explicitly (\gate{qubit}, \gate{cbit}, \gate{qubits}; not used for \gate{nobit} or for implicit declarations) and no value is specified.
+            The following macros are available:
+            \begin{itemize}
+               \item \tex!\reg! contains the internal name that is used to identify this register.
+               \item \tex!\idx! contains the index (zero\hyp based) of the current register within a vector register.
+               \item \tex!\regidx! expands to \tex!\reg! if the register is of length one, and to \tex!\reg[\idx]! else.
+               \item \tex!\len! contains the length of the current register vector.
+            \end{itemize}
+         \end{option}
+         
+         \begin{option}{every label}!shape=yquant-text, anchor=circuit, align=right!
+            This style is installed for every single register name label (i.e., upon creation and when used with the \gate{init} gate).
+            The default style allows to use line breaks in the labels.
+         \end{option}
+         
+         \begin{option}{every initial label}!anchor=east!
+            This style is installed for every single register name label at the left border of the circuit.
+            Hence, it is only used for the \gate{init} gate if in the \tex!yquant*! environment, the gate occurs for a new register (which allows to override the default register type).
+         \end{option}
+         
+         \begin{option}{every qubit label}!!
+            This style is installed for every single register name label of a register of type \gate{qubit}.
+         \end{option}
+         
+         \begin{option}{every cbit label}!!
+            This style is installed for every single register name label of a register of type \gate{cbit}.
+         \end{option}
+         
+         \begin{option}{every qubits label}!!
+            This style is installed for every single register name label of a register of type \gate{qubits}.
+         \end{option}
+         
+         \begin{option}{every multi label}!shift={(-.075, 0)}, draw, decoration={brace, mirror, pre=moveto, pre length=-1mm, post=moveto, post length=-1mm}, decorate, every node/.append style={shape=yquant-text, anchor=east, align=right, midway, shift={(-.025, 0)}}!
+            This style is installed for every register name label that is attached to a multi\hyp qubit register by means of the \gate{init} gate.
+            \Yquant{} additionally inserts a straight line that connects the topmost and the bottom\hyp most register at their left ends.
+            The default style turns this line into a brace and places the description at the appropriate position.
+         \end{option}
+      
+      \subsection{Register outputs}\unskipOpt
+         \begin{option}{every output}!shape=yquant-text, anchor=west, align=left!
+            This style is installed for every \gate{output} label at the end of the circuit.
+            The default style allows to use line breaks in the labels.
+         \end{option}
+         
+         \begin{option}{every qubit output}!!
+            This style is installed for every \gate{output} label of a register of type \gate{qubit}.
+         \end{option}
+         
+         \begin{option}{every cbit output}!!
+            This style is installed for every \gate{output} label of a register of type \gate{cbit}.
+         \end{option}
+         
+         \begin{option}{every qubits output}!!
+            This style is installed for every \gate{output} label of a register of type \gate{qubits}.
+         \end{option}
+         
+         \begin{option}{every multi output}!shift={(.075, 0)}, draw, decoration={brace, pre=moveto, pre length=-1mm, post=moveto, post length=-1mm}, decorate, every node/.append style={shape=yquant-text, anchor=west, align=left, midway, shift={(.025, 0)}}!
+            This style is installed for every \gate{output} label that is attached to a multi\hyp qubit register.
+            \Yquant{} additionally inserts a straight line that connects the topmost and the bottom\hyp most register at their right ends.
+            The default style turns this line into a brace and places the description at the appropriate position.
+         \end{option}
+      
+      \subsection{General styling}\unskipOpt
+         \begin{option}{every circuit}!!
+            Style that is installed for every \tex!yquant! and \tex!yquant*! environment, as if it had been given as an option.
+            The style's default path is \texttt{/yquant}, in contrast to all other styles that operate in the \texttt{/tikz} path by default.
+         \end{option}
+         
+         \begin{option}{every wire}!draw!
+            This style is installed whenever a wire is drawn.
+         \end{option}
+         
+         \begin{option}{every qubit wire}!!
+            This style is installed whenever a wire for a register of type \gate{qubit} is drawn.
+         \end{option}
+         
+         \begin{option}{every cbit wire}!!
+            This style is installed whenever a wire for a register of type \gate{cbit} is drawn.
+         \end{option}
+         
+         \begin{option}{every qubits wire}!!
+            This style is installed whenever a wire for a register of type \gate{qubits} is drawn.
+         \end{option}
+         
+         \begin{option}{every control line}!draw!
+            This style is used to draw the vertical control line that connects controlled operations and their controls.
+         \end{option}
+         
+         \begin{option}{every control}!shape=yquant-circle, anchor=circuit, radius=.5mm!
+            This style is used to draw the node for a control, both positive and negative.
+         \end{option}
+         
+         \begin{option}{every positive control}!fill=black!
+            This style is installed for every positive control (i.e., one that conditions on the register being in state $\ket1$ or $1$).
+         \end{option}
+         
+         \begin{option}{every negative control}!draw!
+            This style is installed for every negative control (i.e., one that conditions on the register being in state $\ket0$ or $0$).
+         \end{option}
+         
+         \begin{option}{every operator}!anchor=circuit!
+            This style is installed for every gate (and also pseudo\hyp gates such as the \gate{slash} operator) that acts on one or multiple registers.
+         \end{option}
+         
+         \begin{option}{this operator}!!
+            This style is appended to the current style installed for an operator; it should be used only locally to overwrite any global configuration effect.
+         \end{option}
+         
+         \begin{option}{this control}!!
+            This style is appended to the current style installed for a control; it should be used only locally to overwrite any global configuration effect.
+         \end{option}
+         
+         \begin{option}{operator style}!/yquant/this operator/.append style={#1}!
+            This is a shorthand that can be used to modify the appearance of the current operator.
+         \end{option}
+         
+         \begin{option}{control style}!/yquant/every control line/.append style={#1}, /yquant/this control/.append style={#1}!
+            This is a shorthand that can be used to modify the appearance of the current control and its associated line.
+         \end{option}
+         
+         \begin{option}{style}!/yquant/operator style={#1}, /yquant/control style={#1}!
+            This is a shorthand that modifies the appearance of both the current operator and any controls or control lines.
+         \end{option}
+      
+      \subsection{Styles for operators}\unskipOpt
+         \begin{option}{operators/every barrier}!shape=yquant-barrier, x radius=\pgflinewidth, dashed, draw!
+            This style is installed for every \gate{barrier} pseudo\hyp gate, i.e., the one that is used to explicitly denote a separation between ``before'' and ``after'' within the circuit.
+            The \texttt{yquant-barrier} shape is a vertical line of width \texttt{x radius}.
+         \end{option}
+      
+         \begin{option}{operators/every box}!shape=yquant-rectangle, draw, align=center, inner xsep=1mm, x radius=2mm, y radius=2.47mm!
+            This style is installed for every \gate{box} operator.
+         \end{option}
+         
+         \begin{option}{operators/every dmeter}!shape=yquant-dmeter, x radius=2mm, y radius=2mm, fill=white, draw!
+            This style is installed for every \gate{dmeter} gate.
+            The \texttt{yquant-dmeter} shape consists of a rectangle whose right side is replaced by a circle, resembling the letter ``D.''
+         \end{option}
+         
+         \begin{option}{operators/every h}!/yquant/operators/every box!
+            This style is installed for every \gate{h} (Hadamard) operator.
+         \end{option}
+         
+         \begin{option}{operators/every measure}!shape=yquant-measure, x radius=4mm, y radius=2.5mm, draw!
+            This style is installed for every \gate{measure} gate.
+            The \texttt{yquant-measure} shape is a rectangle that contains a ``meter'' symbol.
+            It allows for a text to be put inside (e.g., a basis), which then shifts the meter symbol accordingly.
+         \end{option}
+         
+         \begin{option}{operators/every measure meter}!draw, -{Latex[length=2.5pt]}!
+            This style is applied to the path that resembles the ``meter'' symbol that is drawn by the \texttt{yquant-measure} shape.
+            Due to the default style, the \TikZ{} library \pkg{arrows.meta} is automatically loaded with \Yquant.
+         \end{option}
+         
+         \begin{option}{operators/every not}!shape=yquant-oplus, radius=1.3mm, draw!
+            This style is installed for every \gate{not} or \gate{cnot} gate (which are synonyms, and actually do the same as the Pauli~$\sigma_x$ gate).
+            The \texttt{yquant-oplus} shape resembles the addition\hyp modulo\hyp two symbol $\oplus$.
+         \end{option}
+         
+         \begin{option}{operators/every pauli}!/yquant/operators/every box!
+            This style is installed for every Pauli operator, i.e., \gate{x}, \gate{y}, and \gate{z}.
+         \end{option}
+         
+         \begin{option}{operators/every phase}!shape=yquant-circle, radius=.5mm, fill!
+            This style is installed for every \gate{phase} gate $\ketbra00 + \ee^{\ii\phi} \ketbra11$.
+         \end{option}
+         
+         \begin{option}{operators/every slash}!shape=yquant-slash, x radius=.5mm, y radius=.7mm, draw!
+            This style is installed for every \gate{slash} pseudo\hyp gate, i.e., the one that is used to indicate that a single register line actually denotes multiple registers.
+         \end{option}
+         
+         \begin{option}{operators/every swap}!shape=yquant-swap, x radius=.75mm, draw!
+            This style is installed for every bipartite \gate{swap} gate that interchanges two qubits.
+            The \texttt{yquant-swap} shape consists of two crosses that are connected by a middle line.
+            The length of the virtual square that contains the crosses is twice the \texttt{x radius} property; the total height (twice \texttt{y radius}) will automatically be set according to the registers involved.
+            Hence, this gate must always act on a two\hyp qubit register.
+         \end{option}
+         
+         \begin{option}{operators/every x}!/yquant/operators/every pauli!
+            This style is installed for every Pauli operator $\sigma_x$, i.e., \gate{x}.
+         \end{option}
+         
+         \begin{option}{operators/every xx}!shape=yquant-xx, x radius=.75mm, draw!
+            This style is installed for every bipartite \gate{xx} gate in symmetrized notation ($\ketbra{++}{++} + \ketbra{+-}{+-} + \ketbra{-+}{-+} - \ketbra{--}{--}$).
+            The \texttt{yquant-xx} shape consists of two open squares that are connected by a middle line.
+            The length of one side in the square is twice the \texttt{x radius} property; the total height (twice \texttt{y radius}) will automatically be set according to the registers involved.
+            Hence, this gate must always act on a two\hyp qubit register.
+         \end{option}
+         
+         \begin{option}{operators/every y}!/yquant/operators/every pauli!
+            This style is installed for every Pauli operator $\sigma_y$, i.e., \gate{y}.
+         \end{option}
+         
+         \begin{option}{operators/every z}!/yquant/operators/every pauli!
+            This style is installed for every Pauli operator $\sigma_z$, i.e., \gate{z}.
+         \end{option}
+
+         \begin{option}{operators/every zz}!shape=yquant-zz, x radius=.5mm, fill, draw!
+            This style is installed for every bipartite \gate{zz} gate (aka \textsc{CPhase}) in symmetrized notation ($\ketbra{00}{00} + \ketbra{01}{01} + \ketbra{10}{10} - \ketbra{11}{11}$).
+            The \texttt{yquant-zz} shape consists of two circles that are connected by a middle line.
+            The radius of the circles is controlled via the \texttt{x radius} property; the total height (twice \texttt{y radius}) will automatically be set according to the registers involved.
+            Hence, this gate must always act on a two\hyp qubit register.
+         \end{option}
+         
+   \section{Doing the impossible}\label{sec:tikz}
+      \Yquant{} will almost certainly never be able to do everything an author has in mind.
+      Sometimes, there is the need to draw something non\hyp standard, and this cannot be implemented in the \Yquant{} language.
+      However, since \Yquant{} is a layer on top of \TikZ, it should be very hard to find something (meaningful) that cannot be done by combining the power of both packages.
+      
+      Before or after any gate, you may interrupt the \Yquant{} instructions to perform arbitrary \TikZ{} path operations.
+      After every such operation, \Yquant{} will automatically restart its parser so that you can fluently jump between \Yquant{} and \TikZ{} code.
+      You can even interject arbitrary \TeX{} code (or, say, low\hyp level \pkg{pgf} commands); however, then, \Yquant{} is not able to restart its parser.
+      For this reason, after the last command in a block of \TeX{} commands, you must issue \tex!\yquant!, which then re\hyp enables the \Yquant{} language.
+      
+      The feature to perform arbitrary \TikZ{} operations is powerful in itself, but would be of limited use were there no way to access the elements in the quantum circuit.
+      \Yquant{} provides a global attribute \texttt{name} that can be assigned to every gate.
+      All quantum operations are in fact \TikZ{} nodes, and the name you give to them then becomes a \TikZ{} name, which you can easily reference to get the coordinates of a particular operator.
+      Note that the name you specify is only available if a single register is targeted.
+      The name is suffixed by \tex!-\idx!, where \tex!\idx! refers to the (zero\hyp based) index of the operation ordered from top to bottom (i.e., if an operator acts on two qubits and should be named \texttt{op}, the topmost operator will be available as \texttt{op-0} and the second as \texttt{op-1}).
+      All controls are also named, suffixed by \tex!-p\idx! or \tex!-n\idx! for positive and negative controls (i.e., the topmost positive control of the previous operator will be available as \texttt{op-p0}).
+      Counters for target registers, positive, and negative controls are all independent.
+      
+      All \Yquant{} shapes have the anchors available you would typically expect from a \TikZ{} shape of the given outline.
+      Additionally, \Yquant{} shapes will have an anchor \texttt{circuit}; and apart from border anchors, they also implement \emph{projection anchors}.
+      As with the former, you will need low\hyp level macros to access these anchors, which are \tex!\pgfpointshapexproj! and \tex!\pgfpointshapeyproj!.
+      They will expect the name of the node as first argument and a \pkg{pgf} point as second argument.
+      This point will be projected onto the shape in horizontal or vertical direction.
+      These special types of anchors are internally used to determine where the intersection of wire and shape is located.
+      
+%      The current version of \Yquant{} does not implement subcircuits yet.
+%      However, this is planned in a future version; by naming a subcircuit, all named operations inside should then also become available (prefixed by the subcircuit's name).
+   
+   \section{Reference: Gates and operations}\label{sec:gates}
+      This section lists all operations \Yquant{} currently understands.
+      It also details all arguments that can be given to customize the operation, apart from \texttt{name}, which is always available.
+      Note that the \tex![value=<value>]! attribute can (and should) alternatively be given as a braced expression that follows the name of the register.
+      
+      \subsection{\texorpdfstring{\yquant!align!}{align}}\label{gate:align}
+         Syntax: \yquant!align <target>;! \\
+         This is an invisible pseudo\hyp gate that enforces all affected registers to share a common horizontal position for their next gate, which is determined by the largest position of all gates involved.
+         It may not span multiple registers and does not allow for controls.
+         
+         \emph{Possible attributes:} none
+      
+      \subsection{\texorpdfstring{\yquant!barrier!}{barrier}}\label{gate:barrier}
+         Syntax: \yquant!barrier <target>;! \\
+         This is a pseudo\hyp gate that denotes some physical barrier that ensures execution with a specific timing; it is basically a visible version of the \hyperref[gate:align]{\yquant!align!} gate, denoted by a vertical line.
+         It may span multiple registers, but does not allow for controls.
+         The style \style{/yquant/operators/every barrier} is installed.
+         
+         \emph{Possible attributes:} none
+         
+      \subsection{\texorpdfstring{\yquant!box!}{box}}\label{gate:box}
+         Syntax: \yquant!box <target> | <pcontrol> ~ <ncontrol>;! \\
+         This is a generic register of a rectangular shape that can be filled with arbitrary content.
+         It may span multiple registers and allows for controls.
+         The style \style{/yquant/operators/every box} is installed.
+         
+         \emph{Possible attributes:}
+         \begin{itemize}
+            \item \yquant![value=<value>]! \\
+               Denotes the content of the box.
+         \end{itemize}
+      
+      \subsection{\texorpdfstring{\yquant!cbit!}{cbit}}\label{gate:cbit}
+         Syntax: \yquant!cbit <name>[<len>];! \\
+         Declares a register of type \texttt{cbit}.
+         
+         \emph{see \hyperref[gate:qubit]{\yquant!qubit!}}
+      
+      \subsection{\texorpdfstring{\yquant!cnot!}{cnot}}\label{gate:cnot}
+         Syntax: \yquant!cnot <target> | <pcontrol> ~ <ncontrol>;! \\
+         This is a synonym for the \gate{not} gate.
+         Note that despite its name, controls are not mandatory and also here, the style \style{/yquant/operators/every not} is installed.
+      
+      \subsection{\texorpdfstring{\yquant!discard!}{discard}}\label{gate:discard}
+         Syntax: \yquant!discard <target>;! \\
+         This is an invisible pseudo\hyp gate that changes the type of all target registers to \gate{nobit}, i.e., no line will be drawn for them.
+         This has effect already for the outgoing line of the last visible gate on the target registers.
+         The gate may not span multiple registers and does not allow for controls.
+         To change into a register type on\hyp the\hyp fly into something different from \gate{nobit}, use the \gate{setwire} pseudo\hyp gate.
+         
+         \emph{Possible attributes:} none
+      
+      \subsection{\texorpdfstring{\yquant!dmeter!}{dmeter}}\label{gate:dmeter}
+         Syntax: \yquant!dmeter <target>;! \\
+         This is a measurement gate, denoted by a ``D'' shape.
+         It changes the type of all targets involved.
+         It may span multiple registers, but does not allow for controls.
+         The style \style{/yquant/operators/every dmeter} is installed.
+         
+         \emph{Possible attributes:}
+         \begin{itemize}
+            \item \yquant![value=<value>]! \\
+               Allows to specify a text that will be included inside the gate, possible enlarging its width.
+               For outside texts, use \TikZ{} \texttt{label}s instead.
+            \item \yquant![type=<qubit|cbit|qubits>]! \\
+               Allows to specify the type into which the affected targets are converted.
+               Default is \gate{cbit}.
+         \end{itemize}
+      
+      \subsection{\texorpdfstring{\yquant!h!}{h}}\label{gate:h}
+         Syntax: \yquant!h <target> | <pcontrol> ~ <ncontrol>;! \\
+         This is a Hadamard gate, $\frac{1}{\sqrt2} \bigl( \ketbra00 + \ketbra01 + \ketbra10 - \ketbra11 \bigr)$, denoted by a rectangle that contains the letter $H$.
+         It may not span multiple registers, but allows for controls. \\
+         The style \style{/yquant/operators/every h} is installed.
+         
+         \emph{Possible attributes:} none
+      
+      \subsection{\texorpdfstring{\yquant!hspace!}{hspace}}\label{gate:hspace}
+         Syntax: \yquant!hspace <target>;! \\
+         This is an invisible pseudo\hyp gate that inserts a certain amount of white space into all target registers.
+         It may not span multiple registers and does not allow for controls.
+         
+         \emph{Possible attributes}:
+         \begin{itemize}
+            \item \yquant![value=<dim>]! (required) \\
+               Gives the amount of white space that is to be inserted. Must be a valid \TeX{} dimension.
+         \end{itemize}
+      
+      \subsection{\texorpdfstring{\yquant!init!}{init}}\label{gate:init}
+         Syntax: \yquant!init <target>;! \\
+         This is a pseudo\hyp gate that (re)initializes a registers to a given state.
+         It may span multiple registers, but does not allow for controls.
+         The style \style{/yquant/every label} is installed.
+         Note that this pseudo\hyp gate, unlike all others, behaves differently if it the first operation acting on a register: in this case, it does not increment the horizontal position, but uses the space available to the left.
+         If it is the first operation, the style \style{/yquant/every initial label} is installed additionally.
+         For multiple registers, the style \style{/yquant/every multi label} is installed at the end, and a path is constructed that extends from the left end of the first to the left end of the last register in the multi\hyp register compound.
+         
+         \emph{Possible attributes:}
+         \begin{itemize}
+            \item \yquant![type=<qubit|cbit|qubits>]! \\
+               Allows to specify the type into which the affected target registers are converted.
+               Default is the type of the first target register that is different from \gate{nobit}, or \gate{qubit} if they all are \gate{nobit}.
+               The style \texttt{/yquant/every <type> label} is installed additionally.
+            \item \yquant![value=<value>]! (required) \\
+               Denotes the label that is printed to the left of the wire.
+               
+               Inside the value, \tex!\idx! expands to the current index within the register list.
+         \end{itemize}
+      
+      \clearpage
+      \subsection{\texorpdfstring{\yquant!measure!}{measure}}\label{gate:measure}
+         Syntax: \yquant!measure <target>;! \\
+         This is a measurement gate, denoted by a rectangle with a meter symbol.
+         It changes the type of all targets involved.
+         It may span multiple registers, but does not allow for controls.
+         The style \style{/yquant/operators/every measure} is installed.
+         
+         \emph{Possible attributes:}
+         \begin{itemize}
+            \item \yquant![type=<qubit|cbit|qubits>]! \\
+               Allows to specify the type into which the affected targets are converted.
+               Default is \gate{cbit}.
+            \item \yquant![value=<value>]! \\
+               Allows to specify a text that will be included at the bottom of the rectangle (which will shift the meter symbol upwards accordingly).
+               For outside texts, use \TikZ{} \texttt{label}s instead.
+         \end{itemize}
+         
+      \subsection{\texorpdfstring{\yquant!nobit!}{nobit}}\label{gate:nobit}
+         Syntax: \yquant!nobit <name>[<len>];! \\
+         Declares a register of type \gate{nobit}.
+         The \texttt{<name>} must be a self\hyp chosen name for the register which was not previously used as a register name in this \tex!yquant! environment.
+         Names are case\hyp insensitive.
+         The register can be made into a vector register by specifying \texttt{<len>} (default \tex!1!).
+         
+         \emph{Possible attributes:} none
+      
+      \subsection{\texorpdfstring{\yquant!not!}{not}}\label{gate:not}
+         Syntax: \yquant!not <target> | <pcontrol> ~ <ncontrol>;! \\
+         This is a \textsc{not} gate, $\ketbra01 + \ketbra10$, denoted by the $\oplus$ symbol.
+         It may not span multiple registers, but allows for controls.
+         Due to its common usage, the synonymous gate \hyperref[gate:cnot]{\yquant!cnot!} is provided.
+         The style \style{/yquant/operators/every not} is installed.
+         
+         \emph{Possible attributes:} none
+      
+      \subsection{\texorpdfstring{\yquant!output!}{output}}\label{gate:output}
+         Syntax: \yquant!output <target>;! \\
+         This is a pseudo\hyp gate that allows to write some text at the very end of the register line.
+         It may only be specified once per register.
+         It may span multiple registers, but does not allow for controls.
+         The style \style{/yquant/every output} is installed, and also the style \texttt{/yquant/every <type> output}, where \texttt{<type>} is the type of the affected register (at the time of printout).
+         For outputs on multiple registers, the style \style{/yquant/every multi output} is installed instead of the two previously mentioned ones; and additionally, a path is constructed that extends from the first to the last register in the multi\hyp register compound.
+         
+         \emph{Possible attributes:}
+         \begin{itemize}
+            \item \yquant![value=<value>]! (required) \\
+               Denotes the text that is to be printed.
+               Inside the value, \tex!\idx! expands to the current index within the register list.
+         \end{itemize}
+      
+      \subsection{\texorpdfstring{\yquant!phase!}{phase}}\label{gate:phase}
+         Syntax: \yquant!phase <name> | <pcontrol> ~ <ncontrol>;! \\
+         This is a phase gate, $\ketbra00 + \ee^{\ii\phi} \ketbra11$, denoted by a filled circle.
+         It may not span multiple registers, but allows for controls (and should have them, to make any sense).
+         The style \style{/yquant/operators/every phase} is installed.
+         
+         \emph{Possible attributes:}
+         \begin{itemize}
+            \item \yquant![value=<value>]! (required) \\
+               Denotes the angle $\phi$ that is to be printed together with the gate.
+               Position and appearance can be influenced by setting the position of \TikZ{} labels, as this is internally used.
+               Note that at the moment, it is not possible to change any label options on a gate\hyp type basis, only locally or fully globally (\TikZ{} feature request \href{https://github.com/pgf-tikz/pgf/issues/811}{\#811}).
+         \end{itemize}
+         
+      \subsection{\texorpdfstring{\yquant!qubit!}{qubit}}\label{gate:qubit}
+         Syntax: \yquant!qubit <name>[<len>];! \\
+         Declares a register of type \texttt{qubit}.
+         The \texttt{<name>} must be a self\hyp chosen name for the register which was not previously used as a register name in this \tex!yquant! environment.
+         Names are case\hyp insensitive.
+         The register can be made into a vector register by specifying \texttt{<len>} (default \tex!1!).
+         
+         \emph{Possible attributes:}
+         \begin{itemize}
+            \item \yquant![after=<regname>]! \\
+               If given, the register will start not at the left of the circuit but instead at the position at which the last gate in the register \texttt{<regname>} ended.
+            \item \yquant![value=<value>]! \\
+               Denotes the label that is printed to the left of the wire.
+               If the value is omitted, the default is used (\style{/yquant/register/default name}, preinitialized to \tex!\regidx!).
+               
+               Inside the value, \tex!\reg! expands to \texttt{<name>}, \tex!\len! expands to \texttt{<len>}, \tex!\idx! expands to the current index within the vector register ($0 \leq \text{\tex!\idx!} < \text{\texttt{<len>}}$), and \tex!\regidx! expands to \tex!\reg! if \texttt{<len>} is one, or to \tex!\reg[\idx]! else.
+         \end{itemize}
+      
+      \subsection{\texorpdfstring{\yquant!qubits!}{qubits}}\label{gate:qubits}
+         Syntax: \yquant!qubits <name>[<len>];! \\
+         Declares a register of type \texttt{qubits}.
+         
+         \emph{see \hyperref[gate:qubit]{\yquant!qubit!}}
+      
+      \subsection{\texorpdfstring{\yquant!setwire!}{setwire}}\label{gate:setwire}
+         Syntax: \yquant!setwire <target>;! \\
+         This is an invisible pseudo\hyp gate that immediately changes the type of the targets registers, taking effect with the output line extending from the last drawn gate.
+         It may not span multiple registers and does not allow for controls.
+         
+         \emph{Possible attributes:}
+         \begin{itemize}
+            \item \yquant![value=<qubit|cbit|qubits>]! (required) \\
+               Denotes the new type that is assigned to all registers.
+               To change the type to \gate{nobit}, use the \hyperref[gate:discard]{\yquant!discard!} pseudo\hyp gate instead.
+         \end{itemize}
+      
+      \subsection{\texorpdfstring{\yquant!slash!}{slash}}\label{gate:slash}
+         Syntax: \yquant!slash <target>;! \\
+         This is a pseudo\hyp gate used to denote that a single line actually represents multiple registers.
+         It is drawn as a short slash through the line of the register.
+         Note that this gate, in contrast to all others, is positioned on the line extending from the last gate or the initialization line of the registers and does not advance the register's horizontal position.
+         The style \style{/yquant/operators/every slash} is installed.
+         
+         \emph{Possible attributes:} none
+      
+      \subsection{\texorpdfstring{\yquant!swap!}{swap}}\label{gate:swap}
+         Syntax: \yquant!swap <targets> | <pcontrol> ~ <ncontrol>;! \\
+         This is the two\hyp qubit \textsc{swap} gate $\ketbra{00}{00} + \ketbra{01}{10} + \ketbra{10}{01} + \ketbra{11}{11}$ that exchanges two qubits.
+         It is denoted by crosses at the affected registers which are connected by a control line.
+         It may span multiple registers (in fact, it should always span exactly two registers, though \Yquant{} does not enforce this), and it allows for controls.
+         However, refrain from combining \emph{multiple} two\hyp qubit targets \emph{together} with controls.
+         The control line will extend from the first to the last of all registers involved in the operation, so that it is impossible to discern visually which registers should actually be swapped.
+         Using multiple swaps without controls in one operation is fine, as well as a single controlled swap.
+         The style \style{/yquant/operators/every swap} is installed.
+         
+         \emph{Possible attributes:} none
+      
+      \subsection{\texorpdfstring{\yquant!x!}{x}}\label{gate:x}
+         Syntax: \yquant!x <target> | <pcontrol> ~ <ncontrol>;! \\
+         This is a Pauli $\sigma_{\symup x}$ gate $\ketbra01 + \ketbra10$, denoted by a rectangle that contains the letter $X$.
+         It may not span multiple registers, but allows for controls. \\
+         The style \style{/yquant/operators/every x} is installed.
+         
+         \emph{Possible attributes:} none
+         
+      \subsection{\texorpdfstring{\yquant!xx!}{xx}}\label{gate:xx}
+         Syntax: \yquant!xx <targets>;! \\
+         This is a two\hyp qubit symmetric flip gate, denoted by two joined open squares.
+         It may span multiple registers (in fact, it should always span exactly two registers, though \Yquant{} does not enforce this), and it allows for controls.
+         However, refrain from combining \emph{multiple} two\hyp qubit targets \emph{together} with controls.
+         The control line will extend from the first to the last of all registers involved in the operation, so that it is impossible to discern visually which registers form the two\hyp qubit compounds.
+         Using multiple gates without controls in one operation is fine, as well as a single controlled gate.
+         The style \style{/yquant/operators/every xx} is installed.
+         
+         \emph{Possible attributes:} none
+      
+      \subsection{\texorpdfstring{\yquant!y!}{y}}\label{gate:y}
+         Syntax: \yquant!y <target> | <pcontrol> ~ <ncontrol>;! \\
+         This is a Pauli $\sigma_{\symup y}$ gate $-\ii\ketbra01 + \ii\ketbra10$, denoted by a rectangle that contains the letter $Y$.
+         It may not span multiple registers, but allows for controls. \\
+         The style \style{/yquant/operators/every y} is installed.
+         
+         \emph{Possible attributes:} none
+      
+      \subsection{\texorpdfstring{\yquant!z!}{z}}\label{gate:z}
+         Syntax: \yquant!z <target> | <pcontrol> ~ <ncontrol>;! \\
+         This is a Pauli $\sigma_{\symup z}$ gate $\ketbra00 - \ketbra11$, denoted by a rectangle that contains the letter $Z$.
+         It may not span multiple registers, but allows for controls. \\
+         The style \style{/yquant/operators/every z} is installed.
+         
+         \emph{Possible attributes:} none
+         
+      \subsection{\texorpdfstring{\yquant!zz!}{zz}}\label{gate:zz}
+         Syntax: \yquant!zz <targets>;! \\
+         This is a two\hyp qubit symmetric phase gate $\symbb1 - 2\ketbra{11}{11}$, denoted by two joined filled circles.
+         It may span multiple registers (in fact, it should always span exactly two registers, though \Yquant{} does not enforce this), but does not allow for controls.
+         The style \style{/yquant/operators/every zz} is installed.
+         
+         \emph{Possible attributes:} none
+         
+   
+   \section{Examples}\label{sec:examples}
+      This section will contain lots of examples.
+      On the left\hyp hand side, the output is given, while the code to construct the example is on the right.
+      All examples that are provided originate from the examples supplied with \pkg{qasm}, \pkg{qcircuit}, and \pkg{quantikz}.
+      We will essentially follow their manuals example\hyp by\hyp example, which gives a nice comparison in how to achieve the given feature using these packages and \Yquant{} instead.
+      All examples of course require inclusion of the \Yquant{} package in the preamble, and some also require \pkg{braket}.
+      
+      \subsection{\pkg{qasm} documentation}
+      \begingroup%
+         \yquantset{register/default name=$\ket{\reg_{\idx}}$}%
+         The \pkg{qasm} documentation most often names the registers in the way $\ket{\mathrm{register}_{\mathrm{index}}}$.
+         This can be achieved by writing
+         \begin{minted}{tex}
+qubit {$\ket{<name>_{\idx}}$} <name>[<len>];
+         \end{minted}
+         but if you want to realize this naming scheme for all circuits in your document, it is more convenient to say
+         \begin{minted}{tex}
+\yquantset{register/default name=$\ket{\reg_{\idx}}$}
+         \end{minted}
+         in the preamble, as is done here.
+         
+         \begin{example}[test1 (create an EPR pair)]
+            \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit q[2];
+      
+      h q[0];
+      cnot q[1] | q[0];
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample}
+         \end{example}
+         
+         \clearpage
+         \begin{example}[test2 (simple teleportation circuit)]
+            \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit q[3];
+      
+      h q[1];
+      cnot q[2] | q[1];
+      cnot q[1] | q[0];
+      h q[0];
+      measure q[0-1];
+      
+      z q[2] | q[1];
+      x q[2] | q[0];
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample}
+         \end{example}
+         
+         \begin{example}[test3 (swap circuit)]
+            \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit q[2];
+      
+      cnot q[1] | q[0];
+      cnot q[0] | q[1];
+      cnot q[1] | q[0];
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample}
+         \end{example}
+         
+         \clearpage
+         \begin{example}[test4 (quantum fourier transform on three qubits)]
+            \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit j[3];
+      
+      h j[0];
+      box {$S$} j[0] | j[1];
+      box {$T$} j[0] | j[2];
+      h j[1];
+      box {$S$} j[1] | j[2];
+      h j[2];
+      swap (j[0, 2]);
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample}
+         \end{example}
+         
+         \begin{example}[test5 (demonstrate arbitrary qubit matrix ops)]
+            \begin{codeexample}
+% \usepackage{amsmath}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit j[2];
+      
+      box {$\begin{bmatrix}
+         e^{i \alpha} & 0 \\
+         0 & e^{-i \alpha}
+      \end{bmatrix}$} j[1] | j[0];
+      box {$\begin{bmatrix}
+         \cos\theta & -\sin\theta \\
+         \sin\theta & \cos\theta
+      \end{bmatrix}$} j[0];
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample}
+         \end{example}
+            
+         \clearpage
+         \begin{example}[test6 (demonstrate multiple-qubit controlled single-q-gates)]
+            \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit j[4];
+      
+      cnot j[2] | j[0, 1];
+      x j[0];
+      box {$U$} j[1] | j[0, 2-3];
+      h j[2];
+      measure j[3];
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample}
+         \end{example}
+         
+         \begin{example}[test7 (measurement of operator with correction)]
+            \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit q[2];
+      
+      h q[0];
+      box {$U$} q[1] | q[0];
+      h q[0];
+      measure q[0];
+      box {$V$} q[1] | q[0];
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample}
+         \end{example}
+         
+         \clearpage
+         \begin{example}[test8 (stage in simplification of quantum teleportation)]
+            \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit {$\ket{q_0} = \ket\psi$} q[1];
+      qubit {$\ket{q_{\idx}} = \ket0$} q[+2];
+      
+      h q[1];
+      cnot q[1] | q[0];
+      cnot q[2] | q[1];
+      cnot q[1] | q[0];
+      h q[0];
+      cnot q[2] | q[1];
+      z q[0] | q[2];
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample}
+            Note that we left out two Hadamards at the end.
+            
+            Before version 0.1.1, the recommended approach (which of course still works) to define a vector qubit register with various texts was to use case discrimination on \tex!\idx!, for example in the following manner:
+            \begin{minted}{tex}
+qubit {$\ket{q_{\idx}} = \ifcase\idx\relax \ket\psi \else \ket0 \fi$} q[3];
+            \end{minted}
+         \end{example}
+         
+         \begin{example}[test9 (two-qubit gate circuit implementation of Toffoli)]
+            \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit q[3];
+      
+      box {$\sqrt X$} q[2] | q[1];
+      cnot q[1] | q[0];
+      box {$\sqrt X^\dagger$} q[2] | q[1];
+      cnot q[1] | q[0];
+      box {$\sqrt X$} q[2] | q[0];
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample}
+         \end{example}
+         
+         \clearpage
+         \begin{example}[test10 (multi-qubit gates also demonstrates use of classical bits)]
+            \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit {$\ket{q_0}$} q;
+      cbit {$c_1$} c;
+      qubit {$\ket{q_2}$} q[+1];
+      
+      h q[0];
+      box {$U$} (q[0], c);
+      box {$S$} q[1];
+      box {$U$} (c, q[1]);
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample}
+            Instead of a discontigous vector register, we could also have used three scalar registers.
+            The labels chosen for \pkg{qasm} do not fit well to the used required by this use.
+            We might also have used a three\hyp register vector and used the \gate{setwire} pseudo\hyp gate to immediately change the second register into a classical one, which would give indices matching the labels---but still, the registers would have a common name, which would make this a very unnatural approach.
+         \end{example}
+         
+         \begin{example}[test11 (user-defined multi-qubit ops)]
+            \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit q[3];
+      
+      h q[0];
+      box {$U_{f(x)}$} (q[0, 1]);
+      h q[1];
+      box {$U_{f(x, y)}$} (q);
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample}
+            Here we used the fact that a vector register can also be addressed as a whole.
+            Instead of \tex!(q)!, we could have also written, e.g., \tex!(q[0]-q[2])! or \tex!(q[0-2])!, or enumerated all sub\hyp registers in a comma\hyp separated list.
+         \end{example}
+         
+         \clearpage
+         \begin{example}[test12 (multi-qubit controlled multi-qubit operations)]
+            \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit q[3];
+      
+      h q[0];
+      box {$U$} (q[1-2]) | q[0];
+      h q[0];
+      box {$V$} (q[0-1]) | q[2];
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample}
+         \end{example}
+         
+         \begin{example}[test13 (three-qubit phase estimation circuit with QFT and controlled-U)]
+            \begin{codeexample*}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit {$\ket{j_{\idx}} = \ket0$} j[3];
+      qubit s[2];
+      
+      h j;
+      box {$U^4$} (s) | j[0];
+      box {$U^2$} (s) | j[1];
+      box {$U$} (s) | j[2];
+      h j[0];
+      box {$S$} j[1] | j[0];
+      h j[1];
+      box {$T$} j[2] | j[0];
+      box {$S$} j[2] | j[1];
+      h j[2];
+      measure j;
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample*}
+         \end{example}
+         
+         \begingroup%
+            \mdfapptodefinestyle{bdBox}{%
+               leftmargin=-.12\linewidth,
+               rightmargin=-.12\linewidth
+            }%
+            \begin{example}[test14 (three-qubit FT QEC circuit with syndrome measurement)]
+               \begin{codeexample*}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit q[3];
+      qubit {$\ket{s_{\idx}} = \ket0$} s[2];
+      cbit {$c_{\idx} = 0$} c[2];
+      
+      h s[0];
+      cnot s[1] | s[0];
+      cnot s[0] | q[0];
+      cnot s[1] | q[1];
+      cnot s[1] | s[0];
+      h s[0];
+      measure s;
+      cnot c[0] | s[0];
+      cnot c[1] | s[1];
+      discard s; % to suppress wires extending until re-initialization
+      
+      init {$\ket0$} s;
+      h s[0];
+      cnot s[1] | s[0];
+      cnot s[0] | q[1];
+      cnot s[1] | q[2];
+      cnot s[1] | s[0];
+      h s[0];
+      measure s;
+      
+      box {Process\\Syndrome} (s, c);
+      box {$\symcal R$} (q) | s, c;
+   \end{yquant}
+\end{tikzpicture}
+               \end{codeexample*}
+            \end{example}
+         \endgroup%
+         
+         \clearpage
+         \begin{example}[test15 (``D-type'' measurement)]
+            \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit {$\ket{q_0} = \ket\psi$} q;
+      qubit {$\ket{q_1} = \ket+$} q[+1];
+      
+      zz (q);
+      dmeter {$H Z_\theta$} q[0];
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample}
+         \end{example}
+            
+         \begin{example}[test16 (example from Nielsen paper on cluster states)]
+            \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit {$\ket{q_{\idx}} = \ket\psi$} q[2];
+      qubit {$\ket{q_2} = \ket\phi$} q[+1];
+      qubit {$\ket{q_3} = \ket0$} q[+1];
+      
+      zz (q[1], q[2]);
+      align q;
+      cnot q[3] | q[2];
+      slash q[0];
+      dmeter q[3];
+      discard q[2];
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample}
+            We needed to include an \tex!align! pseudo\hyp gate to put the slash at the desired position.
+            Usually, this would be sufficient to put the \tex!cnot! and the \tex!slash! gate directly under each other, as it is in the \pkg{qasm} example.
+            However, the \tex!slash! gate is special in that it does not need horizontal space and is put with only half of the usual operator separation into the circuit (for this reason, it can be put at the beginning of a wire without creating weird shifts with respect to the ``unslashed'' registers---it is put in the initial line that every wire even without an operation has).
+            Hence, you should normally only use the \tex!slash! gate as the very first gate in a circuit.
+            It is not possible to construct the exact same appearance as in the \pkg{qasm} example.
+            Note that \tex!discard! currently just drops the wire directly after the last operation.
+         \end{example}
+         
+         \begin{example}[test17 (example from Nielsen paper on cluster states)]
+            \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit {$\ket{q_0} = \ket\psi$} q;
+      qubit {$\ket{q_{\idx}} = \ket+$} q[+2];
+      qubit {$\ket{q_3} = \ket\phi$} q[+1];
+      
+      zz q[(0-1), (2-3)];
+      zz (q[1-2]);
+      dmeter {$H$} q[1-2];
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample}
+            This example shows how the multi\hyp qubit delimiter (the parenthesis) can even be used within indices.
+         \end{example}
+         
+         \begin{example}[test18 (multiple-control bullet op)]
+            \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit {$\ket{q_{\idx}} = \ket{\ifcase\idx\relax \psi \or + \or + \or \phi \fi}$} q[4];
+      
+      phase {} | q;
+      dmeter {$H$} q[1, 2];
+   \end{yquant}
+\end{tikzpicture}
+            \end{codeexample}
+            This non\hyp standard gate is something that would have to be defined in an accompanying text; probably it is a generalization of \gate{zz}, $\symbb1 - 2 \ketbra{1\dotsm1}{1\dotsm1}$.
+            We implemented it by carrying out a \gate{phase} gate on \emph{no} register (since \gate{phase} requires an argument, we gave an empty one)---indeed, according to the grammar, this is valid syntax with probably no other use case than this---and conditioned it on all others.
+            So in principle, we could have used an arbitrary gate, but \gate{phase} was the semantically closest (\gate{zz} does not allow for controls).
+            This time, we also used the common way to initialize a gate with various identifiers as was done before version~0.1.1, using case distinctions.
+         \end{example}
+      \endgroup
+   
+      \clearpage
+      \subsection{\pkg{qcircuit} documentation}
+      \begingroup%
+         \yquantset{operator/separation=3mm}
+         For a better orientation, we use the same section headings as the \pkg{qcircuit} manual.
+         The manual uses unnamed registers a lot; often, we will use the \tex!yquant*! environment to make things more concise.
+         As \pkg{qcircuit} uses a much large separation between the operators than \Yquant's default, we globally say\\*\tex!\yquantset{operator/separation=3mm}!.
+         
+         \subsubsection{I. Introduction}
+            \begin{example}
+               \begin{codeexample*}
+\begin{tikzpicture}[baseline=(current bounding box.center)]
+   \begin{yquant*}
+      box {$U$} q[2] | q[0, 1];
+   \end{yquant*}
+\end{tikzpicture}
+$=$
+\begin{tikzpicture}[baseline=(current bounding box.center)]
+   \begin{yquant*}
+      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{yquant*}
+\end{tikzpicture}
+               \end{codeexample*}
+               Here, we chose to realize the equality using two \tex!tikzpicture!s with appropriately set baselines.
+               
+               If mangling with the baselines becomes problematic, a different approach would be to use an outer \tex!tikzpicture! with three nodes (left circuit, equals, right circuit); but the circuits themselves are \tex!tikzpictures! again, and nesting those is dangerous (but may work).
+               Instead they could have been put into \tex!\savebox!es and just used.
+               
+               Finally, using nested \tex!tikzpictures! for the outer nodes is not really necessary.
+               Not using nodes but putting the two \tex!yquant*! environments in a \TikZ{} \tex!scope! with \texttt{shift} transformation would have also worked.
+            \end{example}
+      
+            \begin{example}
+               \begin{codeexample*}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit {$\ket\psi$} a;
+      qubit {$\ket0$} b[2];
+      
+      h b[1];
+      cnot b[0] | b[1];
+      cnot b[1] | a;
+      h a;
+      align a, b;
+      measure a;
+      measure b[0];
+      
+      x b[1] | b[0];
+      z b[1] | a;
+      
+      discard a;
+      discard b[0];
+      output {$\ket\psi$} b[1];
+   \end{yquant}
+\end{tikzpicture}
+               \end{codeexample*}
+            \end{example}
+            
+            \begin{example}
+               \begin{codeexample*}
+% \usetikzlibrary{fit, 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;
+      ["Recovery"]
+      box {$\symcal R$} (msg) | syndrome;
+      discard syndrome;
+   \end{yquant}
+   \node[draw, dashed, fit=(inits-2) (scnot0-p0) (smeas-2), "Syndrome Measurement"] {};
+\end{tikzpicture}
+               \end{codeexample*}
+               In this case, an implicit register declaration would not have worked: we would have needed to define the first part of the syndrome register \emph{before} the second part of the message register.
+               But this would then have mixed data with syndrome registers in the vertical ordering.
+               
+               This also is a first demonstration of how to access \Yquant{} objects from within \TikZ.
+               We name several elements that visually form the enclosing rectangle; then, we use the \TikZ{} library \texttt{fit} to put a node around them all.
+               
+               Then we see how to apply an operation to multiple registers in parallel while using the \tex!\idx! macro to still give them a different text.
+               Since \tex!\idx! gives a numerical index (zero\hyp based), we exploit the ASCII code (actually, this document is compiled in Unicode mode...) to turn this into a letter.
+               
+               The example also demonstrates how to put a description next to a gate.
+               In general, those descriptions should be realized using the \TikZ{} feature \texttt{label}.
+               Using the \TikZ{} library \texttt{quotes}, the label is most easily specified.
+               Since the label is not part of the valid arguments and also cannot be found in the \texttt{/yquant} path, it is automatically passed to \style{/yquant/operator style}.
+            \end{example}
+            
+         \clearpage
+         \subsubsection{IV. Simple Quantum Circuits}
+            \begin{example}
+               \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      x q;
+   \end{yquant*}
+\end{tikzpicture}
+               \end{codeexample}
+            \end{example}
+            
+            \paragraph{A. Wires and gates}\leavevmode
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      h a;
+      align a, b;
+      z a;
+      x b;
+      h a;
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+               \end{example}
+               
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      box {$U$} a;
+      box {$U^\dagger$} b;
+      \yquantset{every wire/.append style={->}}
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+                  Though \Yquant{} does not provide any direct mechanism to achieve such wire re\hyp design, changing the wire style at an appropriate position does work.
+                  Setting the style beforehand would have made every connecting wire (including the initial ones) into arrows.
+               \end{example}
+               
+            \clearpage
+            \paragraph{B. CNOT and other controlled single qubits gates}\leavevmode
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      cnot a[1] | a[0];
+      cnot a[0] | a[1];
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+               \end{example}
+               
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      cnot q[2] | q[0];
+      cnot q[0] | q[1-3];
+      box {$U$} q[0] | q[2];
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+               \end{example}
+               
+            \paragraph{C. Vertical wires}\leavevmode
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      box {$U_{\protect\the\numexpr\idx+1}$} q[0, 2] | q[1];
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+                  There is no direct support for this construction, but as with the initialization of a vector registers, \Yquant{} allows to access the macro \tex!\idx! within an operator \texttt{value}.
+                  This macro follows the same rules as the name suffix, i.e., it assigns indices (zero\hyp based) to the target registers in top\hyp to\hyp bottom order, regardless of which order was specified in the target list.
+                  Since we instead want a one\hyp based subscript, we need to add one.
+                  Note that if you want to output \tex!\idx! directly or within an unexpandable expression, you don't need to take any action.
+                  However, here, \tex!\the! is expandable; and since \Yquant{} needs to process all its output twice (first in order to determine the vertical spacing, second to actually typeset), you must manually take care that the command is \emph{not} expanded prematurely by inserting \tex!\protect!.
+                  Had you not done this, the subscript would have been ``$1$'' for both operators.
+                  Note this is not the case if this macro is used upon creation of a register (as is evident by the fact that the previous examples that used \tex!\ifcase! within the value did not need to say \tex!\protect\ifcase ... \protect\or ... \protect\fi!).
+                  Probably we can avoid the need for protection in a future release\dots.
+               \end{example}
+               
+            \paragraph{D. Labeling input and output states}\leavevmode
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      qubit {$\ket1$} q[2];
+      cnot q[0] | q[1];
+      output {$\ket\idx$} q;
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+               \end{example}
+               
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      {
+         \yquantset{every multi label/.append style={decorate=false, draw=none}}
+         init {$\ket{0^k}$} (a[-1]);
+      }
+      init {$\ket\psi$} (b[-1]);
+      qubit {\ifcase\idx\relax$A$\or$B$\fi} c[2];
+      [every multi label/.append style={decorate=false, draw=none, every node/.append style={shift={(-.3, 0)}}}]
+      init {$\ket\psi$} (c);
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+                  Here, three different styles for the initialization of multi\hyp qubit labels are used.
+                  The second one (using a curly brace) corresponds to the default.
+                  It is overwritten for the first qubit, and to make this modification local, this is done in a group.
+                  The third qubit pair uses an overall label and additionally individual labels on the lines.
+                  This is achieved by some trickery: the individual labels are given as initialization labels on the register; the global label is given as an \tex!init! multi\hyp qubit gate.
+               \end{example}
+               
+         \clearpage
+         \subsubsection{V. More Complicated Circuits: Multiple Qubit gates and Beyond}
+            \paragraph{A. Multiple qubit gates}\leavevmode
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      box {$U^\dagger$} (a[-2]);
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+               \end{example}
+               
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit {} a;
+      cbit {} b;
+      nobit ellipsis;
+      qubit {} c;
+      
+      [draw=none]
+      box {$\dots$} ellipsis;
+      box {$U$} (a, b, ellipsis, c);
+      [draw=none]
+      box {$\dots$} ellipsis;
+   \end{yquant}
+\end{tikzpicture}
+                  \end{codeexample}
+                  This demonstrates how a register of type \gate{nobit} might even be useful if the register is never used.
+                  We use \gate{box} registers with disabled border to put the ellipsis dots in place.
+               \end{example}
+               
+               \clearpage
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      box {$\symcal F$} (a[-1]);
+      [name=g]
+      box {$\symcal G$} a[0, 2];
+      \draw (g-0) -- (g-1);
+   \end{yquant*}
+\end{tikzpicture}
+               \end{codeexample}
+                  \emph{Note:} The behavior with a line cannot be reproduced without resolving to \TikZ. However, as \pkg{qcircut}'s manual admits, ``such notation may be a bit confusing,'' so probably support will not be added.
+               \end{example}
+               
+            \paragraph{B. Measurements and classical bits}\leavevmode
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      measure a;
+      dmeter {$\chi$} b;
+      measure {$\ket{\xi_\pm}$} c;
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+                  The ``tab'' and ``measure'' type are not supported yet.
+                  Extracting a meter symbol on its own will not be supported.
+                  If you are interested in the code, have a look at \texttt{yquant-shapes.tex} and search for the \texttt{yquant-measure} shape.
+               \end{example}
+               
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      [shape=yquant-circle]
+      box {Codebit} a;
+      box {$\chi$} b | a;
+      discard a;
+      measure b;
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+                  Rectangles with rounded corners are not supported yet.
+               \end{example}
+               
+               \clearpage
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit {$\ket\psi$} q;
+      
+      measure {$\ket{\xi_\pm}$} q;
+   \end{yquant}
+\end{tikzpicture}
+                  \end{codeexample}
+               \end{example}
+               
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      dmeter {Bell} (a[0, 1]);
+      discard a;
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+               \end{example}
+               
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      measure {$\ket{\xi_\mp}$} (a[-1, 3]);
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+                  Multi\hyp qubit gates (including measurements) on non\hyp adjacent registers are, while being easily written, not supported in terms of a proper visual output.
+                  Of course, as was done in a previous example, you may instead decide to emulate the behavior by drawing the vertical line manually, using a \gate{box} gate on the last register and also changing the type by means of the \gate{setwire} pseudo\hyp gate (but note that the type was not even changed in the \pkg{qcircuit} documentation)\dots.
+               \end{example}
+               
+            \clearpage
+            \paragraph{C. Non-gate inserts, forcing space, and swap}\leavevmode
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      [name=sw]
+      swap (a[0-1]);
+      [draw=none]
+      box {$X$} a[1];
+      slash b;
+      box {$H^{\otimes n}$} b;
+      \node[anchor=199] at (sw-0.north) {Defective Circuit};
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+                  Here, the intermediate text was inserted by using a \tex!box! without drawing.
+                  Another way would be to use an \gate{init} command, although this is semantically wrong (probably).
+               \end{example}
+               
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      qubit {} a;
+      [name=ypos]
+      qubit {} b[3];
+      
+      cnot a | b[0];
+      [name=left]
+      cnot a | b[1];
+      hspace {7mm} -;
+      [name=right]
+      cnot a | b[2];
+   \end{yquant*}
+   \path (left |- ypos-0) -- (right |- ypos-1) node[midway] {$\dots$};
+\end{tikzpicture}
+                  \end{codeexample}
+                  Note how the register range \texttt{-} was used to denote all registers.
+                  We positioned the dots by first naming the relevant registers, so that the vertical position is at the coordinates \texttt{ypos-0} and \texttt{ypos-1}; and then, we also named the \gate{cnot} gates, so that we are able to discern the horizontal position.
+               \end{example}
+               
+            \clearpage
+            \paragraph{D. Barriers}\leavevmode
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      x a[0, 1];
+      barrier (a);
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+                  
+                  Now the \pkg{qcircuit} manual lists three circuits with barriers at different positions.
+                  They cannot be drawn with \Yquant; however, since neither of them is a valid circuit, this is of no concern.
+               \end{example}
+               
+            \paragraph{E. How to control anything}\leavevmode
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      zz (a[0, 2]);
+      cnot a[1] ~ a[0];
+      zz (a[2, 3]);
+      h a[3] | a[0] ~ a[1];
+      measure a[2, 3];
+      box {$U$} (a[0, 1]) | a[3] ~ a[2];
+      discard a[2, 3];
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+                  Note that it is not possible to draw a control to measurement (the measurement operations are explicitly defined not to accept controls): Either the measurement is performed or not (which transforms the register type), but a measurement conditioned on a quantum state is not possible.
+                  In principle, one could think of a measurement conditioned on a classical register (in which case the register type cannot change, as maybe the state stays quantum; the measurement operation then is similar to a complete dephasing).
+                  If there is need for this, please file a feature request.
+               \end{example}
+               
+         \subsubsection{VI. Bells and Whistles: Tweaking Your Diagram to Perfection}
+            For options how to configure the circuits, refer to \cref{sec:config}.
+            
+            \clearpage
+            \paragraph{A. Spacing}\leavevmode
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      swap (a[0, 1]);
+      box {$T^\dagger$} a[2] | a[1];
+      swap (a[0, 1]);
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+               \end{example}
+               
+            \paragraph{B. Labeling}\leavevmode
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}[every initial label/.style={anchor=south east}]
+      qubit {\rlap{\hskip2mm $a$}} a;
+      qubit {\rlap{\hskip2mm $b$}} b;
+      hspace {5mm} -;
+      
+      measure b;
+      align -;
+      measure a;
+      output {$A$} a;
+      output {$B$} b;
+   \end{yquant}
+\end{tikzpicture}
+                  \end{codeexample}
+                  Measurement with bottom output are not supported (yet).
+                  Repositioning the initial labels needs some care and manual fine\hyp tuning.
+               \end{example}
+               
+            \clearpage
+            \paragraph{C. Grouping}\leavevmode
+               \begin{example}
+                  \begin{codeexample*}
+% \usetikzlibrary{fit}
+\begin{tikzpicture}
+   \begin{yquant*}[register/separation=3mm]
+      cnot a[2] | a[0];
+      cnot a[2] | a[1];
+      [name=left]
+      h a[0, 1];
+      z a[2];
+      cnot a[1] | a[0];
+      [name=righttop]
+      h a[0];
+      [name=rightbot]
+      h a[1] | a[2];
+      
+      hspace {2mm} -;
+   \end{yquant*}
+   \node[draw, dashed, fit=(left-0) (left-1) (righttop) (rightbot-0)] {};
+\end{tikzpicture}
+                  \end{codeexample*}
+                  Note that \tex!\begin{yquant*}! must not be followed by a line break (unless masked by \tex!%!) if options follow.
+               \end{example}
+      \endgroup
+      
+      \clearpage
+      \subsection{\pkg{quantikz} documentation}
+      \begingroup
+         \yquantset{operator/separation=4mm}%
+         Again, our section headings will be the same as in the \pkg{quantikz} manual.
+         And since \pkg{quantikz} also has even more space between the gates, we globally say \tex!\yquantset{operator/separation=4mm}!.
+         
+         \subsubsection{II. A single wire}
+            \begin{example}
+               \begin{codeexample*}
+\begin{tikzpicture}[label position=north east, every label/.style={inner sep=1pt}]
+   \begin{yquant}
+      qubit {$\ket0$} a;
+      
+      phase {$\alpha$} a;
+      h a;
+      phase {$\beta$} a;
+      h a;
+      phase {$\gamma$} a;
+      
+      [every output/.append style={align=center}]
+      output {Arbitrary\\pure state} a;
+   \end{yquant}
+\end{tikzpicture}
+               \end{codeexample*}
+               The captions of \gate{phase} commands are internally implemented using \TikZ{} \texttt{label}s.
+               At the moment, it is not possible to change any label options on a gate-type basis, only locally or fully globally (\TikZ{} feature request \href{https://github.com/pgf-tikz/pgf/issues/811}{\#811}).
+            \end{example}
+            
+            \clearpage
+            \paragraph{A. Measurements}\leavevmode
+               \begin{example}
+                  \begin{codeexample}
+% \usetikzlibrary{quotes}
+\begin{tikzpicture}
+   \begin{yquant*}
+      ["$0$"]
+      measure a;
+      discard a;
+      
+      init {} a;
+      dmeter {$1$} a;
+      discard a;
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+                  Other measurement shapes are not supported at the moment.
+               \end{example}
+            
+            \paragraph{B. Wires and arrows}\leavevmode
+               \begin{example}
+                  \begin{codeexample*}
+% \usetikzlibrary{quotes}
+\begin{tikzpicture}
+   \begin{yquant}[operator/separation=1cm, every label/.append style={align=center}]
+      qubit {$\ket0$\\initial state} a;
+      
+      [draw=none]
+      box {$X$} a;
+      
+      ["$0$/$1$", type=qubit]
+      measure a;
+      
+      \yquantset{every wire/.append style={->}, operator/separation=5mm}
+      output {$\ket1$} a;
+   \end{yquant}
+\end{tikzpicture}
+                  \end{codeexample*}
+                  This example demonstrates how to instruct the \gate{measure} gate to use a different output type than the standard \gate{cbit}.
+                  
+                  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).
+                  
+                  In order to change the style of an individual wire, the proper \tex!\yquantset! command must be placed directly before the wire is internally drawn (which happens when the next gate that needs a connecting line is drawn).
+                  Remember to use grouping so that the changes are local.
+                  However, the output wires are all drawn together, so it is not possible to individually change the style of a single output wire, only all of them.
+               \end{example}
+               
+               \begin{example}
+                  \begin{codeexample}
+% \usetikzlibrary{quotes}
+\begin{tikzpicture}
+   \begin{yquant*}
+      qubit {$\ket0^{\otimes n}$} a;
+      ["north east:3" {font=\protect\footnotesize, inner sep=0pt}]
+      slash a;
+      hspace {2mm} a;
+      h a;
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+                  Again, you see an example of how some commands need to be \tex!\protect!ed when used in \Yquant{} options, and that you can indeed exploit all features of the \texttt{quotes} library.
+               \end{example}
+               
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubits {$\ket0^{\otimes n}$} a;
+      h a;
+   \end{yquant}
+\end{tikzpicture}
+                  \end{codeexample}
+               \end{example}
+            
+         \clearpage
+         \subsubsection{III. Multiple Qubits}
+            \begin{example}
+               \begin{codeexample*}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit {$\ket0$} a;
+      qubit {$\ket0$} b;
+      
+      h a, b;
+      cnot b | a;
+      box {$U$} a ~ b;
+      zz (a, b);
+      
+      [after=a]
+      qubit {} c;
+      
+      swap (a, c);
+      box {$U$} c | a ~ b;
+   \end{yquant}
+\end{tikzpicture}
+               \end{codeexample*}
+               This example demonstrates the use of the \texttt{after} argument that instructs the register creation to begin the register only after the current position of another register that already exists.
+            \end{example}
+            
+            \clearpage
+            \begin{example}
+               \begin{codeexample*}
+\begin{tikzpicture}
+   \begin{yquant*}
+      [name=c]
+      cnot a[0, 2] | a[1];
+      [name=m]
+      measure a[1];
+      discard a[2];
+      \path[/yquant/every wire, /yquant/every qubit wire] (c-1) -- (m.center |- c-1);
+      box {$U$} a[0] | a[1];
+      discard a[1];
+   \end{yquant*}
+\end{tikzpicture}
+               \end{codeexample*}
+               It is not possible for the double control line to directly exit the measurement gate.
+               Also, if you discard a gate, this will prevent it from exiting from its last gate.
+               \Yquant{} will not allow you (apart from manual drawing) to extend the wire to some arbitrary position, then drop it.
+               But of course, as done here, you can always resort to the full power of \TikZ.
+            \end{example}
+            
+            \begin{example}
+               \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      cnot a[1, 2] | a[0];
+      measure a[1], a[2];
+      box {$U$} a[0] | a[1];
+      box {$V$} a[0] | a[2];
+      discard a[1]-;
+   \end{yquant*}
+\end{tikzpicture}
+               \end{codeexample}
+            \end{example}
+            
+         \clearpage
+         \subsubsection{IV. Operating on many Qubits}
+            \begin{example}
+               \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      init {$\ket0^{\otimes3}$} (a[-2]);
+      
+      box {$U$} (a[1-2]) | a[0];
+      measure a[0];
+      discard a[0];
+      output {$\ket{11}$} (a[1-2]);
+   \end{yquant*}
+\end{tikzpicture}
+               \end{codeexample}
+               Multi\hyp qubits inputs are possible using the \gate{init} command.
+               The text assigned to a register declaration is always for an individual register.
+            \end{example}
+            
+            \begin{example}
+               \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      hspace {7.5mm} a;
+      h a;
+      hspace {7.5mm} a;
+      [x radius=1cm]
+      box {$U$} (b, c);
+      cnot b | a;
+      measure a;
+      discard a;
+   \end{yquant*}
+\end{tikzpicture}
+               \end{codeexample}
+               \Yquant{} does not use a grid layout: operators are stacked next to each other.
+               Therefore, there is no automatic centering of a column, though it could be emulated using hand-crafted \gate{hspace} commands, as was done here (the Hadamard gate uses the \style{/yquant/operator/minimum width}, which is \tex!5mm!, while the large box has a width of \tex!2cm!, so that we need two \tex!7.5mm! spacings at the end, as the \gate{hspace} pseudo\hyp gate only inserts exactly the space you give, but not additional [twice] \style{/yquant/operator/separation}, as would be the case for a hypothetical zero\hyp width gate).
+               In fact, we don't even need the second \gate{hspace}, since the two\hyp qubit \gate{cnot} will automatically enforce correct alignment.
+            \end{example}
+            
+            \begin{example}
+               \begin{codeexample*}
+\begin{tikzpicture}[braced/.style={decoration={brace, #1, pre=moveto, pre length=-1pt, post=moveto, post length=-1mm}, decorate}, inner/.style={font=\footnotesize}]
+   \begin{yquant}[register/separation=3mm]
+      [name=a]
+      qubit {} a[4];
+      [x radius=1cm, name=u]
+      box {$U$} (a[1-3]) | a[0];
+   \end{yquant}
+   \draw[braced]
+      ([xshift=2pt] a-1 -| u.west) -- ([xshift=2pt] a-2 -| u.west)
+      node[inner, anchor=west, xshift=1pt, pos=.55] {$x$};
+   \draw[braced=mirror]
+      ([xshift=-2pt] a-1 -| u.east) -- ([xshift=-2pt] a-2 -| u.east)
+      node[inner, anchor=east, xshift=-1pt, pos=.55] {$x$};
+   \node[inner, anchor=west] at (a-3 -| u.west) {\smash{$y$}};
+   \node[inner, anchor=east] at (a-3 -| u.east) {\smash{$y \oplus f(x)$}};
+\end{tikzpicture}
+               \end{codeexample*}
+               There is no simple way to draw \emph{within} a gate, though this is probably something that will be easier using subcircuits (planned feature).
+               Instead, here the intricate parts were reproduced using \TikZ: first, we make sure we assign a name to every relevant coordinate.
+               Then we use some \TikZ{} styles to draw the braces and nodes at the intersection of these coordinates.
+               Here, we also make use of the \texttt{moveto} decoration transformation that comes with \Yquant{} and that allows to enlarge the braces slightly for a good overall appearance.
+               Finally, as $y$ has a much smaller height than $y \oplus f(x)$, we make sure this does not affect the vertical positioning; and also, as $x$ has no ascender, we need to slightly position it off\hyp mid for a good look.
+            \end{example}
+            
+            \clearpage
+            \begin{example}
+               \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      box {$\sqrt Z$} a;
+      box {$X$} b;
+      box {$\sqrt{\mathrm{SWAP}}$} (a, b);
+      measure a;
+   \end{yquant*}
+\end{tikzpicture}
+               \end{codeexample}
+               This time, we did not artificially discard the lines.
+            \end{example}
+            
+            \begin{example}
+               \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit {$c_{\idx}$} c[4];
+      box {M\\A\\J} (c[-2]);
+      box {M\\A\\J} (c[1-]);
+   \end{yquant}
+\end{tikzpicture}
+               \end{codeexample}
+            \end{example}
+            
+            \paragraph{A. Different connections}\leavevmode
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}[register/default name=]
+      qubit a;
+      cbit b;
+      nobit c;
+      cbit d;
+      qubit e;
+      box {$U$} (-);
+      setwire {qubit} c;
+   \end{yquant}
+\end{tikzpicture}
+                  \end{codeexample}
+                  This example for the first time demonstrates the declaration of a non\hyp existing register and the \gate{setwire} pseudo\hyp gate that acts as a zero\hyp width, no\hyp content \gate{init} gate.
+               \end{example}
+            
+         \clearpage
+         \subsubsection{V. Slicing}
+            \begin{example}
+               \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit {} a[3];
+      h a[0];
+      [red, thick, label=step]
+      barrier (a);
+      cnot a[1] | a[0];
+      measure a[0];
+      discard a[0];
+      cnot a[2] | a[1];
+      h a[1];
+   \end{yquant}
+\end{tikzpicture}
+               \end{codeexample}
+               There is nothing like a \texttt{slice all} keyword, as \Yquant's underlying layout is not grid\hyp based.
+               Changing the style of slice captions simply means providing label options.
+               This time, we used the \texttt{label} key instead of the shorter syntax provided by the \texttt{quotes} library, which is of course also possible.
+            \end{example}
+            
+            \begin{example}
+               \begin{codeexample*}
+% \usetikzlibrary{quotes}
+\begin{tikzpicture}[every label/.style={rotate=40, anchor=south west}]
+   \begin{yquant}[operators/every barrier/.append style={blue, thick}]
+      qubit {} a[3];
+      h a[0];
+      ["slice 1"]
+      barrier (-);
+      cnot a[1] | a[0];
+      ["slice 2"]
+      barrier (-);
+      measure a[0];
+      discard a[0];
+      cnot a[2] | a[1];
+      ["slice 3"]
+      barrier (-);
+      h a[1];
+   \end{yquant}
+\end{tikzpicture}
+               \end{codeexample*}
+            \end{example}
+            
+            \begin{example}
+               \begin{codeexample*}
+% \usetikzlibrary{quotes}
+\begin{tikzpicture}[label distance=4mm]
+   \begin{yquant}[operators/every barrier/.append style={red, thick, shorten <= -2.5mm, shorten >= -2.5mm}]
+      qubit {$\ket0$} a;
+      h a;
+      ["1"]
+      barrier (a);
+      phase {[label distance=0pt]$\varphi$} a;
+      ["2"]
+      barrier (a);
+      h a;
+      ["3"]
+      barrier (a);
+      output {$\cos\frac\varphi2 \ket0 - i\sin\frac\varphi2 \ket1$};
+   \end{yquant}
+\end{tikzpicture}
+               \end{codeexample*}
+               Usually, the \texttt{shorten} keys do not have any effect on \Yquant{} operations, since the latter are all made up of nodes.
+               However, the \texttt{yquant-barrier} shape explicitly takes care of correctly handling them.
+               It is the only one that does so.
+               Since barriers usually end quite closely to the wires---and the default \texttt{dashed} style may make this worse---the \texttt{shorten}ing may often prove useful.
+               Note that if the barriers are enlarged by means of negative \texttt{shorten}ings, this will not affect the bounding box or internal register height calculations, and you must take care of appropriately shifting labels.
+               Also note that we used much larger magnitudes in order to achieve a similar appearance as in \pkg{quantikz}.
+               To avoid that the large distance also affects the \gate{phase} gate badly, we locally reset the distance; for this, there are two ways.
+               The easiest one is to make use of the fact that the value of the \gate{phase} gate is passed directly as \texttt{label} argument, so that we can locally reset the distance.
+               The other possibility would be to write
+               \begin{minted}[linenos=false, fontsize=\footnotesize, bgcolor=boxGrayBody]{tex}
+   {
+      \yquantset{/tikz/label distance=0pt}
+      phase {$\varphi$} a;
+   }
+               \end{minted}
+               since due to the aforementioned lack of support for a style that sets the options in \TikZ, we must manually use a (grouped) \tex!\yquantset! instruction for this.
+               Note that whenever you change a \TikZ{} style in a \Yquant{} environment, use the \tex!\yquantset! macro, \emph{not} \tex!\tikzset! or \tex!\pgfkeys!.
+               Not only will the latter two not automatically restart the parser (so that you would have to issue \tex!\yquant! after their use), but \Yquant{} has to process all its content twice in order to properly determine the register height.
+               Only \tex!\yquantset! will be properly captured and re\hyp issued at the correct position when the content is actually typeset.
+               Had we written \tex!\tikzset{label distance=0pt} \yquant!, no effect at all would have been visible, since this command would only have taken effect in the first (invisible) round when \Yquant{} determines heights.
+            \end{example}
+            
+            \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}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant}[register/default name=]
+      [register/minimum height=2cm]
+      qubit a;
+      qubit {\vbox to 1cm{}} b;
+      qubit c;
+      
+      h a;
+      x b-;
+      hspace {2cm} -;
+      x a;
+      z b-;
+      h a;
+      z b-;
+   \end{yquant}
+\end{tikzpicture}
+                  \end{codeexample}
+                  At the moment, the distance between registers is calculated by \Yquant{} automatically.
+                  We show various possibilities to intervene in this example.
+                  The first is to locally, upon creation of the register, reset \style{/yquant/register/minimum height} to a different value.
+                  The second is to artificially enlarge the label that the qubit initializer takes.
+                  However, both approaches enlarge the \emph{height} of the registers, i.e., add half of the specified amount to the top and the bottom.
+               \end{example}
+               
+               \begin{example}
+                  \begin{codeexample*}
+\begin{tikzpicture}
+   \begin{yquant*}
+      [x radius=1cm]
+      x a;
+      box {\hbox to 1cm{\hfil$X$\hfil}} a;
+      hspace {1cm} a;
+      x a;
+      discard a;
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample*}
+                  Here, we demonstrate two possibilities to enlarge a box: The first is by specifying its size in terms of the \texttt{x radius} or \texttt{y radius} keys beforehand.
+                  Those values serve as minimum sizes and would be extended if the text extended beyond the box.
+                  The second option is to just enlarge the text artificially by explicitly putting it into a fixed\hyp width box.
+                  Note that in the first case, the \emph{radius} is specified, i.e., the half\hyp width, while in the second case, it is the \emph{total} width (both times modulo the inner separation).
+                  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}
+               
+            \paragraph{B. Global Adjustment}\leavevmode
+               \begin{example}
+                  \begin{codeexample*}
+\begin{tikzpicture}
+   \begin{yquant*}[operator/separation=1cm]
+      h a;
+      phase {$\beta$} a;
+      h a;
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample*}
+               \end{example}
+               
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}[register/minimum height=0pt]
+      x a[0, 2];
+      zz (a[0, 1]);
+      x a[0];
+      h b;
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+                  By default, \Yquant{} will use the height that is required by the individual gates, but at least \style{/yquant/register/minimum height} (which defaults to \tex!3mm!).
+                  Only manually reducing the default height will produce the cramped spacing displayed here.
+               \end{example}
+               
+            \clearpage
+            \paragraph{C. Alignment}\leavevmode
+               \begin{example}
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      x a[0];
+      cnot a[1] | a[0];
+   \end{yquant*}
+\end{tikzpicture}
+$=$
+\begin{tikzpicture}
+   \begin{yquant*}
+      cnot a[1] | a[0];
+      x a;
+   \end{yquant*}
+\end{tikzpicture}
+                  \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 \style{/yquant/register/minimum height} key does not help here, since it only affects \Yquant's internal handling, but not the bounding box calculated by \TikZ.
+                  In the first example of the \pkg{qcircuit} documentation, we demonstrated how the desired task can easily be achieved in terms of \texttt{baseline}s.
+                  We will now do the same with scopes instead.\vskip2mm 
+                  \begin{codeexample*}
+\begin{tikzpicture}[/yquant/register/minimum height=5mm]
+   \begin{yquant*}
+      x a[0];
+      cnot a[1] | a[0];
+   \end{yquant*}
+   \path (current bounding box.east |- 0, 0) ++(1, 0) coordinate (shift);
+   \begin{scope}[shift=(shift)]
+      \begin{yquant*}
+         cnot a[1] | a[0];
+         x a;
+      \end{yquant*}
+   \end{scope}
+   \node at (current bounding box) {$=$};
+\end{tikzpicture}
+                  \end{codeexample*}
+                  Here, we increased the minimum height so that in the left circuit despite the absence of the $X$ gate, the second register has the same separation.
+                  We used the meta\hyp node \texttt{current bounding box} to avoid the need to manually specify hard\hyp coded positions.
+               \end{example}
+               
+               \subparagraph{1. Perfecting Vertical Alignment}\leavevmode
+                  \begin{example}
+                     \begin{codeexample*}
+\begin{tikzpicture}[baseline=(W)]
+   \begin{yquant}
+      qubit {$\ket0$} anc;
+      [name=W]
+      qubit {} x;
+      h x;
+      cnot x | anc;
+   \end{yquant}
+\end{tikzpicture} $\equiv$ \begin{tikzpicture}[baseline=(W)]
+   \begin{yquant}
+      [name=W]
+      qubit {} x;
+      h x;
+      x x;
+   \end{yquant}
+\end{tikzpicture}
+                     \end{codeexample*}
+                     While here, we opted for the most logical choice to name the declaration of the register, a name put to any operation on the desired register would also serve the purpose.
+                  \end{example}
+                  
+                  \clearpage
+                  \begin{example}
+                     \begin{codeexample*}
+\begin{tikzpicture}[baseline={([yshift=.2cm]W)}]
+   \begin{yquant}
+      qubit {$\ket0$} anc;
+      [name=W]
+      qubit {} x;
+      h x;
+      cnot x | anc;
+   \end{yquant}
+\end{tikzpicture} $\equiv$
+\begin{tikzpicture}[baseline={([yshift=.2cm]new)}]
+   \begin{yquant}
+      [name=new]
+      qubit {} x;
+      h x;
+      x x;
+   \end{yquant}
+\end{tikzpicture}
+                     \end{codeexample*}
+                     Of course, you may also use the features of the \TikZ{} library \texttt{calc} to achieve the same shift.
+                  \end{example}
+            
+            \paragraph{D. Scaling}\leavevmode
+               \begin{example}
+                  \begin{codeexample*}
+\begin{tikzpicture}[scale=1.5, every node/.append style={scale=1.5}]
+   \begin{yquant*}
+      h a;
+      phase {$\beta$} a;
+      h a;
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample*}
+                  Here, we first scaled the circuit itself.
+                  However, since \TikZ{} does not apply scaling to nodes (which means any operation) unless explicitly told so, we need to add the style to those.
+               \end{example}
+         
+         \subsubsection{VII. Typesetting}
+            \paragraph{A. Global Styling}\leavevmode
+               \begin{example}
+                  \begin{codeexample*}
+% \usetikzlibrary{quotes}
+\begin{tikzpicture}
+   \begin{yquant*}[operators/every h/.append style={fill=red!20}]
+      h a;
+      phase {$\beta$} a;
+      h a;
+      ["$\ket\pm$" above right]
+      measure a;
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample*}
+                  Instead of setting \style{/yquant/operators/every h}, we could also have changed \style{/yquant/operators/every box}.
+                  Had we used \style{/yquant/every operator}, then the measurement would also have changed.
+                  Again, due to a \TikZ{} limitation, it is not possible to change the position of labels on a per\hyp style basis, only by using \texttt{label} options or a global setting.
+               \end{example}
+               
+               \begin{example}
+                  \begin{codeexample*}
+\begin{tikzpicture}[thick]
+   \begin{yquant*}[every operator/.prefix style={fill=white}]
+      cnot a[1] | a[0];
+      box {$R_z(-\theta\fracslash2)$} a[1];
+      cnot a[1] | a[0];
+      box {$R_z(\theta\fracslash2)$} a[1];
+      measure a[1];
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample*}
+                  As the ``thin'' style is the default, we present the opposite.
+                  By default, all operators are transparent; we changed this by giving all of them a white background color (but as a style \emph{prefix}, so that, e.g., black fillings overwrite this).
+                  Contrary to \pkg{quantikz}, this also fills the \gate{cnot}s.
+                  If you only want to fill certain operators, you have to selectively target them using their styles.
+               \end{example}
+               
+               \begin{example}
+                  \begin{codeexample*}
+\begin{tikzpicture}
+   \begin{yquant}[operators/every box/.append style={fill=white}]
+      qubit {} j[3];
+      box {$J_{12}$} (-j[1]);
+      box {$J_{13}$} (j[0, 2]);
+      box {$J_{23}$} (j[1]-);
+   \end{yquant}
+\end{tikzpicture}
+                  \end{codeexample*}
+                  \Yquant{} will make sure that ``pass\hyp through'' lines are never obscured, even if, as in this case, the backgrounds are explicitly filled.
+               \end{example}
+            
+            \paragraph{B. Per-Gate Styling}\leavevmode
+               \begin{example}
+                  \begin{codeexample}
+% \usetikzlibrary{quotes}
+\begin{tikzpicture}
+   \begin{yquant*}
+      [fill=red!20, font=\color{cyan}]
+      h a;
+      [green]
+      phase {[green]$\beta$} a;
+      ["$\ket\pm$"]
+      measure a;
+      discard a;
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
+               \end{example}
+               
+               \clearpage
+               \begin{example}
+                  \begin{codeexample*}
+% \usetikzlibrary{shapes.symbols, fit}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit {} data;
+      qubit {$\ket0$} anc1[2];
+      
+      h data;
+      cnot anc1 | data;
+      [after=data]
+      qubit {$\ket0$} anc2[2];
+      [name=box, draw=none]
+      box {\phantom{noise}} (data, anc1);
+      cnot anc2[0] | data;
+      cnot anc2 | anc1[0];
+      cnot anc2[1] | anc1[1];
+      measure anc2;
+   \end{yquant}
+   \node[starburst, cyan, fill=yellow, draw=red,
+         line width=2pt, inner xsep=-4pt, inner ysep=-5pt, fit=(box)] {noise};
+\end{tikzpicture}
+                  \end{codeexample*}
+                  \TikZ{} shapes cannot simply be used with \Yquant.
+                  Any \Yquant{} shape must be aware of the keys \texttt{x radius} and \texttt{y radius} that control its width and height.
+                  Additionally, \Yquant{} shapes must implement the \texttt{circuit} anchor (which can usually be let to the \texttt{center} anchor), and they must implement projection anchors.
+                  Those objects, which are a \Yquant{} addition to \TikZ{} allow \Yquant{} to determine where precisely the wires at the individual positions are supposed to begin and end.
+                  \Yquant{} draws its elements sequentially; hence, a wire that comes into an operator will be hidden by anything the operator draws on top of it; but outgoing wires will in turn draw on the operator.
+                  To avoid the issues, we construct an invisible box operator and name it; \emph{outside} of the \tex!yquant! environment, we \tex!fit! the special \TikZ{} shape on top of it.
+               \end{example}
+               
+            \paragraph{C. Boxing/Highlighting Parts of a Circuit}\leavevmode
+               \begin{example}
+                  \begin{codeexample*}
+% \usetikzlibrary{quotes}
+\begin{tikzpicture}
+   \begin{yquant*}
+      h a;
+      cnot b | a;
+      [name=left]
+      h -;
+      cnot b | a;
+      [name=right]
+      h -;
+      cnot b|a;
+      h b;
+   \end{yquant*}
+   \node[fit=(left-0) (left-1) (right-0) (right-1),
+         draw, inner sep=6pt, "reversed c-\textsc{not}"] {};
+\end{tikzpicture}
+                  \end{codeexample*}
+               \end{example}
+               
+               \clearpage
+               \begin{example}
+                  \begin{codeexample*}
+% \usetikzlibrary{quotes, backgrounds}
+\begin{tikzpicture}
+   \begin{yquant*}
+      h a;
+      [name=left]
+      cnot b | a;
+      cnot a | b;
+      [name=right]
+      cnot b | a;
+      h b;
+   \end{yquant*}
+   \scoped[on background layer]
+      \node[fit=(left-0) (left-p0) (right-0) (right-p0),
+            draw, dashed, rounded corners, fill=blue!20,
+            inner xsep=6pt, inner ysep=10pt,
+            "\textsc{swap}" below] {};
+\end{tikzpicture}
+                  \end{codeexample*}
+                  In this example, we need to refer to names, but want to fill the background before those nodes are actually available.
+                  Hence, we use the layering mechanism of \TikZ{} and put the node on the background layer.
+                  Alternatively, we could have drawn on top and used opacity to still make visible what is behind; but in general, whenever you can avoid to use opacities, do avoid it; it adds overhead at the renderer and may give sub\hyp optimal result when printing since the viewer has to reduce all elements to non\hyp overlapping parts.
+               \end{example}
+               
+               \Yquant{} does not support the fancy nearest\hyp neighbor swap gate that \pkg{quantikz} has.
+               It would however not be very difficult to implement this particular shape and make it available.
+               
+         \clearpage
+         \subsubsection{VIII. Otherwise undocumented features}
+            \begin{example}
+               \begin{codeexample*}
+% \usetikzlibrary{quantikz}
+\begin{tikzpicture}
+   \begin{yquant}[register/default name=]
+      qubit a;
+      [name=wave, register/minimum height=1cm]
+      nobit wave;
+      qubit b;
+      qubit c;
+      
+      h a, b;
+      box {$U$} c | a;
+      [draw=none]
+      box {$\dots$} a, b-;
+      box {$U^k$} c | b;
+      h a, b;
+   \end{yquant}
+   \node[wave, fit=(wave) (current bounding box.east |- wave), inner ysep=.5pt, inner xsep=0pt] {};
+\end{tikzpicture}
+               \end{codeexample*}
+               Here, we included \pkg{quantikz}, which provides the \texttt{wave} shape, then introduced a register that will contain this wave (and enlarged it sufficiently).
+               After the circuit is drawn, we \texttt{fit} the wave along.
+               Since the name assigned to a register without any text actually is of a \texttt{coordinate} shape, we need to enlarge the height of the wave by providing a slightly increased \texttt{inner ysep}.
+               Additionally, \pkg{quantikz} sets a negative \texttt{inner xsep}, which is probably required for its grid layout; but \Yquant{} positions exactly, so we also need to reset this.
+            \end{example}
+         
+         \clearpage
+         \subsubsection{X. Troubleshooting}
+            \begin{example}
+               \begin{codeexample*}
+\begin{tikzpicture}
+   \begin{yquant}
+      qubit {$\ket0$} a[2];
+      box {$\begin{pmatrix}
+               \alpha & \beta \\
+               \beta & -\alpha
+            \end{pmatrix}$} a[0];
+      cnot a[1] | a[0];
+      box {$U_{\protect\the\numexpr\idx+1}$} a;
+   \end{yquant}
+\end{tikzpicture}
+               \end{codeexample*}
+            \end{example}
+      \endgroup
+   
+   \section{Wishlist}
+      This section contains some thoughts on future improvements and features.
+      \begin{itemize}
+         \item Subcircuit support. \\
+            A subcircuit is a quantum circuit on its own that is put into a box within other circuits.
+            It has input, output, and also internal wires.
+            Subcircuits may be declared on\hyp the\hyp fly if they are used only once, but there should also be the option to globally declare subcircuits and use them at any time.
+            As with ordinary quantum circuits, everything in a subcircuit should be allowed to have a name.
+            If the subcircuit itself is then also named, those inner names should be made available (prefixed with the subcircuit's name), to the outer circuit.
+            Subcircuits may also contain subcircuits.
+            While the number of input registers should match, a subcircuit may have more, less or different output registers.
+            The language needs to be extended to somehow allow for this.
+            Subcircuits will typically be multi\hyp qubit elements that, at least if internal wires are used, may significantly increase the required height for an individual register.
+            Hence, the internal height calculations must be adapted.
+            This will be particularly problematic if the subcircuit targets non\hyp adjacent wires.
+         \item Better handling of non\hyp adjacent wires. \\
+            While this would be a nice feature, an implementation would hard: How should the individual shapes behave for non\hyp adjacent wires?
+            Two boxes, connected by a wire, as used in one \pkg{qcircuit} example, is a simplistic design that quickly fails for more complicated or larger shapes.
+         \item Styling the wires. \\
+            It is currently relatively hard to selectively style wires.
+            While individual wire segments can be targeted by changing the appropriate wire styles before the operation that would draw the ingoing wire, it must then be reset and it is cumbersome to do this for all wire segments of a register.
+            Additionally, styling the final output wires individually is not possible.
+            For this, it would be advantageous to allow a wire style on a per\hyp register basis.
+         \item Support for other languages. \\
+            It would be particularly nice to introduce a language mode.
+            While the \Yquant{} language will always provide the set of everything \Yquant{} can do at the moment, it would be nice if \Yquant{} can automatically detect \texttt{OpenQASM} and parse its content correctly.
+            \texttt{OpenQASM} is much more limited than \Yquant{} and, being a language designed for actual execution of the circuits, does not provide means to change visual appearance.
+            Probably some \Yquant{} additions to \texttt{OpenQASM} would be ok, as long as they only complement the original language?
+            Also, \texttt{OpenQASM} support would probably require subcircuits.
+            
+            Another nice feature would be to support \pkg{qasm}.
+            Also here, the feature set is much more limited and it would probably be hard to implement an automatic detection, the user would have to specify the language by hand.
+         \item Vertical layout. \\
+            Sometimes, long quantum circuits on a portrait page can be better represented in a vertical layout.
+            Also if lots of explanations are to be added, this becomes problematic in the horizontal version.
+            In principle, \Yquant's approach could allow for a simple key switch that changes horizontal to vertical.
+            Currently, this is largely unsupported by all quantum circuit packages except for \pkg{qpic}.
+      \end{itemize}
+   
+   \section{Changelog}
+      \subsection{2020-03-15: Version 0.1}
+         Initial release
+      
+      \subsection{2020-03-22: Version 0.1.1}
+         Complete rewrite of the register name parser.
+         \Yquant{} now understands comma\hyp separated lists and ranges in indices, and also is far more tolerant with respect to whitespaces. \\
+         \Yquant{} now also supports non\hyp contiguous vector registers and allows to add new registers into an already existing vector that is not the last register, and also in the unstarred mode.
+%END_FOLD
+\end{document}
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/latex/yquant/yquant-doc.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex	2020-03-24 20:57:29 UTC (rev 54527)
@@ -0,0 +1,476 @@
+% BEGIN_FOLD Drawing wires
+% extends the wire of register #1. Assumes a node called yquantbox is set up, and it is a node with appropriate projections.
+\protected\def\yquant at circuit@extendwire#1{%
+   \begingroup%
+      \edef\wiretype{\yquant at register@get at type{#1}}%
+      \dimdef\wireypos{\yquant at register@get at y{#1}}%
+      \tikzset{/yquant/every wire}%
+      \unless\ifnum\wiretype=\yquant at register@type at none{%
+         \csname yquant at circuit@extendwire@\wiretype\endcsname{#1}%
+      }\fi%
+      % set the wire style to have the correct \pgflinewidth available (we don't allow individual line widths for different types of wires
+      \tikzset{/yquant/every wire}%
+      \pgfpointanchor{yquantbox}{east}%
+      \@tempdima=\pgf at x%
+      \pgfpointshapexproj{yquantbox}%
+                         {\pgfqpoint{\@tempdima}
+                                    {\dimexpr\wireypos+2\pgflinewidth\relax}}%
+      \edef\tmp{{(\the\pgf at x,\the\pgf at y)}}%
+      % For multi-qubit registers, the east anchor is not necessarily accurate.
+      \pgfpointshapexproj{yquantbox}{\pgfqpoint{\@tempdima}{\wireypos}}%
+      \edef\tmp{\tmp{(\the\pgf at x,\the\pgf at y)}}%
+      \pgfpointshapexproj{yquantbox}
+                         {\pgfqpoint{\@tempdima}%
+                                    {\dimexpr\wireypos-2\pgflinewidth\relax}}%
+      \yquant at register@set at lastwire{#1}{\tmp{(\the\pgf at x,\the\pgf at y)}}%
+   \endgroup%
+}
+
+% finishes the wire of register #1 until x position \yquant at env@end at xpos
+\protected\def\yquant at circuit@endwire#1{%
+   \begingroup%
+      \edef\wiretype{\yquant at register@get at type{#1}}%
+      \unless\ifnum\wiretype=\yquant at register@type at none\relax%
+         % we don't have a yquantbox node but still want to extend the line; so just install a dummy projection
+         \let\pgfpointshapexproj=\yquant at circuit@endwire at xproj%
+         \dimdef\wireypos{\yquant at register@get at y{#1}}%
+         \tikzset{/yquant/every wire}%
+         \csname yquant at circuit@extendwire@\wiretype\endcsname{#1}%
+      \fi%
+   \endgroup%
+}
+
+\protected\def\yquant at circuit@endwire at xproj#1#2{%
+   \pgf at process{%
+      #2%
+      \pgf at x=\yquant at env@end at xpos%
+   }%
+}
+
+\def\yquant at circuit@extendwire@@extract(#1,#2){%
+   #1%
+}
+
+% a bit faster than nested \@firstoftwo/\@secondoftwo
+% note \@thirdofthree is defined in the latex kernel already.
+\long\def\@firstofthree#1#2#3{#1}%
+\long\def\@secondofthree#1#2#3{#2}%
+
+% quantum wire
+\protected\csdef{yquant at circuit@extendwire at 1}#1{%
+   \edef\tmp{\yquant at register@get at lastwire{#1}}%
+   \edef\tmp{\expandafter\@secondofthree\tmp}%
+   \edef\lastx{\expandafter\yquant at circuit@extendwire@@extract\tmp}%
+   \pgfpointshapexproj{yquantbox}{\pgfqpoint{\lastx}{\wireypos}}%
+   \ifdim\lastx<\pgf at x%
+      \edef\cmd{%
+         \noexpand\path [/yquant/every wire, /yquant/every qubit wire]
+            \tmp -- (\the\pgf at x,\the\pgf at y);%
+      }%
+      \cmd%
+   \fi%
+}
+
+% classical wire
+\protected\csdef{yquant at circuit@extendwire at 2}#1{%
+   \edef\tmp{\yquant at register@get at lastwire{#1}}%
+   \edef\tmpa{\expandafter\@firstofthree\tmp}%
+   \edef\lastxa{\expandafter\yquant at circuit@extendwire@@extract\tmpa}%
+   \edef\tmpb{\expandafter\@thirdofthree\tmp}%
+   \edef\lastxb{\expandafter\yquant at circuit@extendwire@@extract\tmpb}%
+   \let\cmd=\empty%
+   \pgfpointshapexproj{yquantbox}{\pgfqpoint{\lastxa}%
+                                            {\dimexpr\wireypos+2\pgflinewidth\relax}}%
+   \ifdim\lastxa<\pgf at x%
+      \edef\cmd{%
+         \tmpa -- (\the\pgf at x,\the\pgf at y)%
+      }%
+   \fi%
+   \pgfpointshapexproj{yquantbox}{\pgfqpoint{\lastxb}%
+                                            {\dimexpr\wireypos-2\pgflinewidth\relax}}%
+   \ifdim\lastxb<\pgf at x%
+      \eappto\cmd{%
+         \tmpb -- (\the\pgf at x,\the\pgf at y)%
+      }%
+   \fi%
+   \unless\ifx\cmd\empty%
+      \edef\cmd{\noexpand\path [/yquant/every wire, /yquant/every cbit wire] \cmd;}%
+      \cmd%
+   \fi%
+}
+
+% quantum-bundle
+\protected\csdef{yquant at circuit@extendwire at 3}#1{%
+   \edef\tmp{\yquant at register@get at lastwire{#1}}%
+   \edef\tmpa{\expandafter\@firstofthree\tmp}%
+   \edef\lastxa{\expandafter\yquant at circuit@extendwire@@extract\tmpa}%
+   \edef\tmpb{\expandafter\@secondofthree\tmp}%
+   \edef\lastxb{\expandafter\yquant at circuit@extendwire@@extract\tmpb}%
+   \edef\tmpc{\expandafter\@thirdofthree\tmp}%
+   \edef\lastxc{\expandafter\yquant at circuit@extendwire@@extract\tmpc}%
+   \let\cmd=\empty%
+   \pgfpointshapexproj{yquantbox}{\pgfqpoint{\lastxa}%
+                                            {\dimexpr\wireypos+2\pgflinewidth\relax}}%
+   \ifdim\lastxa<\pgf at x%
+      \edef\cmd{%
+         \tmpa -- (\the\pgf at x,\the\pgf at y)%
+      }%
+   \fi%
+   \pgfpointshapexproj{yquantbox}{\pgfqpoint{\lastxb}{\wireypos}}%
+   \ifdim\lastxb<\pgf at x%
+      \eappto\cmd{%
+         \tmpb -- (\the\pgf at x,\the\pgf at y)%
+      }%
+   \fi%
+   \pgfpointshapexproj{yquantbox}{\pgfqpoint{\lastxc}%
+                                            {\dimexpr\wireypos-2\pgflinewidth\relax}}%
+   \ifdim\lastxc<\pgf at x%
+      \eappto\cmd{%
+         \tmpc -- (\the\pgf at x,\the\pgf at y)%
+      }%
+   \fi%
+   \unless\ifx\cmd\empty%
+      \edef\cmd{\noexpand\path [/yquant/every wire, /yquant/every qubits wire] \cmd;}%
+      \cmd%
+   \fi%
+}
+% END_FOLD
+
+% BEGIN_FOLD Drawing control lines
+% populates a drawing macro with the current control line with style #1 at position #2. Assumes a node called yquantbox is set up, and it is a node with appropriate projections. At the first call, \yquant at circuit@extendcontrolline at cmd must be \let to \empty and \yquant at circuit@extendcontrolline at prev to \relax.
+\protected\def\yquant at circuit@extendcontrolline#1#2{%
+   \begingroup%
+      \tikzset{/yquant/every control line}%
+      \expandafter%
+   \endgroup%
+   \expandafter\@tempdima\the\pgflinewidth%
+   \ifcase#1%
+      % no control (or to a discarded target, which we don't do)
+   \or%
+      % qubit
+      \unless\ifx\yquant at circuit@extendcontrolline at prev\relax%
+         \pgfpointanchor{yquantbox}{north}%
+         \pgfpointshapeyproj{yquantbox}{\pgf at x=#2\relax}%
+         \eappto\yquant at circuit@extendcontrolline at cmd{%
+            \expandafter\@secondofthree\yquant at circuit@extendcontrolline at prev%
+            -- (\the\pgf at x,\the\pgf at y)%
+         }%
+      \fi%
+      \yquant at circuit@extendcontrolline at store{#2}%
+   \or%
+      % cbit
+      \unless\ifx\yquant at circuit@extendcontrolline at prev\relax%
+         \pgfpointanchor{yquantbox}{north}%
+         \pgfpointshapeyproj{yquantbox}%
+                            {\pgf at x=\dimexpr#2-2\@tempdima\relax}%
+         \eappto\yquant at circuit@extendcontrolline at cmd{%
+            \expandafter\@firstofthree\yquant at circuit@extendcontrolline at prev%
+            -- (\the\pgf at x,\the\pgf at y)%
+         }%
+         \pgfpointshapeyproj{yquantbox}%
+                            {\pgf at x=\dimexpr#2+2\@tempdima\relax}%
+         \eappto\yquant at circuit@extendcontrolline at cmd{%
+            \expandafter\@thirdofthree\yquant at circuit@extendcontrolline at prev%
+            -- (\the\pgf at x,\the\pgf at y)%
+         }%
+      \fi%
+      \yquant at circuit@extendcontrolline at store{#2}%
+   \or%
+      % quantum-bundle (very unusual, but perhaps for transversal operations?)
+      \unless\ifx\yquant at circuit@extendcontrolline at prev\relax%
+         \pgfpointanchor{yquantbox}{north}%
+         \pgfpointshapeyproj{yquantbox}%
+                            {\pgf at x=\dimexpr#2-2\@tempdima\relax}%
+         \eappto\yquant at circuit@extendcontrolline at cmd{%
+            \expandafter\@firstofthree\yquant at circuit@extendcontrolline at prev%
+            -- (\the\pgf at x,\the\pgf at y)%
+         }%
+         \pgfpointshapeyproj{yquantbox}%
+                            {\pgf at x=\dimexpr#2\relax}%
+         \eappto\yquant at circuit@extendcontrolline at cmd{%
+            \expandafter\@secondofthree\yquant at circuit@extendcontrolline at prev%
+            -- (\the\pgf at x,\the\pgf at y)%
+         }%
+         \pgfpointshapeyproj{yquantbox}%
+                            {\pgf at x=\dimexpr#2+2\@tempdima\relax}%
+         \eappto\yquant at circuit@extendcontrolline at cmd{%
+            \expandafter\@thirdofthree\yquant at circuit@extendcontrolline at prev%
+            -- (\the\pgf at x,\the\pgf at y)%
+         }%
+      \fi%
+      \yquant at circuit@extendcontrolline at store{#2}%
+   \else%
+      \PackageError{yquant.sty}{Invalid control line type `\the#1'}%
+                   {yquant encountered an internal error.}%
+   \fi%
+}
+
+\protected\def\yquant at circuit@extendcontrolline at store#1{%
+   \pgfpointanchor{yquantbox}{south}%
+   \pgfpointshapeyproj{yquantbox}%
+                      {\pgf at x=\dimexpr#1-2\@tempdima\relax}%
+   \edef\yquant at circuit@extendcontrolline at prev{{(\the\pgf at x,\the\pgf at y)}}%
+   \pgfpointshapeyproj{yquantbox}%
+                      {\pgf at x=#1\relax}%
+   \eappto\yquant at circuit@extendcontrolline at prev{{(\the\pgf at x,\the\pgf at y)}}%
+   \pgfpointshapeyproj{yquantbox}%
+                      {\pgf at x=\dimexpr#1+2\@tempdima\relax}%
+   \eappto\yquant at circuit@extendcontrolline at prev{{(\the\pgf at x,\the\pgf at y)}}%
+}
+% END_FOLD
+
+\newif\ifyquant at circuit@operator at hasControls%
+% sets up the relevant variables associated with an operator
+% #1: positive controls
+% #2: negative controls
+% #3: targets
+\protected\def\yquant at circuit@operator#1#2#3{%
+   % convert all names to indices
+   % targets
+   \yquant at register@get at ids{#3}%
+   \let\yquant at circuit@operator at targets=\yquant at register@get at ids@list%
+   \let\yquant at circuit@operator at mintarget=\yquant at register@get at ids@min%
+   \let\yquant at circuit@operator at maxtarget=\yquant at register@get at ids@max%
+   \let\yquant at circuit@operator at numtarget=\yquant at register@get at ids@count%
+   % For the targets, multi-qubit registers might have been allowed, but certainly not for
+   % the controls!
+   \yquant at register@get at allowmultifalse%
+   % positive controls
+   \yquant at register@get at ids{#1}%
+   \let\yquant at circuit@operator at pctrls=\yquant at register@get at ids@list%
+   \let\yquant at circuit@operator at minpctrl=\yquant at register@get at ids@min%
+   \let\yquant at circuit@operator at maxpctrl=\yquant at register@get at ids@max%
+   \let\yquant at circuit@operator at numpctrl=\yquant at register@get at ids@count%
+   \ifnum\yquant at register@get at ids@count>0 %
+      \yquant at circuit@operator at hasControlstrue%
+   \fi%
+   % negative controls
+   \yquant at register@get at ids{#2}%
+   \let\yquant at circuit@operator at nctrls=\yquant at register@get at ids@list%
+   \let\yquant at circuit@operator at minnctrl=\yquant at register@get at ids@min%
+   \let\yquant at circuit@operator at maxnctrl=\yquant at register@get at ids@max%
+   \let\yquant at circuit@operator at numnctrl=\yquant at register@get at ids@count%
+   \ifnum\yquant at register@get at ids@count>0 %
+      \yquant at circuit@operator at hasControlstrue%
+   \fi%
+   % determine the qubits spanned
+   \yquant at min\yquant at circuit@operator at minctrl%
+      \yquant at circuit@operator at mintarget%
+      \yquant at circuit@operator at minpctrl%
+      \yquant at circuit@operator at minnctrl%
+      \relax%
+   \yquant at max\yquant at circuit@operator at maxctrl%
+      \yquant at circuit@operator at maxtarget%
+      \yquant at circuit@operator at maxpctrl%
+      \yquant at circuit@operator at maxnctrl%
+      \relax%
+   % obtain the required minimal x position
+   \yquant at register@get at maxxrange%
+      \yquant at circuit@operator at x%
+      \yquant at circuit@operator at minctrl%
+      \yquant at circuit@operator at maxctrl%
+   \dimdef\yquant at circuit@operator at x{%
+      \yquant at circuit@operator at x+\yquant at config@operator at sep%
+   }%
+}
+
+% BEGIN_FOLD Subcircuit-related
+% Does all necessary calculations for inserting a sub-circuit
+% #1: subcircuit code (should start with \begin{yquant})
+%\newbox\yquant at circuit@subcircuit at box
+%\protected\long\def\yquant at circuit@subcircuit#1{%
+%   % We need to place the inner circuit at the correct position; but for this, we need
+%   % its extent. For this, we first place it within a box. But this box is then
+%   % integrated seamlessly, in particular, named nodes must be re-placed. We use a lot of
+%   % inspiration from pgf's matrix capabilities.
+%   % First, we anticipate the macro that is used by our subcircuit to store the node
+%   % names.
+%   \edef\yquant at circuit@subcircuit at nodelist{yquant at env\the\numexpr\yquant at env+1\relax @circuit at subcircuit@nodelist}%
+%   \global\cslet\yquant at circuit@subcircuit at nodelist\empty%
+%   \pgfinterruptboundingbox%
+%      % we make sure there are no conflicts by prefixing any named nodes in any case.
+%      \ifx\yquant at lang@attr at name\empty%
+%         \pgfkeys{/tikz/name prefix/.expanded={sub\yquant at prefix-}}%
+%      \else%
+%         \pgfkeys{/tikz/name prefix/.expanded={\pgfkeysvalueof{/tikz/name prefix}\yquant at lang@attr at name-}}%
+%      \fi%
+%      \let\pgf at nodecallback=\yquant at circuit@subcircuit at nodecallback%
+%      \pgftransformreset%
+%      \global\setbox\yquant at circuit@subcircuit at box=\hbox{{%
+%         % bypass 'overlay' option
+%         \pgf at relevantforpicturesizetrue%
+%         \pgfsys at beginpicture%
+%         #1%
+%         \pgfsys at endpicture%
+%         \ifdim\pgf at picmaxx=-16000pt %
+%            \global\pgf at picmaxx=0pt %
+%            \global\pgf at picminx=0pt %
+%            \global\pgf at picmaxy=0pt %
+%            \global\pgf at picminy=0pt %
+%         \fi%
+%      }}%
+%      \wd\yquant at circuit@subcircuit at box=0pt %
+%      \global\setbox\yquant at circuit@subcircuit at box=\hbox{{%
+%         \hskip-\pgf at picminx%
+%         \unhbox\yquant at circuit@subcircuit at box%
+%         \hskip\pgf at picmaxx%
+%      }}%
+%      \ht\yquant at circuit@subcircuit at box=\pgf at picmaxy%
+%      \dp\yquant at circuit@subcircuit at box=-\pgf at picminy%
+%      % We need to remember the offset for the coordinate shifts
+%      \dimgdef\yquant at circuit@subcircuit at shiftx{-\pgf at picminx}%
+%   \endpgfinterruptboundingbox%
+%   \ifx\yquant at lang@attr at name\empty%
+%      % However, if the outer node was not named, no access to the inner nodes is desired,
+%      % so we delete all nodes again.
+%      \def\do##1{%
+%         \csgundef{pgf at sh@ns@##1}%
+%         \csgundef{pgf at sh@np@##1}%
+%         \csgundef{pgf at sh@nt@##1}%
+%         \csgundef{pgf at sh@pi@##1}%
+%         \csgundef{pgf at sh@ma@##1}%
+%      }%
+%      \dolistcsloop\yquant at circuit@subcircuit at nodelist%
+%      \global\cslet\yquant at circuit@subcircuit at nodelist\empty%
+%   \else%
+%      % But now access is desired, and probably we are deeply nested. Append the sublist to ours, so that our parent can re-map them again.
+%      \ifx\pgf at nodecallback\yquant at circuit@subcircuit at nodecallback%
+%         \csxappto{\yquant at prefix circuit at subcircuit@nodelist}%
+%                  {\csname\yquant at circuit@subcircuit at nodelist\endcsname}%
+%      \fi%
+%   \fi%
+%}
+%
+%\def\yquant at circuit@subcircuit at nodecallback#1{%
+%   \listcsxadd{\yquant at prefix circuit at subcircuit@nodelist}{#1}%
+%}
+
+%\protected\def\yquant at circuit@subcircuit at shiftnodes#1{%
+%   \expandafter\unless\expandafter\ifx\csname\yquant at circuit@subcircuit at nodelist\endcsname\empty{%
+%      \pgftransformreset%
+%      \pgf at process{\pgfpointanchor{#1}{text}}%
+%      \edef\yquant at circuit@subcircuit at offset{%
+%         \noexpand\pgfqpoint{\the\dimexpr\pgf at x+\yquant at circuit@subcircuit at shiftx\relax}%
+%                            {\the\dimexpr\pgf at y\relax}%
+%      }%
+%      \def\do##1{%
+%         \pgf at shift@node{##1}\yquant at circuit@subcircuit at offset%
+%      }%
+%      \dolistcsloop\yquant at circuit@subcircuit at nodelist%
+%   }\fi%
+%}
+% END_FOLD
+
+% BEGIN_FOLD Helpers for operator callbacks
+% turn a wire into a different type
+\def\yquant at circuit@settype#1{%
+   \yquant at register@set at type{#1}\yquant at circuit@settype at to%
+}
+
+% performs an alignment of all registers specified in the argument; that is, the next operation on any of the listed registers will be after the maximum position of all of them
+% #1: arbitrary register list
+\protected\def\yquant at circuit@align#1{%
+   \begingroup%
+      \yquant at register@get at maxxlist\x{#1}%
+      \def\do##1{%
+         \yquant at register@set at x{##1}\x%
+      }%
+      \dolistloop{#1}%
+   \endgroup%
+}
+
+% introduces a horizontal skip (= invisible operator of given width) among the registers; that is, those registers are first aligned, then skipped by the given amount.
+% #1: arbitrary register list
+% #2: skip width
+\protected\def\yquant at circuit@hspace#1#2{%
+   \begingroup%
+      \yquant at register@get at maxxlist\x{#1}%
+      \dimdef\x{\x+#2}%
+      \def\do##1{%
+         \yquant at register@set at x{##1}\x%
+      }%
+      \dolistloop{#1}%
+   \endgroup%
+}
+
+% sets the type of a list of registers
+% #1: arbitrary register list
+% #2: new type
+\protected\def\yquant at circuit@settypes#1#2{%
+   \begingroup%
+      \let\tmp=\empty%
+      \def\do##1{%
+         % We do not extend the wire: a register that is discarded somewhere does not make
+         % sense, only right after some application (which is supposed to already have
+         % extended the wire appropriately).
+         \appto\tmp{\yquant at register@set at type{##1}#2}%
+      }%
+      \dolistloop{#1}%
+      \csxappto{\yquant at prefix draw}{\tmp}%
+   \endgroup%
+}
+
+% sets the output of wires
+% #1: arbitrary register list
+\protected\def\yquant at circuit@output#1{%
+   \csxappto{\yquant at prefix outputs}%
+            {\noexpand\yquant at circuit@output at do%
+               {\noexpand#1}% there is nothing to expand - except the first token, which might be \yquant at register@multi, and we need to preserve this.
+               {\yquant at attrs@remaining}%
+               {\unexpanded\expandafter{\yquant at lang@attr at value}}%
+            }%
+}
+
+\protected\long\def\yquant at circuit@output at do#1#2#3{%
+   % this must only be called at the end of an environment, where \yquant at env@end at xpos is
+   % set up properly!
+   \def\do##1{%
+      \ifyquant at firsttoken\yquant at register@multi{##1}{%
+         \csxappto{\yquant at prefix draw}%
+                  {\noexpand\yquant at circuit@output at do@multi%
+                   \yquant at circuit@output at do@multi@@extract##1{\unexpanded{#3}}}%
+      }{%
+         \csgappto{\yquant at prefix draw}%
+                  {\yquant at circuit@output at do@single{##1}{#3}}%
+      }%
+   }%
+   % \dolistloop will carry out one \expandafter on the argument; but this expansion step
+   % is already done. If #1 starts with \yquant at register@multi, this will be expanded once
+   % despite \protected, so insert some expand-to-nothing token first.
+   \csgappto{\yquant at prefix draw}{%
+      \yquant at circuit@output at group{#2}%
+   }
+   \dolistloop{\empty#1}%
+   \csgappto{\yquant at prefix draw}{%
+      \yquant at circuit@output at endgroup%
+   }%
+}
+
+\def\yquant at circuit@output at do@multi@@extract#1#2#3#4#5{%
+   {#2}{#3}%
+}
+
+\protected\long\def\yquant at circuit@output at group#1{%
+   \begingroup%
+      \def\idx{0}%
+      \yquant at set{#1}%
+}
+
+\let\yquant at circuit@output at endgroup=\endgroup%
+
+\long\def\yquant at circuit@output at do@single#1#2{%
+   \path
+      (\yquant at env@end at xpos, \yquant at register@get at y{#1})
+      node[/yquant/every output,
+           /yquant/every \ifcase\yquant at register@get at type{#1} qubit\or cbit\or qubits\fi\space output] {#2};
+   \numdef\idx{\idx+1}%
+}
+
+\long\def\yquant at circuit@output at do@multi#1#2#3{%
+   \path[/yquant/every multi output]
+      (\yquant at env@end at xpos, \yquant at register@get at y{#1}) --
+      (\yquant at env@end at xpos, \yquant at register@get at y{#2})
+      node {#3};%
+   \numdef\idx{\idx+1}%
+}
+% END_FOLD
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/yquant/yquant-config.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-config.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-config.tex	2020-03-24 20:57:29 UTC (rev 54527)
@@ -0,0 +1,140 @@
+\usetikzlibrary{decorations.pathreplacing}
+\pgfdeclaremetadecoration{tikz at internal}{pre}{
+   \state{pre}[width=\pgfkeysvalueof{/pgf/decoration/pre length}+\pgfkeysvalueof{/pgf/decoration/post length}, next state=main]{
+      \appto\tikz at dec@shift{\pgftransformxshift{-\pgfkeysvalueof{/pgf/decoration/post length}}}
+      \tikz at dec@trans
+      \decoration{\pgfkeysvalueof{/pgf/decoration/pre}}
+   }
+   \state{main}[width=\pgfmetadecoratedremainingdistance, next state=final]{
+      \tikz at dec@trans
+      \decoration{\tikz at decoration@name}
+   }
+   \state{final}{
+      \tikz at dec@trans
+      \decoration{\pgfkeysvalueof{/pgf/decoration/post}}
+   }
+}
+\pgfqkeys{/yquant}{
+   every circuit/.style={},
+   % register settings
+   register/default name/.store in=%
+      \yquant at config@register at default@name,
+   register/minimum height/.code=%
+      {\dimdef\yquant at config@register at minimum@height{#1}},
+   register/separation/.code=%
+      {\dimdef\yquant at config@register at sep{#1}},
+   % register label style
+   every label/.style=%
+      {shape=yquant-text, anchor=circuit, align=right},
+   every initial label/.style=%
+      {anchor=east},
+   every qubit label/.style=%
+      {},
+   every cbit label/.style=%
+      {},
+   every qubits label/.style=%
+      {},
+   every multi label/.style=%
+      {shift={(-.075, 0)}, draw, decoration={brace, mirror, pre=moveto, pre length=-1mm, post=moveto, post length=-1mm}, decorate,
+       every node/.append style={shape=yquant-text, anchor=east, align=right, midway, shift={(-.025, 0)}}},
+   % output label styles
+   every output/.style=%
+      {shape=yquant-text, anchor=west, align=left},
+   every qubit output/.style=%
+      {},
+   every cbit output/.style=%
+      {},
+   every qubits output/.style=%
+      {},
+   every multi output/.style=%
+      {shift={(.075, 0)}, draw, decoration={brace, pre=moveto, pre length=-1mm, post=moveto, post length=-1mm}, decorate,
+       every node/.append style={shape=yquant-text, anchor=west, align=left, midway, shift={(.025, 0)}}},
+   % wire style
+   every wire/.style=%
+      {draw},
+   every qubit wire/.style=%
+      {},
+   every cbit wire/.style=%
+      {},
+   every qubits wire/.style=%
+      {},
+   % operator settings
+   operator/separation/.code=%
+      {\dimdef\yquant at config@operator at sep{#1}},
+   operator/minimum width/.code=%
+      {\dimdef\yquant at config@operator at minimum@width{#1}},
+   % operator style: control
+   every control line/.style=%
+      {draw},
+   every control/.style=%
+      {shape=yquant-circle, anchor=circuit, radius=.5mm},
+   every positive control/.style=%
+      {fill=black},
+   every negative control/.style=%
+      {draw},
+   % operator style: main part
+   every operator/.style=%
+      {anchor=circuit},
+   % overwriting all styles
+   this operator/.style=%
+      {},
+   this control/.style=%
+      {},
+   operator style/.style=%
+      {/yquant/this operator/.append style={#1}},
+   control style/.style=%
+      {/yquant/every control line/.append style={#1},
+       /yquant/this control/.append style={#1}},
+   style/.style=%
+      {/yquant/this operator/.append style={#1},
+       /yquant/every control line/.append style={#1},
+       /yquant/this control/.append style={#1}},
+   % different operator appearances
+   operators/every box/.style=%
+      {shape=yquant-rectangle, draw, align=center, inner xsep=1mm, x radius=2mm, y radius=2.47mm},
+   operators/every h/.style=%
+      {/yquant/operators/every box},
+   operators/every pauli/.style=%
+      {/yquant/operators/every box},
+   operators/every x/.style=%
+      {/yquant/operators/every pauli},
+   operators/every y/.style=%
+      {/yquant/operators/every pauli},
+   operators/every z/.style=%
+      {/yquant/operators/every pauli},
+%   operators/every subcircuit/.style=%
+%      {/yquant/operators/every box, inner ysep=0pt},
+   operators/every phase/.style=%
+      {shape=yquant-circle, radius=.5mm, fill},
+   operators/every zz/.style=%
+      % y radius must be twice as large as x radius (= two circles). And there is no
+      % possiblity to distort the circle to an ellipse; x radius is always the defining
+      % property!
+      {shape=yquant-zz, x radius=.5mm, y radius=1mm, fill, draw},
+   operators/every xx/.style=%
+      % same as zz
+      {shape=yquant-xx, x radius=.75mm, y radius=1.5mm, draw},
+   operators/every slash/.style=%
+      {shape=yquant-slash, x radius=.5mm, y radius=.7mm, draw},
+   operators/every swap/.style=%
+      {shape=yquant-swap, x radius=.75mm, y radius=1.5mm, draw},
+   operators/every not/.style=%
+      {shape=yquant-oplus, radius=1.3mm, draw},
+   operators/every measure/.style=%
+      {shape=yquant-measure, x radius=4mm, y radius=2.5mm, draw},
+   operators/every measure meter/.style=%
+      {draw, -{Latex[length=2.5pt]}},
+   operators/every dmeter/.style=%
+      {shape=yquant-dmeter, x radius=2mm, y radius=2mm, draw},
+   operators/every barrier/.style=%
+      {shape=yquant-barrier, dashed, draw},
+   operators/multi operator line/.is if=\yquant at config@multi at line,
+}
+
+\def\yquant at config@register at default@name{\regidx}
+\def\yquant at config@register at minimum@height{3mm}
+\def\yquant at config@register at sep{1mm}
+\def\yquant at config@operator at sep{1mm}
+\def\yquant at config@operator at minimum@width{5mm}
+\newif\ifyquant at config@multi at line
+\yquant at config@multi at linetrue
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/latex/yquant/yquant-config.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex	2020-03-24 20:57:29 UTC (rev 54527)
@@ -0,0 +1,422 @@
+% BEGIN_FOLD Actual drawing at shipout
+\newcount\yquant at draw@@currentcontroltype%
+
+\protected\def\yquant at draw@group#1#2#3#4#5{%
+   \begingroup%
+      \def\yquant at draw@@x{#1}%
+      \ifx F#2%
+         \yquant at draw@@currentcontroltype=0 %
+      \else%
+         \yquant at draw@@currentcontroltype=\yquant at register@get at type{#2}\relax%
+      \fi%
+      \let\yquant at circuit@extendcontrolline at cmd=\empty%
+      \let\yquant at circuit@extendcontrolline at prev=\relax%
+      \yquant at langhelper@list at attrs%
+      % If the quotes library is loaded, activate it. (else, this is by default \relax)
+      \tikz at enable@node at quotes%
+      \yquant at set{#3}%
+      \def\yquant at draw@@style{#4}%
+      \def\yquant at draw@@content{#5}%
+      \def\yquant at draw@@idx at content{0}%
+      \def\yquant at draw@@idx at pcontrol{0}%
+      \def\yquant at draw@@idx at ncontrol{0}%
+}
+
+\protected\def\yquant at draw@endgroup#1#2#3{%
+      \unless\ifx F#1%
+         \yquant at draw@cline%
+      \fi%
+      \ifcase#3\relax%
+      \or%
+         \yquant at draw@alias at ctrl{#2}n%
+      \or%
+         \yquant at draw@alias at ctrl{#2}p%
+      \or%
+         \yquant at draw@alias at ctrl{#2}p%
+         \yquant at draw@alias at ctrl{#2}n%
+      \or%
+         \yquant at draw@alias{#2}%
+      \or%
+         \yquant at draw@alias{#2}%
+         \yquant at draw@alias at ctrl{#2}n%
+      \or%
+         \yquant at draw@alias{#2}%
+         \yquant at draw@alias at ctrl{#2}p%
+      \or%
+         \yquant at draw@alias{#2}%
+         \yquant at draw@alias at ctrl{#2}p%
+         \yquant at draw@alias at ctrl{#2}n%
+      \fi%
+   \endgroup%
+}
+
+\protected\long\def\yquant at draw@single#1#2{%
+   \let\idx=\yquant at draw@@idx at content%
+   \edef\cmd{%
+      \noexpand\path (\yquant at draw@@x, \yquant at register@get at y{#1})%
+         node[/yquant/every operator, \yquant at draw@@style, /yquant/this operator,%
+              name prefix=, name suffix=, name=yquantbox]%
+         {\unexpanded\expandafter{\yquant at draw@@content}};%
+   }%
+   \cmd%
+   \ifpgfpointshapexproj{yquantbox}%
+      \yquant at circuit@extendwire{#1}%
+   \fi%
+   \yquant at circuit@extendcontrolline\yquant at draw@@currentcontroltype\yquant at draw@@x%
+   % check for empty name parameter
+   \if\relax\detokenize{#2}\relax%
+   \else%
+      \pgfnodealias{\tikz at pp@name{#2}}{yquantbox}%
+   \fi%
+   \numdef\yquant at draw@@idx at content{\yquant at draw@@idx at content+1}%
+}
+
+\protected\long\def\yquant at draw@multi#1#2#3#4#5{%
+   \let\idx=\yquant at draw@@idx at content%
+   % We need to somehow extract the y radius
+   \edef\cmd{%
+      \noexpand\path (\yquant at draw@@x, \the\dimexpr.5\dimexpr%
+                         \yquant at register@get at y{#1}+\yquant at register@get at y{#2}\relax%
+                      \relax)%
+         node[/yquant/every operator, \yquant at draw@@style, /yquant/this operator,%
+              y radius/.expanded=\the\dimexpr.5\dimexpr\yquant at register@get at ydist{#1}{#2}\relax\relax+%
+                     .5*\noexpand\pgfkeysvalueof{/tikz/y radius},%
+              name prefix=, name suffix=, name=yquantbox]%
+            {\unexpanded\expandafter{\yquant at draw@@content}};
+   }%
+   \cmd%
+   \ifpgfpointshapexproj{yquantbox}%
+      \let\do=\yquant at circuit@extendwire%
+      \dolistloop{#4}%
+   \fi%
+   \yquant at circuit@extendcontrolline\yquant at draw@@currentcontroltype\yquant at draw@@x%
+   % check for empty name parameter
+   \if\relax\detokenize{#5}\relax%
+   \else%
+      \pgfnodealias{\tikz at pp@name{#5}}{yquantbox}%
+   \fi%
+   \numdef\yquant at draw@@idx at content{\yquant at draw@@idx at content+1}%
+}
+
+\protected\long\def\yquant at draw@multiinit#1#2#3#4#5{%
+   \let\idx=\yquant at draw@@idx at content%
+   % We need to somehow extract the y radius
+   \edef\cmd{%
+      \noexpand\path[/yquant/every operator, \yquant at draw@@style,%
+                     /yquant/every multi label, /yquant/this operator]%
+         (\yquant at draw@@x, \yquant at register@get at y{#1}) --%
+         (\yquant at draw@@x, \yquant at register@get at y{#2})%
+         node[name prefix=, name suffix=, name=yquantbox]%
+            {\unexpanded\expandafter{\yquant at draw@@content}};
+   }%
+   \cmd%
+   % no wire extension (we are still at the initial position), no control line (init doesn't allow for those, so just save the no-op)
+   % check for empty name parameter
+   \if\relax\detokenize{#5}\relax%
+   \else%
+      \pgfnodealias{\tikz at pp@name{#5}}{yquantbox}%
+   \fi%
+   \numdef\yquant at draw@@idx at content{\yquant at draw@@idx at content+1}%
+}
+
+\protected\def\yquant at draw@control#1#2#3{%
+   \edef\cmd{%
+      \noexpand\path (\yquant at draw@@x, \yquant at register@get at y{#2})%
+         node[/yquant/every control, /yquant/every #1 control, /yquant/this control,%
+              name prefix=, name suffix=, name=yquantbox]%
+         {};%
+   }%
+   \cmd%
+   \ifpgfpointshapexproj{yquantbox}%
+      \yquant at circuit@extendwire{#2}%
+   \fi%
+   \yquant at draw@@currentcontroltype=\yquant at register@get at type{#2}\relax%
+   \yquant at circuit@extendcontrolline\yquant at draw@@currentcontroltype\yquant at draw@@x%
+   % check for empty name parameter
+   \if\relax\detokenize{#3}\relax%
+   \else%
+      \pgfnodealias{\tikz at pp@name{#3}}{yquantbox}%
+   \fi%
+}
+
+\protected\def\yquant at draw@pcontrol#1#2{%
+   \let\idx=\yquant at draw@@idx at pcontrol%
+   \yquant at draw@control{positive}{#1}{#2}%
+   \numdef\yquant at draw@@idx at pcontrol{\yquant at draw@@idx at pcontrol+1}%
+}
+
+\protected\def\yquant at draw@ncontrol#1#2{%
+   \let\idx=\yquant at draw@@idx at ncontrol%
+   \yquant at draw@control{negative}{#1}{#2}%
+   \numdef\yquant at draw@@idx at ncontrol{\yquant at draw@@idx at ncontrol+1}%
+}
+
+\protected\def\yquant at draw@cline{%
+   \edef\cmd{%
+      \noexpand\path[/yquant/every control line]%
+         \yquant at circuit@extendcontrolline at cmd;
+   }%
+   \cmd%
+}
+
+\protected\def\yquant at draw@alias#1{%
+   \pgfnodealias{\tikz at pp@name{#1}}{\tikz at pp@name{#1-0}}%
+}
+
+\protected\def\yquant at draw@alias at ctrl#1#2{%
+   \pgfnodealias{\tikz at pp@name{#1-#2}}{\tikz at pp@name{#1-#20}}%
+}
+% END_FOLD
+
+% BEGIN_FOLD Preparation of drawing a generic shape
+% Most drawing operations will be realized through nodes
+\let\yquant at draw@callback at box=\@gobble
+\let\yquant at draw@callback at wire=\@gobble
+
+\def\yquant at draw@sort#1#2{%
+   \yquant at draw@sort at aux#1\relax#2\relax%
+      \expandafter\@firstoftwo%
+   \else%
+      \expandafter\@secondoftwo%
+   \fi%
+}
+
+\def\yquant at draw@sort at aux#1#2#3\relax#4#5#6\relax{%
+   \unless\ifnum#2>#5\relax%
+}
+
+% generic shape of an operator
+% #1: value
+% #2: tikz options that select the correct shape
+% #3: positive controls
+% #4: negative controls
+% #5: targets
+\protected\long\def\yquant at draw#1#2#3#4#5{%
+   % setup the required macros
+   \yquant at circuit@operator{#3}{#4}{#5}%
+   \yquant at draw@{#1}{#2}%
+}
+
+\protected\long\def\yquant at draw@#1#2{%
+   \yquant at sort@clear%
+   \def\idx{0}%
+   \dimen2=\yquant at config@operator at minimum@width%
+   % BEGIN_FOLD register
+   \def\do##1{%
+      \ifx\yquant at lang@attr at name\empty%
+         \let\nodename=\empty%
+      \else%
+         \edef\nodename{\yquant at lang@attr at name-\idx}%
+      \fi%
+      \ifyquant at firsttoken\yquant at register@multi{##1}{%
+         \yquant at draw@@multi{#1}{#2}{##1}%
+      }{%
+         \yquant at draw@@single{#1}{#2}{##1}%
+      }%
+         \expandafter%
+      \endpgfinterruptboundingbox%
+      \expandafter\dimen\expandafter0\expandafter=%
+         \the\dimexpr\pgf at picmaxx-\pgf at picminx\relax\relax%
+      \ifdim\dimen0>\dimen2 %
+         \dimen2=\dimen0 %
+      \fi%
+      \numdef\idx{\idx+1}%
+      % TODO
+%      \yquant at draw@callback at box\nodename%
+   }%
+   \dolistloop\yquant at circuit@operator at targets%
+   % END_FOLD
+   % BEGIN_FOLD controls
+   \ifyquant at circuit@operator at hasControls%
+      \def\do##1{%
+         \ifx\yquant at lang@attr at name\empty%
+            \let\nodename=\empty%
+         \else%
+            \edef\nodename{\yquant at lang@attr at name-\yquant at draw@controlprefix\idx}%
+         \fi%
+         \yquant at sort@eadd{%
+            \expandafter\noexpand\csname yquant at draw@\yquant at draw@controlprefix control\endcsname%
+               {##1}% register index
+               {\nodename}%
+         }%
+         \unless\ifdefined\yquant at draw@controltype%
+            \edef\yquant at draw@controltype{##1}%
+         \fi%
+         \numdef\idx{\idx+1}%
+      }
+      \def\yquant at draw@controlprefix{p}%
+      \def\idx{0}%
+      \dolistloop\yquant at circuit@operator at pctrls%
+      \def\yquant at draw@controlprefix{n}%
+      \def\idx{0}%
+      \dolistloop\yquant at circuit@operator at nctrls%
+      \unless\ifdefined\yquant at draw@controltype%
+         \PackageError{yquant.sty}{Assertion failure}%
+                      {Internal inconsistency in yquant: Controlled action detected, but no controls were found.}%
+      \fi%
+   \fi%
+   % END_FOLD
+   % We now know the dimensions of all the registers (though we didn't bother with the height of the control knobs [if present], we just assume they are too small to change this).
+   \protected\def\idx{}%
+   \protected at edef\yquant at draw@append{%
+      \noexpand\yquant at draw@group%
+         {\the\dimexpr\yquant at circuit@operator at x+.5\dimen2\relax}% mid x position
+         \ifyquant at circuit@operator at hasControls%
+           \yquant at draw@controltype%
+         \else%
+           F%
+         \fi% if-switch whether controls are present
+         {\yquant at attrs@remaining}% custom style
+         {#2}% operator style
+         {#1}%
+   }%
+   \yquant at sort\yquant at draw@sort%
+   \advance \dimen2 by \yquant at circuit@operator at x\relax%
+   % BEGIN_FOLD shipout
+   \ifyquant at circuit@operator at hasControls%
+      % If we draw a control line, all intermediate registers are affected in their position so that the line is never crossed.
+      \yquant at for \yquant at i := \yquant at circuit@operator at minctrl to \yquant at circuit@operator at maxctrl {%
+         \yquant at register@set at x\yquant at i{\the\dimen2}%
+      }%
+   \fi%
+   \def\do##1{%
+      \appto\yquant at draw@append{##1}%
+      \yquant at draw@finalize at ctrl##1%
+   }%
+   \yquant at sort@dolistloop%
+   \csxappto{\yquant at prefix draw}{%
+      \unexpanded\expandafter{\yquant at draw@append}%
+      \noexpand\yquant at draw@endgroup%
+         \ifyquant at circuit@operator at hasControls%
+            T%
+         \else%
+            F%
+         \fi%
+         \ifx\yquant at lang@attr at name\empty%
+            {}0%
+         \else%
+            {\yquant at lang@attr at name}%
+            \ifnum\yquant at circuit@operator at numtarget=1 %
+               \ifnum\yquant at circuit@operator at numpctrl=1 %
+                  \ifnum\yquant at circuit@operator at numnctrl=1 %
+                     7%
+                  \else%
+                     6%
+                  \fi%
+               \else%
+                  \ifnum\yquant at circuit@operator at numnctrl=1 %
+                     5%
+                  \else%
+                     4%
+                  \fi%
+               \fi%
+            \else%
+               \ifnum\yquant at circuit@operator at numpctrl=1 %
+                  \ifnum\yquant at circuit@operator at numnctrl=1 %
+                     3%
+                  \else%
+                     2%
+                  \fi%
+               \else%
+                  \ifnum\yquant at circuit@operator at numnctrl=1 %
+                     1%
+                  \else%
+                     0%
+                  \fi%
+               \fi%
+            \fi%
+         \fi%
+   }%
+   % END_FOLD
+}
+
+\protected\def\yquant at draw@@single#1#2#3{%
+   \yquant at sort@eadd{%
+      \yquant at draw@single%
+         {#3}% register index
+         {\nodename}%
+   }%
+   % determine the actual dimensions by a virtual draw command
+   \pgfinterruptboundingbox%
+      \yquant at env@virtualize at path%
+      \path%
+         (0pt, 0pt)
+         node[/yquant/every operator, #2, /yquant/this operator,%
+              name prefix=, name suffix=, name=] {#1};%
+      \yquant at register@update at height{#3}{%
+         \the\dimexpr\pgf at picmaxy-\pgf at picminy\relax%
+      }%
+}
+
+\protected\def\yquant at draw@@multi#1#2#3{%
+   \yquant at sort@eadd{%
+      \yquant at draw@multi%
+         #3%
+         {\nodename}%
+   }%
+   % Determining the actual height is a problem - where to store its value? We just assume that there is always enough space for such a control, since it anyway already spans multiple registers. (TODO?)
+   \pgfinterruptboundingbox%
+      \yquant at env@virtualize at path%
+      % Here, we just set a dummy height, as we don't know the actual height yet. As the width of most/all shapes should not depend on their height, it does not matter.
+      \path%
+         (0pt, 0pt)
+         node[/yquant/every operator, #2, /yquant/this operator, y radius=1cm,%
+              name prefix=, name suffix=0, name=] {#1};
+}
+
+\protected\def\yquant at draw@@multiinit#1#2#3{%
+   \yquant at sort@eadd{%
+      \yquant at draw@multiinit%
+         #3%
+         {\nodename}%
+   }%
+   % Determining the actual height is a problem - where to store its value? We just assume that there is always enough space for such a control, since it anyway already spans multiple registers. (TODO?)
+   \pgfinterruptboundingbox%
+      \yquant at env@virtualize at path%
+      % Here, we just set a dummy height, as we don't know the actual height yet. As the width of most/all shapes should not depend on their height, it does not matter.
+      \path%
+         (0pt, 0pt)
+         node[/yquant/every operator, #2, /yquant/every multi label, y radius=1cm,%
+              name prefix=, name suffix=0, name=] {#1};
+}
+
+\def\yquant at draw@finalize at ctrl#1{%
+   \ifx\yquant at draw@multi#1%
+      \expandafter\yquant at draw@finalize at ctrl@multi%
+   \else%
+      \ifx\yquant at draw@multiinit#1%
+         \expandafter\expandafter\expandafter\yquant at draw@finalize at ctrl@multi%
+      \else%
+         \expandafter\expandafter\expandafter\yquant at draw@finalize at ctrl@single%
+      \fi%
+   \fi%
+}
+
+\protected\def\yquant at draw@finalize at ctrl@single#1#2{%
+   \unless\ifyquant at circuit@operator at hasControls%
+      \yquant at register@set at x#1{\the\dimen2}%
+   \fi%
+   \eappto\yquant at draw@append{%
+      \yquant at draw@callback at wire{#1}%
+   }%
+}
+
+\protected\def\yquant at draw@finalize at ctrl@multi#1#2#3#4#5{%
+   \unless\ifyquant at circuit@operator at hasControls{%
+      % \yquant at for uses \loop...\repeat and hence redefines \body, which would destroy an outer loop.
+      % if we did not draw a control line, the x position has not yet been set. A multi-qubit register might visually extend over multiple registers that are not even part, hence we update them all.
+      \yquant at for \yquant at i := #1 to #2 {%
+         \yquant at register@set at x\yquant at i{\the\dimen2}%
+      }%
+   }\fi%
+   % this is called from a do loop itself, so preserve \do (but do not enter grouping)
+   \let\yquant at draw@update at x@multi@@olddo=\do%
+   \def\do##1{%
+      \eappto\yquant at draw@append{%
+         \yquant at draw@callback at wire{##1}%
+      }%
+   }%
+   \dolistloop{#4}%
+   \let\do=\yquant at draw@update at x@multi@@olddo%
+}
+% END_FOLD
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/yquant/yquant-env.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-env.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-env.tex	2020-03-24 20:57:29 UTC (rev 54527)
@@ -0,0 +1,261 @@
+\newif\ifyquant at env@lazy
+
+\protected\def\yquant at envunstar{%
+   \yquant at env@lazyfalse%
+   \yquant at env@begin%
+}
+
+\protected\def\yquant at envstar{%
+   \yquant at env@lazytrue%
+   \yquant at env@begin%
+}
+
+\protected\def\yquant at env@begin{%
+   % We check for an optional argument, but if it is in a new line, we don't take it - it
+   % might well be the square brace of an argument. Temporary change newlines to ordinary
+   % characters.
+   \catcode`\^^M=12 %
+   \yquant at futurenonspacelet\yquant at env@begin at next\yquant at env@begin at checkarg%
+}
+
+{\catcode`\^^M=12 \global\let\yquant at env@linebreak=^^M}
+
+\protected\def\yquant at env@begin at checkarg{%
+   \catcode`\^^M=5 %
+   \ifx\yquant at env@begin at next[%
+      \expandafter\yquant at env@begin at arg%
+   \else%
+      \ifx\yquant at env@begin at next\yquant at env@linebreak%
+         % In this case we don't really want to inject the wrong-catcode linebreak back,
+         % which would produce an error.
+         \afterassignment\yquant at env@begin at noarg%
+         \expandafter\expandafter\expandafter\let%
+         \expandafter\expandafter\expandafter\@eattoken%
+         % since ^^M is an ordinary character, no need for "= ".
+      \else%
+         \expandafter\expandafter\expandafter\yquant at env@begin at noarg%
+      \fi%
+   \fi%
+}
+
+\def\yquant at env@begin at noarg{%
+   \yquant at env@begin at arg[]%
+}
+
+\long\protected\def\yquant at env@begin at arg[#1]{%
+   \begingroup%
+      \advance\yquant at env by 1 %
+      \edef\yquant at prefix{yquant at env\the\yquant at env @}%
+      \let\yquant=\yquant at env@scan%
+      \yquant at lang@reset at attrs%
+      \csgdef{\yquant at prefix registers}{0}%
+%      \csgdef{\yquant at prefix lasty}{0pt}%
+      \global\cslet{\yquant at prefix draw}\relax%
+      \global\cslet{\yquant at prefix outputs}\relax%
+      \csxdef{\yquant at prefix cleanup}{%
+         \expandafter\noexpand\csname\yquant at prefix registers\endcsname%
+         \expandafter\noexpand\csname\yquant at prefix draw\endcsname%
+         \expandafter\noexpand\csname\yquant at prefix outputs\endcsname%
+         \expandafter\noexpand\csname\yquant at prefix cleanup\endcsname%
+      }%
+      \ifnum\yquant at env=1 %
+         \yquant at env@substikz%
+      \fi%
+      \scope[{/yquant/.cd, every circuit, #1}]%
+}
+\newif\ifyquantdebug
+\protected\def\yquant at env@end{%
+         \letcs\yquant at env@end at registers{\yquant at prefix registers}%
+         \ifnum\yquant at env@end at registers>0 %
+            % draw all wires
+            \yquant at register@get at maxxrange\yquant at env@end at xpos{1}{\yquant at env@end at registers}%
+            % to have a symmetric situation, we extend again one separation at the end
+            \csxappto{\yquant at prefix draw}{%
+               \def\noexpand\yquant at env@end at xpos{%
+                  \the\dimexpr\yquant at env@end at xpos+\yquant at config@operator at sep\relax%
+               }%
+            }
+            % also calculate the true y positions
+            \dimen0=0pt %
+            \dimen2=0pt %
+            \dimen4=\yquant at config@register at sep %
+            \yquant at for \i := 1 to \yquant at env@end at registers {%
+               % add a final wire
+               \csxappto{\yquant at prefix draw}{%
+                  \yquant at circuit@endwire{\i}%
+               }%
+               % we do not care if the wire is present for the y position
+               \dimen2=.5\dimexpr\yquant at register@get at height\i\relax%
+               \advance\dimen0 by \dimen2\relax%
+               % top-to-bottom means negative coordinates in pgf
+               \yquant at register@set at y\i{-\the\dimen0}%
+               \advance\dimen0 by \dimen2\relax%
+               \advance\dimen0 by \dimen4\relax%
+            }%
+            \csname\yquant at prefix outputs\endcsname%
+         \fi%
+      \endscope%
+      % Now we actually carry out the tikz commands which were previously stored in the draw command. But before this, we get rid of all \yquant at env@scan calls and also restore the scope command, since this would add itself once again. And get at y needs to expand.
+      \let\path=\tikz at command@path%
+      \let\tikz at lib@scope at check=\yquant at env@substikz at scopecheck%
+      \let\tikz at scope@opt=\yquant at env@substikz at scope%
+      \let\endtikz at scope@env=\yquant at env@substikz at endscope%
+      \let\endscope=\endtikz at scope@env%
+      \let\stopscope=\endscope%
+      \yquant at register@get at y@@expandable%
+      \ifyquantdebug%
+         \csshow{\yquant at prefix draw}%
+      \fi%
+      \csname\yquant at prefix draw\endcsname%
+      \expandafter\expandafter\expandafter\yquant at cleanup\csname\yquant at prefix cleanup\endcsname|%
+   \endgroup%
+}
+
+\tikzaddtikzonlycommandshortcutlet\yquant\yquant at envunstar
+\expandafter\tikzaddtikzonlycommandshortcutlet\csname yquant*\endcsname\yquant at envstar
+\tikzaddtikzonlycommandshortcutlet\endyquant\yquant at env@end
+\expandafter\tikzaddtikzonlycommandshortcutlet\csname endyquant*\endcsname\yquant at env@end
+
+\protected\def\yquantset{%
+   \pgfqkeys{/yquant}%
+}
+\let\yquant at set=\yquantset%
+
+% private yquant-language related helpers
+% In order to allow nested environments and also grouping (without the need to smuggle definitions out of the groups whenever necessary), we count the number of nested environments.
+\newcount\yquant at env
+
+\def\yquant at env@substikz at finish{%
+   % Rendering pipeline
+   \endgroup%
+   \global\pgflinewidth=\tikzscope at linewidth\relax%
+   \tikz at path@do at at@end%
+}
+
+% first undoes the substikz commands, next turns the \path command into a virtual one that does not produce any output.
+\protected\def\yquant at env@virtualize at path{%
+   \yquant at register@get at y@@expandable%
+   \let\path=\tikz at command@path%
+   \let\tikz at finish=\yquant at env@substikz at finish%
+   \let\tikz at lib@scope at check=\yquant at env@substikz at scopecheck%
+}
+
+% substitute the tikz commands (defined in \tikz at installcommands) so that they can be arbitrarily interleaved with yquant code. We patch \path, \scope, \endscope, \stopscope, their internal complements, and also patch \yquantset.
+\protected\def\yquant at env@substikz{%
+   % \tikz at path@do at at@end is called after a path. Hence, it is an ideal candidate to re-invoke \yquant at env@scan. However, it is by default defined to be \tikz at lib@scope at check, and we need this definition for the scopes library to work correctly. But since \tikz at lib@scope at check is also called after a scope and the end of a scope, this is even better. Yet, we need to check whether the scopes library is present or not.
+   \let\yquant at env@substikz at scopecheck=\tikz at lib@scope at check%
+   \ifx\tikz at lib@scope at check\pgfutil at empty%
+      % no, it is not. This is simple.
+      \let\tikz at lib@scope at check=\yquant at env@scan%
+   \else%
+      % yes, it is. Call it after the special behavior is done.
+      \patchcmd\tikz at lib@scope at check{{}}{\yquant at env@scan}\relax{%
+         \PackageWarning{yquant.sty}{Patching \string\tikz at lib@scope at check\space failed; you must invoke \string\yquant\space manually after every tikz command to switch back to yquant code.}%
+      }
+   \fi%
+   % We not only need to re-invoke yquant after the tikz command, but we must also make sure that the tikz command is not actually drawn now, but at the end. However, what happens if some macros are used within the command? Here, we choose to expand the macros to the values they have _now_, but protected (which should prevent bad things for formatting commands). If you find this to be an issue, please report.
+   \def\path##1;{%
+      \protected at csxappto{\yquant at prefix draw}{%
+         \noexpand\path##1;%
+      }%
+      \yquant%
+   }%
+   % no need for \scoped, because it internally calls \scope.
+   % We need to hack into \scope, but this is a bit tricky due to its argument handling. In order to get all optional arguments, including the possible animations library, correct, we change \tikz at scope@opt.
+   \let\yquant at env@substikz at scope=\tikz at scope@opt%
+   \def\tikz at scope@opt[##1]{%
+      \protected at csxappto{\yquant at prefix draw}{%
+         \noexpand\tikz at scope@env[{##1}]%
+      }%
+      \yquant at env@substikz at scope[{##1}]%
+   }%
+   \let\yquant at env@substikz at endscope=\endtikz at scope@env%
+   \def\endtikz at scope@env{%
+      \csgappto{\yquant at prefix draw}{%
+         \yquant at env@substikz at endscope%
+      }%
+      \yquant at env@substikz at endscope%
+   }%
+   \let\endscope=\endtikz at scope@env%
+   \let\stopscope=\endscope%
+   % We define \yquantset as a pgfkeys-like macro. Anything else would deteriorate performance badly, as \pgfkeys, \pgfqkeys, or \tikzset are used a lot internally.
+   \protected\def\yquantset##1{%
+      \protected at csxappto{\yquant at prefix draw}{%
+         \noexpand\pgfqkeys{/yquant}{##1}%
+      }%
+      \pgfqkeys{/yquant}{##1}%
+      \yquant at env@scan%
+   }%
+}
+
+% Scan until the next non-space token is found and execute it as a csname
+\def\yquant at env@scan{%
+   \begingroup%
+      \yquant at env@contscan%
+}
+
+\protected\def\yquant at env@contscan{%
+   \yquant at futurenonspacelet\yquant at env@nextchar\yquant at env@check%
+}
+
+\def\yquant at env@rescan{%
+   \endgroup%
+   \yquant at env@scan%
+}
+
+\protected\def\yquant at env@check{%
+   \let\next=\relax%
+   % Here we assume standard catcodes for A and [, but our language specification also requires this implicitly.
+   \ifx\yquant at env@nextchar[%
+      \let\next=\yquant at langhelper@check at attrs%
+   \else%
+      \ifcat\noexpand\yquant at env@nextchar A% letter
+         \let\next=\yquant at langhelper@check at name%
+      \else%
+         \ifcat\noexpand\yquant at env@nextchar\bgroup%
+            \endgroup%
+            \let\next=\yquant at env@opengroup%
+         \else%
+            \ifcat\noexpand\yquant at env@nextchar\egroup%
+               \endgroup%
+               \let\next=\yquant at env@closegroup%
+            \else%
+               \ifx\yquant at env@nextchar\par%
+                  \let\next=\yquant at env@gobblepar%
+               \else%
+                  \ifcat\noexpand\yquant at env@nextchar\relax%
+                     \endgroup%
+                     \let\next=\relax%
+                  \else%
+                     \PackageError{yquant.sty}%
+                        {Invalid yquant syntax: `\meaning\yquant at env@nextchar'}%
+                        {Adhere to the specs!}%
+                  \fi%
+               \fi%
+            \fi%
+         \fi%
+      \fi%
+   \fi%
+   \next%
+}
+
+\protected\def\yquant at env@opengroup{%
+   \afterassignment\yquant at env@opengroup at aux%
+   \let\@eattoken= %
+}
+
+\def\yquant at env@opengroup at aux{%
+   \bgroup%
+      \csgappto{\yquant at prefix draw}{\begingroup}%
+      \yquant at env@scan%
+}
+
+\def\yquant at env@closegroup{%
+   \csgappto{\yquant at prefix draw}{\endgroup}%
+   \aftergroup\yquant at env@scan%
+}
+
+\def\yquant at env@gobblepar{%
+   \afterassignment\yquant at env@contscan%
+   \let\@eattoken= %
+}
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/latex/yquant/yquant-env.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/yquant/yquant-lang.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-lang.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-lang.tex	2020-03-24 20:57:29 UTC (rev 54527)
@@ -0,0 +1,559 @@
+% BEGIN_FOLD Attributes
+\yquant at langhelper@declare at attr{
+   value/.store in=\yquant at lang@attr at value,
+   after/.code={%
+      \yquant at register@get at ids{#1}%
+      \let\yquant at lang@attr at after=\yquant at register@get at ids@list%
+   },
+   type/.store in=\yquant at lang@attr at type
+}
+\yquant at langhelper@declare at attr@global{
+   name/.store in=\yquant at lang@attr at name
+}
+
+\protected\def\yquant at lang@reset at attrs{%
+   \undef\yquant at lang@attr at value%
+   \undef\yquant at lang@attr at after%
+   \undef\yquant at lang@attr at type%
+   \let\yquant at lang@attr at name=\empty%
+}
+% END_FOLD
+
+% BEGIN_FOLD Declaration of registers
+\yquant at langhelper@declare at command@uncontrolled{nobit}\yquant at lang@@nobit
+\yquant at langhelper@setup at attrs{nobit}{}{}
+\def\yquant at lang@@nobit#1{%
+   \let\yquant at lang@create at type=\yquant at register@type at none%
+   \def\yquant at lang@create at style{initial}% there is no separate style, just duplicate
+   \ifdefined\yquant at lang@attr at value%
+      \PackageError{yquant.sty}{Placeholder initialization must not have value}%
+                   {You must not provide a description for an invisible register.}
+   \else
+      \let\yquant at lang@attr at value=\empty%
+   \fi%
+   \yquant at lang@create at parse@name#1[;
+}
+
+\yquant at langhelper@declare at command@uncontrolled{qubit}\yquant at lang@@qubit
+\yquant at langhelper@setup at attrs{qubit}{}{after,value}
+\def\yquant at lang@@qubit#1{%
+   \let\yquant at lang@create at type=\yquant at register@type at q%
+   \def\yquant at lang@create at style{qubit}%
+   \unless\ifdefined\yquant at lang@attr at value%
+      \let\yquant at lang@attr at value=\yquant at config@register at default@name%
+   \fi%
+   \yquant at lang@create at parse@name#1[;
+}
+
+\yquant at langhelper@declare at command@uncontrolled{cbit}\yquant at lang@@cbit
+\yquant at langhelper@setup at attrs{qubit}{}{after,value}
+\def\yquant at lang@@cbit#1{%
+   \let\yquant at lang@create at type=\yquant at register@type at c%
+   \def\yquant at lang@create at style{qubit}%
+   \unless\ifdefined\yquant at lang@attr at value%
+      \let\yquant at lang@attr at value=\yquant at config@register at default@name%
+   \fi%
+   \yquant at lang@create at parse@name#1[;
+}
+
+\yquant at langhelper@declare at command@uncontrolled{qubits}\yquant at lang@@qubits
+\yquant at langhelper@setup at attrs{qubit}{}{after,value}
+\def\yquant at lang@@qubits#1{%
+   \let\yquant at lang@create at type=\yquant at register@type at qs%
+   \def\yquant at lang@create at style{qubits}%
+   \unless\ifdefined\yquant at lang@attr at value%
+      \let\yquant at lang@attr at value=\yquant at config@register at default@name%
+   \fi%
+   \yquant at lang@create at parse@name#1[;
+}
+
+\def\yquant at lang@create at parse@name#1[#2;{%
+   \if\relax\detokenize{#2}\relax%
+      \yquant at lang@create at do#1[1][;%
+   \else%
+      \yquant at lang@create at do#1[#2;%
+   \fi%
+}
+
+\protected\def\yquant at lang@create at do#1[#2]#3[;{%
+   % parse length
+   \if\relax\detokenize{#3}\relax%
+      \yquant at langhelper@validate\len\count{#2}%
+      \ifnum\len<1 %
+         \PackageError{yquant.sty}{Invalid register length}%
+                      {Valid register lengths are integers greater or equal to one.}%
+      \fi
+   \else%
+      \PackageError{yquant.sty}{Invalid register name}%
+         {Register names must not contain `[' apart from register length indication.}%
+   \fi%
+   \edef\reg{\trim at spaces{#1}}%
+   % we allow for scattering, so check whether the register already exists
+   \ifcsname\yquant at prefix registerhigh@\reg\endcsname%
+      \ifyquant at firsttoken+{#2}{%
+         \numdef\idx{\csname\yquant at prefix registerhigh@\reg\endcsname+1}%
+         \numdef\len{\len+\idx}%
+      }{%
+         \PackageError{yquant.sty}{Duplicate registers}%
+            {Register `\reg' was already defined. Use `\reg[+#2]' with explicit plus symbol to indicate that you want to enlarge the register on purpose.}%
+      }%
+   \else%
+      \def\idx{0}%
+   \fi%
+   % define text macros
+   \ifnum\len=1 %
+      \let\regidx=\reg%
+   \else%
+      \def\regidx{\reg[\idx]}%
+   \fi%
+   % determine x position
+   \ifdefined\yquant at lang@attr at after%
+      \yquant at register@get at maxxlist\yquant at lang@create at x\yquant at lang@attr at after%
+   \else%
+      \def\yquant at lang@create at x{0pt}%
+   \fi%
+   \begingroup%
+      \ifx\yquant at lang@attr at name\empty%
+         \let\yquant at lang@create at name=\empty%
+      \else%
+         \def\yquant at lang@create at name{\yquant at lang@attr at name-\idx}%
+      \fi%
+      % pre-set y position
+      \yquant at for \idx := \idx to \numexpr \len -1\relax {%
+         \yquant at register@define%
+            \yquant at lang@create at type%
+            \yquant at lang@create at x%
+            \reg\idx%
+         % First determine the actual height by a virtual draw command
+         \pgfinterruptboundingbox%
+            \yquant at env@virtualize at path%
+            \path%
+               (\yquant at lang@create at x, 0pt)
+               node[/yquant/every label, /yquant/every initial label,%
+                    /yquant/every \yquant at lang@create at style\space label]
+               {\trim at spaces{\yquant at lang@attr at value}};%
+            \expandafter\yquant at register@update at height%
+               \csname\yquant at prefix registers\endcsname%
+               {\the\dimexpr\pgf at picmaxy-\pgf at picminy\relax}%
+         \endpgfinterruptboundingbox%
+         % Prepare to shipout
+         \protected at csxappto{\yquant at prefix draw}{%
+            \yquant at lang@create at draw{\csname\yquant at prefix registers\endcsname}%
+                                    {\yquant at lang@create at x}%
+                                    {\yquant at lang@create at style}%
+                                    {\yquant at lang@attr at value}%
+                                    {\yquant at lang@create at name}%
+         }%
+      }%
+      \unless\ifx\yquant at lang@attr at name\empty%
+         \ifnum\len=1 %
+            \csxappto{\yquant at prefix draw}%
+                     {\yquant at draw@alias{\yquant at lang@attr at name}}%
+         \fi%
+      \fi%
+   \endgroup%
+}
+
+\protected\def\yquant at lang@create at draw#1#2#3#4#5{%
+   \begingroup%
+      \dimdef\wireypos{\yquant at register@get at y{#1}}%
+      \if\relax\detokenize{#4}\relax%
+         % For empty labels, we still put the node at the appropriate position as it may needs to be referenced, but we will not let it effect the bounding box (so that the left end is not shifted), and we don't need an inner separation, so that the label is truely just a coordinate.
+         \path[overlay]
+            (#2, \wireypos)%
+            coordinate[name prefix=, name suffix=, name=yquantbox];
+      \else%
+         \path
+            (#2, \wireypos)%
+            node[/yquant/every label, /yquant/every initial label,%
+                 /yquant/every #3 label, name prefix=, name suffix=, name=yquantbox]%
+                {#4};%
+      \fi%
+      % set the wire style to have the correct \pgflinewidth available (we don't allow individual line widths for different types of wires)
+      \tikzset{/yquant/every wire}%
+      \pgfpointanchor{yquantbox}{east}%
+      % Every label shape should implement the projection anchor, else we just guess the values, but this might be inaccurate for non-rectangular shapes
+      \ifpgfpointshapexproj{yquantbox}%
+         \@tempdima=\pgf at x%
+         \pgfpointshapexproj{yquantbox}%
+                            {\pgfqpoint{\@tempdima}
+                                       {\dimexpr\wireypos+2\pgflinewidth\relax}}%
+         \edef\tmp{{(\the\pgf at x,\the\pgf at y)}}%
+         % This projection should normally not be necessary, as the east anchor _should_ be accurate - but who knows?
+         \pgfpointshapexproj{yquantbox}{\pgfqpoint{\@tempdima}{\wireypos}}%
+         \edef\tmp{\tmp{(\the\pgf at x,\the\pgf at y)}}%
+         \pgfpointshapexproj{yquantbox}
+                            {\pgfqpoint{\@tempdima}%
+                                       {\dimexpr\wireypos-2\pgflinewidth\relax}}%
+         \yquant at register@set at lastwire{#1}{\tmp{(\the\pgf at x,\the\pgf at y)}}%
+      \else%
+         % Just guess the values.
+         \yquant at register@set at lastwire{#1}{%
+            {(\the\pgf at x,\the\dimexpr\wireypos+2\pgflinewidth\relax)}%
+            {(\the\pgf at x,\wireypos)}%
+            {(\the\pgf at x,\the\dimexpr\wireypos-2\pgflinewidth\relax)}%
+         }%
+      \fi%
+      \if\relax\detokenize{#5}\relax%
+      \else%
+         \pgfnodealias{\tikz at pp@name{#5}}{yquantbox}%
+      \fi%
+   \endgroup%
+}
+% END_FOLD
+
+% BEGIN_FOLD Box registers
+% all-purpose box with arbitrary text
+\yquant at langhelper@declare at command{box}\yquant at lang@@box
+\yquant at langhelper@setup at attrs{box}{value}{}
+\def\yquant at lang@@box{%
+   \yquant at register@get at allowmultitrue%
+   \expandafter\yquant at draw%
+      \expandafter{\yquant at lang@attr at value}
+      {/yquant/operators/every box}%
+}
+
+% Hadamard
+\yquant at langhelper@declare at command{h}\yquant at lang@@h
+\yquant at langhelper@setup at attrs{h}{}{}
+\def\yquant at lang@@h{%
+   \yquant at draw%
+      {$H$}%
+      {/yquant/operators/every h}%
+}
+
+% Pauli X (or NOT)
+\yquant at langhelper@declare at command{x}\yquant at lang@@x
+\yquant at langhelper@setup at attrs{x}{}{}
+\def\yquant at lang@@x{%
+   \yquant at draw%
+      {$X$}%
+      {/yquant/operators/every x}%
+}
+
+% Pauli Y
+\yquant at langhelper@declare at command{y}\yquant at lang@@y
+\yquant at langhelper@setup at attrs{y}{}{}
+\def\yquant at lang@@y{%
+   \yquant at draw%
+      {$Y$}%
+      {/yquant/operators/every y}%
+}
+
+% Pauli Z
+\yquant at langhelper@declare at command{z}\yquant at lang@@z
+\yquant at langhelper@setup at attrs{z}{}{}
+\def\yquant at lang@@z{%
+   \yquant at draw%
+      {$Z$}%
+      {/yquant/operators/every z}%
+}
+
+% sub-circuit: This is a nested circuit.
+%\yquant at langhelper@declare at command{subcircuit}\yquant at lang@@subcircuit
+%\yquant at langhelper@setup at attrs{subcircuit}{}{shift}
+%\protected\def\yquant at lang@@subcircuit#1#2#3{%
+%   % First we restore access to the yquant environment (which was a shorthand to
+%   % re-starting the parser within the environment, conveniently forbidding nesting).
+%   \let\yquant=\yquant at envunstar%
+%   \cslet{yquant*}\yquant at envstar%
+%   % Then determine the actual subcircuit content.
+%   \yquant at circuit@subcircuit\yquant at lang@attr at value%
+%   % Now the subcircuit is stored in \yquant at circuit@subcircuit at box. However, note that
+%   % it may contain named nodes (whose names are stored in
+%   % \csname\yquant at prefix circuit at subcircuit@nodelist\endcsname) that need to be shifted
+%   % whenever we actually position the subcircuit.
+%%   \let\yquant at draw@callback at box=\yquant at circuit@subcircuit at shiftnodes%
+%   \yquant at register@get at allowmultitrue%
+%   \yquant at draw%
+%      {\copy\yquant at circuit@subcircuit at box}%
+%      {/yquant/operators/every subcircuit}
+%      {#1}{#2}{#3}%
+%   \global\setbox\yquant at circuit@subcircuit at box=\box\voidb at x% memory management
+%}
+% END_FOLD
+
+% BEGIN_FOLD other geometric shapes
+% phase
+\yquant at langhelper@declare at command{phase}\yquant at lang@@phase
+\yquant at langhelper@setup at attrs{phase}{value}{}%
+\def\yquant at lang@@phase{%
+   \edef\cmd{%
+      \noexpand\yquant at draw%
+         {}%
+         {/yquant/operators/every phase, label={\unexpanded\expandafter{\yquant at lang@attr at value}}}%
+   }%
+   \cmd%
+}
+
+% two-qubit controlled x (symmetric notation)
+\yquant at langhelper@declare at command{xx}\yquant at lang@@xx
+\yquant at langhelper@setup at attrs{xx}{}{}
+\def\yquant at lang@@xx#1#2#3{%
+   \yquant at register@get at allowmultitrue%
+   \yquant at circuit@operator{#1}{#2}{#3}%
+   \ifyquant at circuit@operator at hasControls%
+      \yquant at draw@{}{/yquant/operators/every xx, /yquant/operator/multi operator line=false}%
+   \else%
+      \yquant at draw@{}{/yquant/operators/every xx}%
+   \fi%
+}
+
+% two-qubit controlled phase (symmetric notation)
+\yquant at langhelper@declare at command@uncontrolled{zz}\yquant at lang@@zz
+\yquant at langhelper@setup at attrs{zz}{}{}
+\def\yquant at lang@@zz{%
+   \yquant at register@get at allowmultitrue%
+   \yquant at draw%
+      {}%
+      {/yquant/operators/every zz}%
+      {}{}%
+}
+
+% slash (pseudo-operator, alternative indication for a bundle)
+\yquant at langhelper@declare at command@uncontrolled{slash}\yquant at lang@@slash
+\yquant at langhelper@setup at attrs{slash}{}{}
+\protected\def\yquant at lang@@slash#1{%
+   % temporarily squeeze most into the separation
+   \pgfkeys{%
+      /yquant/operator/minimum width=0pt,
+      /yquant/operator/separation=.5\dimexpr\yquant at config@operator at sep-\pgflinewidth\relax
+   }%
+   \def\yquant at draw@callback at wire##1{%
+      \yquant at register@set at x%
+         {##1}%
+         {\the\dimexpr\yquant at register@get at x{##1}-\yquant at config@operator at sep-\pgflinewidth\relax}%
+   }
+   \yquant at draw%
+      {}%
+      {/yquant/operators/every slash}%
+      {}{}{#1}%
+}
+
+% swap
+\yquant at langhelper@declare at command{swap}\yquant at lang@@swap
+\yquant at langhelper@setup at attrs{swap}{}{}
+\def\yquant at lang@@swap#1#2#3{%
+   \yquant at register@get at allowmultitrue%
+   \yquant at circuit@operator{#1}{#2}{#3}%
+   \ifyquant at circuit@operator at hasControls%
+      \yquant at draw@{}{/yquant/operators/every swap, /yquant/operator/multi operator line=false}%
+   \else%
+      \yquant at draw@{}{/yquant/operators/every swap}%
+   \fi%
+}
+
+% not
+\yquant at langhelper@declare at command{not}\yquant at lang@@not
+\yquant at langhelper@setup at attrs{not}{}{}
+\def\yquant at lang@@not{%
+   \yquant at draw%
+      {}%
+      {/yquant/operators/every not}%
+}
+% alias to cnot
+\let\yquant at lang@cnot=\yquant at lang@not
+\yquant at langhelper@setup at attrs{cnot}{}{}
+
+% measure
+\yquant at langhelper@declare at command@uncontrolled{measure}\yquant at lang@@measure
+\yquant at langhelper@setup at attrs{measure}{}{value,type}
+\def\yquant at lang@@measure{%
+   \ifdefined\yquant at lang@attr at type%
+      \expandafter\ifstrequal\expandafter{\yquant at lang@attr at type}{qubit}%
+         {\let\yquant at circuit@settype at to=\yquant at register@type at q}%
+         {%
+            \expandafter\ifstrequal\expandafter{\yquant at lang@attr at type}{cbit}%
+            {\let\yquant at circuit@settype at to=\yquant at register@type at c}%
+            {%
+               \expandafter\ifstrequal\expandafter{\yquant at lang@attr at type}{qubits}%
+               {\let\yquant at circuit@settype at to=\yquant at register@type at qs}%
+               {%
+                  \PackageError{yquant.sty}{Invalid bit type: `\yquant at lang@attr at type}%
+                     {Use one of `qubit', `cbit', or `qubits'.}%
+               }%
+            }%
+         }%
+   \else%
+      \let\yquant at circuit@settype at to=\yquant at register@type at c%
+   \fi%
+   \let\yquant at draw@callback at wire=\yquant at circuit@settype%
+   \yquant at register@get at allowmultitrue%
+   \unless\ifcsname yquant at lang@attr at value\endcsname%
+      \let\yquant at lang@attr at value=\empty%
+   \fi%
+   \expandafter\yquant at draw%
+      \expandafter{\yquant at lang@attr at value}%
+      {/yquant/operators/every measure}%
+      {}{}%
+}
+
+% measure (dmeter)
+\yquant at langhelper@declare at command@uncontrolled{dmeter}\yquant at lang@@dmeter
+\yquant at langhelper@setup at attrs{dmeter}{}{value,type}
+\def\yquant at lang@@dmeter{%
+   \ifdefined\yquant at lang@attr at type%
+      \expandafter\ifstrequal\expandafter{\yquant at lang@attr at type}{qubit}%
+         {\let\yquant at circuit@settype at to=\yquant at register@type at q}%
+         {%
+            \expandafter\ifstrequal\expandafter{\yquant at lang@attr at type}{cbit}%
+            {\let\yquant at circuit@settype at to=\yquant at register@type at c}%
+            {%
+               \expandafter\ifstrequal\expandafter{\yquant at lang@attr at type}{qubits}%
+               {\let\yquant at circuit@settype at to=\yquant at register@type at qs}%
+               {%
+                  \PackageError{yquant.sty}{Invalid bit type: `\yquant at lang@attr at type}%
+                     {Use one of `qubit', `cbit', or `qubits'.}%
+               }%
+            }%
+         }%
+   \else%
+      \let\yquant at circuit@settype at to=\yquant at register@type at c%
+   \fi%
+   \let\yquant at draw@callback at wire=\yquant at circuit@settype%
+   \yquant at register@get at allowmultitrue%
+   \unless\ifcsname yquant at lang@attr at value\endcsname%
+      \let\yquant at lang@attr at value=\empty%
+   \fi%
+   \expandafter\yquant at draw%
+      \expandafter{\yquant at lang@attr at value}%
+      {/yquant/operators/every dmeter}%
+      {}{}%
+}
+% END_FOLD
+
+% BEGIN_FOLD miscellaneous
+\yquant at langhelper@declare at command@uncontrolled{barrier}\yquant at lang@@barrier
+\yquant at langhelper@setup at attrs{barrier}{}{}
+\def\yquant at lang@@barrier{%
+   \yquant at register@get at allowmultitrue%
+   \yquant at draw%
+      {}%
+      {/yquant/operators/every barrier}%
+      {}{}
+}
+
+\yquant at langhelper@declare at command@uncontrolled{align}\yquant at lang@@align
+\yquant at langhelper@setup at attrs{align}{}{}
+\def\yquant at lang@@align#1{%
+   \yquant at register@get at ids{#1}%
+   \yquant at circuit@align\yquant at register@get at ids@list%
+}
+
+\yquant at langhelper@declare at command@uncontrolled{hspace}\yquant at lang@@hspace
+\yquant at langhelper@setup at attrs{hspace}{value}{}
+\def\yquant at lang@@hspace#1{%
+   \yquant at langhelper@validate\amount\dimen\yquant at lang@attr at value%
+   \yquant at register@get at ids{#1}%
+   \yquant at circuit@hspace\yquant at register@get at ids@list\amount%
+}
+
+\yquant at langhelper@declare at command@uncontrolled{discard}\yquant at lang@@discard
+\yquant at langhelper@setup at attrs{discard}{}{}
+\def\yquant at lang@@discard#1{%
+   \yquant at register@get at ids{#1}%
+   \yquant at circuit@settypes\yquant at register@get at ids@list\yquant at register@type at none%
+}
+
+\yquant at langhelper@declare at command@uncontrolled{init}\yquant at lang@@init
+\yquant at langhelper@setup at attrs{init}{value}{type}
+\def\yquant at lang@@init at multi@@extract#1#2#3#4#5{%
+   #5%
+}
+\protected\def\yquant at lang@@init#1{%
+   \yquant at register@get at allowmultitrue%
+   \yquant at register@get at ids{#1}%
+   \ifdefined\yquant at lang@attr at type%
+      \expandafter\ifstrequal\expandafter{\yquant at lang@attr at type}{qubit}%
+         {\let\yquant at circuit@settype at to=\yquant at register@type at q}%
+         {%
+            \expandafter\ifstrequal\expandafter{\yquant at lang@attr at type}{cbit}%
+            {\let\yquant at circuit@settype at to=\yquant at register@type at c}%
+            {%
+               \expandafter\ifstrequal\expandafter{\yquant at lang@attr at type}{qubits}%
+               {\let\yquant at circuit@settype at to=\yquant at register@type at qs}%
+               {%
+                  \PackageError{yquant.sty}{Invalid bit type: `\yquant at lang@attr at type}%
+                     {Use one of `qubit', `cbit', or `qubits'.}%
+               }%
+            }%
+         }%
+   \else%
+      % We don't know which type is desired. Scan all target registers and use the first wire that is available as a type.
+      \let\yquant at circuit@settype at to=\yquant at register@type at none%
+      \def\do##1{%
+         \ifyquant at firsttoken\yquant at register@multi{##1}{%
+            \def\@do####1{%
+               \edef\yquant at circuit@settype at to{\yquant at register@get at type{####1}}%
+               \unless\ifx\yquant at circuit@settype at to\yquant at register@type at none%
+                  \expandafter\listbreak%
+               \fi%
+            }%
+            \forlistloop\@do{\yquant at lang@@init at multi@@extract##1}%
+         }{%
+            \edef\yquant at circuit@settype at to{\yquant at register@get at type{##1}}%
+         }%
+         \unless\ifx\yquant at circuit@settype at to\yquant at register@type at none%
+            \expandafter\listbreak%
+         \fi%
+      }%
+      \dolistloop\yquant at register@get at ids@list%
+      \ifx\yquant at circuit@settype at to\yquant at register@type at none%
+         % now we don't have a clue; assume it's a qubit
+         \let\yquant at circuit@settype at to=\yquant at register@type at q%
+      \fi%
+      \ifx\yquant at circuit@settype at to\yquant at register@type at q%
+         \def\yquant at lang@attr at type{qubit}%
+      \else%
+         \ifx\yquant at circuit@settype at to\yquant at register@type at c%
+            \def\yquant at lang@attr at type{cbit}%
+         \else%
+            \def\yquant at lang@attr at type{qubits}%
+         \fi%
+      \fi%
+   \fi%
+   \let\yquant at draw@callback at wire=\yquant at circuit@settype%
+   \let\yquant at draw@@multi=\yquant at draw@@multiinit%
+   \yquant at circuit@operator{}{}{#1}%
+   % special case: if there were no operations at any affected wire before, we will replace the wire description
+   \ifdim\yquant at circuit@operator at x=\yquant at config@operator at sep\relax%
+      \def\yquant at circuit@operator at x{-.5\dimen2}%
+      \expandafter\yquant at draw@%
+         \expandafter{\yquant at lang@attr at value}%
+         {/yquant/every label, /yquant/every initial label, /yquant/every \yquant at lang@attr at type\space label}%
+   \else%
+      \expandafter\yquant at draw@%
+         \expandafter{\yquant at lang@attr at value}%
+         {/yquant/every label, /yquant/every \yquant at lang@attr at type\space label}%
+   \fi%
+}
+
+\yquant at langhelper@declare at command@uncontrolled{output}\yquant at lang@@output
+\yquant at langhelper@setup at attrs{output}{value}{}
+\def\yquant at lang@@output#1{%
+   \yquant at register@get at allowmultitrue%
+   \yquant at register@get at ids{#1}%
+   \expandafter\yquant at circuit@output\expandafter{\yquant at register@get at ids@list}%
+}
+
+\yquant at langhelper@declare at command@uncontrolled{setwire}\yquant at lang@@setwire
+\yquant at langhelper@setup at attrs{setwire}{value}{}
+\protected\def\yquant at lang@@setwire#1{%
+   \yquant at register@get at ids{#1}%
+   \expandafter\ifstrequal\expandafter{\yquant at lang@attr at value}{qubit}%
+      {\let\yquant at circuit@settype at to=\yquant at register@type at q}%
+      {%
+         \expandafter\ifstrequal\expandafter{\yquant at lang@attr at value}{cbit}%
+         {\let\yquant at circuit@settype at to=\yquant at register@type at c}%
+         {%
+            \expandafter\ifstrequal\expandafter{\yquant at lang@attr at value}{qubits}%
+            {\let\yquant at circuit@settype at to=\yquant at register@type at qs}%
+            {%
+               \PackageError{yquant.sty}{Invalid bit type: `\yquant at lang@attr at value}%
+                  {Use one of `qubit', `cbit', or `qubits'.}%
+            }%
+         }%
+      }%
+   \yquant at circuit@settypes\yquant at register@get at ids@list\yquant at circuit@settype at to%
+}
+% END_FOLD
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/latex/yquant/yquant-lang.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/yquant/yquant-langhelper.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-langhelper.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-langhelper.tex	2020-03-24 20:57:29 UTC (rev 54527)
@@ -0,0 +1,315 @@
+% Parsing attributes
+\let\yquant at langhelper@list at attrs=\empty
+
+\protected\long\def\yquant at langhelper@check at attrs[#1]{%
+   \appto\yquant at langhelper@list at attrs{#1,}%
+   \yquant at env@contscan%
+}
+
+% shorthands for declaring attributes
+\protected\def\yquant at langhelper@declare at attr{%
+   \pgfqkeys{/yquant/all attrs}%
+}
+
+\protected\def\yquant at langhelper@declare at attr@global{%
+   \pgfqkeys{/yquant/global attrs}%
+}
+
+\pgfkeys{%
+   /yquant/attr filter handler/.code={%
+      \let\yquant at langhelper@filter@@name=\pgfkeyscurrentkeyRAW%
+      \let\yquant at langhelper@filter@@value=\pgfkeyscurrentvalue%
+      % the key was filtered out, i.e., it is neither a local nor a global attribute.
+      \pgfkeysinterruptkeyfilter%
+         % execute it in /yquant, if it exists there
+         \pgfqkeys{/yquant}{\yquant at langhelper@filter@@name/.try/.expand once=\yquant at langhelper@filter@@value}%
+         \ifpgfkeyssuccess%
+            \eappto#1{%
+               ,/yquant/\unexpanded\expandafter{\yquant at langhelper@filter@@name}%
+                  \unless\ifx\yquant at langhelper@filter@@value\pgfkeysnovalue at text%
+                     ={\unexpanded\expandafter{\yquant at langhelper@filter@@value}}%
+                  \fi%
+            }%
+         \else%
+            \pgfkeys{/yquant/operator style/.expanded=%
+               {\unexpanded\expandafter{\yquant at langhelper@filter@@name}=%
+                  {\unexpanded\expandafter{\yquant at langhelper@filter@@value}}%
+               }%
+            }%
+            \eappto#1{%
+               ,/yquant/operator style={\unexpanded\expandafter{\yquant at langhelper@filter@@name}%
+                  \unless\ifx\yquant at langhelper@filter@@value\pgfkeysnovalue at text%
+                     ={\unexpanded\expandafter{\yquant at langhelper@filter@@value}}%
+                  \fi%
+               }%
+            }%
+         \fi%
+      \endpgfkeysinterruptkeyfilter%
+   },
+   /pgf/key filters/attr filter/.code={%
+      % we need to capture every non-attribute (which means filtering them out).
+      \expandafter\ifyquant at beginswith\expandafter{\pgfkeyscurrentkey}{/yquant/attrs/}{%
+         % the key is in /yquant/attrs. Does it actually exist (but not as a handler, which would define non-existing keys)?
+         \if\pgfkeyscasenumber1%
+            \pgfkeysfiltercontinuetrue%
+         \else%
+            \if\pgfkeyscasenumber2%
+               \pgfkeysfiltercontinuetrue%
+            \else%
+               % 0 or 3 for our case means non-existing - now we need to check whether we can find it in the global attributes.
+               \pgfkeysifassignable{/yquant/global attrs/\pgfkeyscurrentkeyRAW}{%
+                  \pgfkeysfiltercontinuetrue%
+               }{%
+                  % it is not, so it is not a known attribute for this operator. Filter.
+                  \pgfkeysfiltercontinuefalse%
+               }%
+            \fi%
+         \fi%
+      }{%
+         % the key is not in /yquant/attrs. Is it a global attribute (usually, the user should not access this explicitly, but let's be tolerant here)?
+         \expandafter\ifyquant at beginswith\expandafter{\pgfkeyscurrentkey}{/yquant/global attrs/}{%
+            % the key is in /yquant/global attrs. Does it actually exist?
+            \if\pgfkeyscasenumber1%
+               \pgfkeysfiltercontinuetrue%
+            \else%
+               \if\pgfkeyscasenumber2%
+                  \pgfkeysfiltercontinuetrue%
+               \else%
+                  % no - that's it.
+                  \pgfkeysfiltercontinuefalse%
+               \fi%
+            \fi%
+         }{%
+            % the key is no known attribute
+            \pgfkeysfiltercontinuefalse%
+         }%
+      }%
+   },
+   /yquant/attr filter/.style={
+      /pgf/key filters/attr filter/.install key filter,
+      /yquant/attr filter handler/.install key filter handler=\yquant at attrs@remaining%
+   }%
+}
+
+% specifies which attributes can be used for a given command
+% #1: command name
+% #2: comma-separated list of required attrs
+% #3: comma-separated list of optional attrs
+\protected\def\yquant at langhelper@setup at attrs#1#2#3{%
+   \begingroup%
+      \lowercase{\edef\cmd{#1}}%
+      \edef\keyscmd{%
+         \noexpand\pgfkeyslet{/yquant/attrs/\cmd/.unknown/. at cmd}%
+                             \yquant at langhelper@setup at attrs@unknown%
+      }%
+      \let\keysset=\relax%
+      \let\keyscheck=\relax%
+      \def\do##1{%
+         \eappto\keyscmd{%
+            \noexpand\pgfkeysdef{/yquant/attrs/\cmd/##1}{%
+               \unexpanded{%
+                  \cslet{yquant at langhelper@attrs at req@##1}\relax%
+                  \pgfkeysinterruptkeyfilter%
+                     \pgfkeys{/yquant/all attrs/##1={####1}}%
+                  \endpgfkeysinterruptkeyfilter%
+               }
+            }%
+         }%
+         \eappto\keysset{%
+            \def\expandafter\noexpand\csname yquant at langhelper@attrs at req@##1\endcsname{%
+               \yquant at langhelper@setup at attrs@missing{##1}%
+            }%
+         }%
+         \expandafter\appto\expandafter\keyscheck%
+            \csname yquant at langhelper@attrs at req@##1\endcsname%
+      }%
+      \docsvlist{#2}%
+      \global\cslet{yquant at langhelper@setup at attrs@set@\cmd}\keysset%
+      \global\cslet{yquant at langhelper@setup at attrs@check@\cmd}\keyscheck%
+      \def\do##1{%
+         \eappto\keyscmd{%
+            \noexpand\pgfkeysdef{/yquant/attrs/\cmd/##1}{%
+               \unexpanded{%
+                  \pgfkeysinterruptkeyfilter%
+                     \pgfkeys{/yquant/all attrs/##1={####1}}%
+                  \endpgfkeysinterruptkeyfilter%
+               }%
+            }%
+         }%
+      }%
+      \docsvlist{#3}%
+      \expandafter%
+   \endgroup%
+   \keyscmd%
+}
+
+\protected\def\yquant at langhelper@setup at attrs@unknown#1\pgfeov{%
+   % This is in its essence /.search also={/yquant/global attrs}, but with filtering interrupted
+   \pgfkeysinterruptkeyfilter%
+      \ifpgfkeysaddeddefaultpath%
+         % only process keys for which no full path has been provided:
+         \pgfkeyssuccessfalse%
+         \let\pgfkeys at searchalso@name=\pgfkeyscurrentkeyRAW%
+         % We interrupt the filtering process because we only want to append the very top-level command to the remaining-macro.
+         \unless\ifpgfkeyssuccess%
+            \pgfqkeys{/yquant/global attrs}%
+                     {\pgfkeys at searchalso@name={#1}}%
+         \fi%
+      \else%
+         % the /.search also implementation defines this in an unexpanded macro, which is then executed. Any reason?
+         \pgfkeysvalueof{/handlers/.unknown/. at cmd}#1\pgfeov%
+      \fi%
+   \endpgfkeysinterruptkeyfilter%
+}
+
+\protected\def\yquant at langhelper@setup at attrs@missing#1{%
+   \PackageError{yquant.sty}{Required attribute `#1' missing}%
+      {You used a command that requires specifying the attribute `#1'.}%
+}%
+
+% Parsing command itself
+\protected\def\yquant at langhelper@check at name#1 {%
+   \lowercase{\edef\cmd{#1}}%
+   \unless\ifcsname yquant at lang@\cmd\endcsname%
+      \PackageError{yquant.sty}{Unsupported yquant command: `#1'}%
+         {You used a command that is unknown to yquant.}%
+   \fi%
+   % Provide the association with the correct attributes
+   \csname yquant at langhelper@setup at attrs@set@\cmd\endcsname%
+   % For "ordinary" uses of the quotes library (without additional options), it would be better not to load the library now, since then the original text (everything in quotes) is just appended to /yquant/operator style. However, then uses with options will break the pgfkeys parser, as they are invalid. For this reason, we must enable the quotes library already at this state, with the consequence that we store the longer version, i.e., the output of the quotes-parsed expression instead.
+   \tikz at enable@node at quotes%
+   % execute them
+   \let\yquant at attrs@remaining=\empty%
+   \unless\ifx\yquant at langhelper@list at attrs\empty%
+      \edef\yquant at langhelper@list at attrs{%
+         \noexpand\pgfqkeysfiltered%
+            {/yquant/attrs/\cmd}%
+            {\unexpanded\expandafter{\yquant at langhelper@list at attrs}}%
+      }%
+      \pgfkeys{/yquant/attr filter}%
+      \yquant at langhelper@list at attrs%
+      \let\yquant at langhelper@list at attrs=\empty% required for nested environments
+   \fi%
+   % If there was an argument, set it
+   \@ifnextchar\bgroup%
+      \yquant at langhelper@check at name@i%
+      \yquant at langhelper@check at name@ii%
+}
+
+\protected\long\def\yquant at langhelper@check at name@i#1{%
+   \ifdefined\yquant at lang@attr at value%
+      \PackageWarning{yquant.sty}{Node content given explicitly and as an attribute. Using the explicit value.}%
+   \fi%
+   \def\yquant at lang@attr at value{#1}%
+   \let\yquant at langhelper@attrs at req@value=\relax%
+   \yquant at langhelper@check at name@ii%
+}
+
+\protected\def\yquant at langhelper@check at name@ii{%
+   % Check all necessary attributes were given.
+   \csname yquant at langhelper@setup at attrs@check@\cmd\endcsname%
+   % Finally execute the command
+   \csname yquant at lang@\cmd\endcsname%
+}
+
+% Defining commands that accept registers and take an optional value
+% #1: name of the argument
+% #2: command that is to be called with three parameters: the indices of the positive and negative controls and registers, all as named lists
+\protected\def\yquant at langhelper@declare at command#1#2{%
+   \begingroup%
+      \lowercase{\edef\cmd{#1}}%
+      \long\protected\csgdef{yquant at lang@\cmd}{%
+         \let\cmd=#2%
+         \yquant at langhelper@declare at command@@parse%
+      }%
+   \endgroup%
+}
+
+% Defining commands that accept registers and take an additional value
+% #1: name of the argument
+% #2: command that is to be called with three parameters: the indices of the positive and negative controls and registers, all as named lists
+\protected\def\yquant at langhelper@declare at command@uncontrolled#1#2{%
+   \begingroup%
+      \lowercase{\edef\cmd{#1}}%
+      \long\protected\csgdef{yquant at lang@\cmd}{%
+         \def\cmd{\yquant at langhelper@declare at command@@uncontrolled{#2}}%
+         \yquant at langhelper@declare at command@@parse%
+      }%
+   \endgroup%
+}
+
+\long\def\yquant at langhelper@declare at command@@parse#1;{%
+   \yquant at langhelper@declare at command@@extract at nctrl#1~;%
+   \yquant at env@rescan%
+}
+
+\def\yquant at langhelper@declare at command@@extract at nctrl#1~#2;{%
+   \if\relax\detokenize{#2}\relax%
+      \yquant at langhelper@declare at command@@extract at pctrl#1|~~;%
+   \else%
+      \yquant at langhelper@declare at command@@extract at pctrl#1|~#2;%
+   \fi%
+}
+
+\def\yquant at langhelper@declare at command@@extract at pctrl#1|#2~#3~;{%
+   \if\relax\detokenize{#2}\relax%
+      \yquant at langhelper@declare at command@@exec#1||~#3;%
+   \else%
+      \yquant at langhelper@declare at command@@exec#1|#2~#3;%
+   \fi%
+}
+
+\protected\def\yquant at langhelper@declare at command@@exec#1|#2|~#3;{%
+   \edef\params{%
+      {\trim at spaces{#2}}%
+      {\trim at spaces{#3}}%
+      {\trim at spaces{#1}}%
+   }%
+   \expandafter\cmd\params%
+}
+
+\protected\def\yquant at langhelper@declare at command@@uncontrolled#1#2#3{%
+   \ifstrempty{#2}\relax{%
+      \PackageError{yquant.sty}{Positive controls are not allowed for this command}{}%
+   }%
+   \ifstrempty{#3}\relax{%
+      \PackageError{yquant.sty}{Negative controls are not allowed for this command}{}%
+   }%
+   #1%
+}
+
+% shorthands for validation of property values
+% #1: a macro that will contain the sanitized value
+% #2: a TeX register type: most likely \count, \dimen
+% #3: a string to be checked
+% This macro is not expandable.
+\protected\def\yquant at langhelper@validate#1#2#3{%
+   \begingroup%
+      \afterassignment\yquant at langhelper@validate at i%
+      #2 255=#3\relax\yquant at end%
+      \unless\ifvalid%
+         \PackageError{yquant.sty}{Invalid property value: `#3'}%
+            {The value must be assignable to a \protect#2 register.}%
+      \fi%
+      \expandafter%
+   \endgroup%
+   \expandafter\def\expandafter#1\expandafter{\the#2 255}%
+}
+
+\def\yquant at langhelper@validate at relax{\relax}
+\protected\def\yquant at langhelper@validate at i#1\relax#2\yquant at end{%
+   % if the valid value was not user-delimited by \relax, #1 and #2 are empty
+   % if the valid value was user-delimited by \relax, #1 is empty and #2 is \relax
+   \let\ifvalid=\iffalse%
+   \if\relax\detokenize{#1}\relax%
+      \def\tmp{#2}%
+      \ifx\empty\tmp%
+         \csletcs{ifvalid}{iftrue}%
+      \else%
+         \ifx\yquant at langhelper@validate at relax\tmp%
+            \csletcs{ifvalid}{iftrue}%
+         \fi%
+      \fi%
+   \fi%
+   % eat the rest (which should be empty anyway)
+}
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/latex/yquant/yquant-langhelper.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/yquant/yquant-registers.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-registers.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-registers.tex	2020-03-24 20:57:29 UTC (rev 54527)
@@ -0,0 +1,532 @@
+\def\yquant at register@type at none{0}
+\def\yquant at register@type at q{1}
+\def\yquant at register@type at c{2}
+\def\yquant at register@type at qs{3}
+
+% Internally, we store the register information in a single macro. Indeed, this is almost always faster than using multiple macros (at least in the way implemented here), apart from changing a single type of information, which is almost as fast.
+% BEGIN_FOLD Constructor: create single register and cleanup environment
+
+% #1: type
+% #2: x position
+% #3: name
+% #4: index
+\protected\def\yquant at register@define#1#2#3#4{%
+   \csnumgdef{\yquant at prefix registers}%
+             {\csname\yquant at prefix registers\endcsname+1}%
+   \csxdef{\yquant at prefix register@\csname\yquant at prefix registers\endcsname}{%
+      {#1}% type
+      {#2}% x pos
+      {\yquant at config@register at minimum@height}% height; at the end, the y position
+      {}% wire start positions
+   }%
+   \global\csletcs{\yquant at prefix registername@#3[#4]}{\yquant at prefix registers}%
+   \csxdef{\yquant at prefix registerhigh@\reg}{#4}%
+   \yquant at cleanup@csadd{\yquant at prefix register@\csname\yquant at prefix registers\endcsname}%
+   \yquant at cleanup@csadd{\yquant at prefix registername@#3[#4]}%
+   \ifnum0=#4\relax%
+      \yquant at cleanup@csadd{\yquant at prefix registerhigh@\reg}%
+   \fi%
+}
+% END_FOLD
+
+% BEGIN_FOLD Converter: convert a register name to its id
+% store the number corresponding to register #2 into #1
+\protected\def\yquant at register@get at id#1#2{%
+   \ifcsname\yquant at prefix registername@#2\endcsname%
+      \letcs#1{\yquant at prefix registername@#2}%
+   \else%
+      \yquant at register@get at id@lazycreate{#2}%
+      \letcs#1{\yquant at prefix registers}%
+   \fi%
+}
+
+% same as before, but resolves to the _index_ of the last register
+\protected\def\yquant at register@get at id@high#1#2{%
+   \ifcsname\yquant at prefix registerhigh@#2\endcsname%
+      \letcs#1{\yquant at prefix registerhigh@#2}%
+   \else%
+      \yquant at register@get at id@lazycreate{#2}%
+      \letcs#1{\yquant at prefix registers}%
+   \fi%
+}
+
+% In the lazy mode, we create all unknown registers on-the-fly.
+\def\yquant at register@get at id@lazycreate#1{%
+   \ifyquant at env@lazy%
+      % In principle, we could just call \yquant at lang@@qubit. However, if access to a vector register is desired and a _part_ of this does already exist (though not the requested index), we only create the missing registers.
+      \yquant at register@get at id@lazycreate at parse#1[;
+   \else%
+      \PackageError{yquant.sty}{Register `#1' unknown}%
+         {You referred to an unknown register.
+          Declare registers first using `qubit' and friends.}%
+   \fi%
+}
+
+\def\yquant at register@get at id@lazycreate at parse#1[#2;{%
+   \if\relax\detokenize{#2}\relax%
+      \yquant at register@get at id@lazycreate at do#1[0][;%
+   \else%
+      \yquant at register@get at id@lazycreate at do#1[#2;%
+   \fi%
+}
+
+\protected\def\yquant at register@get at id@lazycreate at do#1[#2]#3[;{%
+   % parse length
+   \if\relax\detokenize{#3}\relax%
+      \yquant at langhelper@validate\len\count{#2}%
+      \numdef\len{\len+1}%
+   \else%
+      \PackageError{yquant.sty}{Invalid register name}%
+         {Register names must not contain `[' apart from register length indication.}%
+   \fi%
+   \edef\reg{\trim at spaces{#1}}%
+   % Was this register already defined?
+   \ifcsname\yquant at prefix registerhigh@\reg\endcsname%
+      \numdef\idx{\csname\yquant at prefix registerhigh@\reg\endcsname+1}%
+      \unless\ifnum\idx<\len\relax%
+         \PackageError{yquant.sty}{Internal inconsistency detected}%
+            {Tried to create a register on-the-fly that already existed.}%
+      \fi%
+   \else%
+      \def\idx{0}%
+   \fi%
+   \begingroup%
+      % pre-set y position
+      \yquant at for \idx := \idx to \numexpr \len -1\relax {%
+         \yquant at register@define%
+            \yquant at register@type at q%
+            {0pt}%
+            \reg\idx
+         % Prepare to shipout
+         \csxappto{\yquant at prefix draw}{%
+            \yquant at lang@create at draw{\csname\yquant at prefix registers\endcsname}%
+                                    {0pt}%
+                                    {qubit}%
+                                    {}%
+                                    {}%
+         }%
+      }%
+   \endgroup%
+}
+
+\newif\ifyquant at register@get at allowmulti
+% converts names to indices
+% #1: comma-separated string of names or ranges
+%     range format: startname-endname
+%     Both startname and endname may be omitted, denoting the very first and last
+%     register, respectively
+%     If \ifyquant at register@get at allowmulti is set to true, multi-qubit registers are
+%     allowed, which are surrounded by parentheses. They may not appear in ranges.
+% \yquant at register@get at ids@list, \yquant at register@get at ids@min, \yquant at register@get at ids@max and \yquant at register@get at ids@count will be set appropriately
+\begingroup%
+\catcode`[=\active%
+\catcode`(=\active%
+\protected\gdef\yquant at register@get at ids#1{%
+   \begingroup%
+      \let\yquant at register@get at ids@list=\empty%
+      \count0=2147483647 % minimal id
+      \count2=0 % maximal id
+      \count4=0 % number of total registers
+      \ifblank{#1}{}{%
+         \let\ifinmulti=\iffalse%
+         \let\do=\yquant at register@get at ids@outerlist%
+         \begingroup%
+            \catcode`[=\active%
+            \catcode`(=\active%
+            \def[##1]{\yquant at register@get at ids@@index{##1}}%
+            \def(##1){\yquant at register@get at ids@@multi{##1}}%
+            \edef\yquant at register@get at ids@retokenized{\scantokens{#1\noexpand}}%
+            \expandafter%
+         \endgroup%
+         \expandafter\docsvlist\expandafter{\yquant at register@get at ids@retokenized}%
+      }%
+      \global\let\yquant at register@get at ids@list=\yquant at register@get at ids@list%
+      \xdef\yquant at register@get at ids@min{\the\count0}%
+      \xdef\yquant at register@get at ids@max{\the\count2}%
+      \xdef\yquant at register@get at ids@count{\the\count4}%
+   \endgroup%
+}
+\endgroup
+
+\protected\def\yquant at register@get at ids@@index{}
+\protected\def\yquant at register@get at ids@@multi{}
+
+\def\yquant at register@get at ids@outerlist#1{%
+   \ifyquant at firsttoken\yquant at register@get at ids@@multi{#1}{%
+      \unless\ifyquant at register@get at allowmulti%
+         \PackageError{yquant.sty}{Multi-register gate not allowed}%
+                      {The selected gate can only be used in a single-register context.}%
+      \fi%
+      \yquant at register@get at ids@multi#1\yquant at sep%
+   }{%
+      \yquant at register@get at ids@checkrange#1-\yquant at sep%
+   }%
+}
+
+\protected\def\yquant at register@get at ids@multi\yquant at register@get at ids@@multi#1\yquant at sep{%
+   \begingroup%
+      \let\yquant at register@get at ids@list=\empty%
+      \count0=2147483647 % minimal id
+      \count2=0 % maximal id
+      \count4=0 % number of total registers
+      \let\ifinmulti=\iftrue%
+      \let\do=\yquant at register@get at ids@multilist%
+      \docsvlist{#1}%
+      \edef\process{%
+            \endgroup%
+         \noexpand\listadd\noexpand\yquant at register@get at ids@list{%
+            \noexpand\yquant at register@multi%
+               {\the\count0}{\the\count2}{\the\count4}%
+               {\yquant at register@get at ids@list}%
+         }%
+         \noexpand\ifnum\count0>\the\count0\space%
+            \count0=\the\count0\space%
+         \noexpand\fi%
+         \noexpand\ifnum\count2<\the\count2\space%
+            \count2=\the\count2\space%
+         \noexpand\fi%
+         \advance\count4 by 1 %
+      }%
+      \process%
+}
+
+\def\yquant at register@get at ids@multilist#1{%
+   \yquant at register@get at ids@checkrange#1-\yquant at sep%
+}
+
+\def\yquant at register@get at ids@checkrange#1-#2\yquant at sep{%
+   \if\relax\detokenize{#2}\relax%
+      % the string does not contain a dash
+      \yquant at register@get at ids@norange{#1}%
+   \else%
+      % this is a range argument
+      \yquant at register@get at ids@range#1-#2\yquant at sep%
+   \fi%
+}
+
+\def\yquant at register@get at ids@norange#1{%
+   % the register is not used within a range, which gives us full freedom with respect to sub-index selections
+   \yquant at register@get at ids@norange at checkindex%
+      #1%
+      \yquant at register@get at ids@@index%
+      \yquant at sep%
+}
+
+\protected\def\yquant at register@get at ids@norange at checkindex#1\yquant at register@get at ids@@index#2\yquant at sep{%
+   \edef\current{\trim at spaces{#1}}%
+   \if\relax\detokenize{#2}\relax%
+      % the string does not contain a sub-index; we add the full register
+      \yquant at register@get at id\first{\current[0]}%
+      \letcs\high{\yquant at prefix registerhigh@\current}%
+      \yquant at register@get at id\last{\current[\high]}%
+      \ifnum\first<\count0 %
+         \count0=\first\relax%
+      \fi%
+      \ifnum\last>\count2 %
+         \count2=\last\relax%
+      \fi%
+      \advance\count4 by \numexpr\high+1\relax%
+      \yquant at for \i := 0 to \high {%
+         \yquant at register@get at id\idx{\current[\i]}%
+         \listeadd\yquant at register@get at ids@list{\idx}%
+      }%
+   \else%
+      \yquant at register@get at ids@norange at index#2%
+   \fi%
+}
+
+\protected\def\yquant at register@get at ids@norange at index#1\yquant at register@get at ids@@index{%
+   \let\olddo=\do%
+   % the string contains sub-indices; since we are not in a range, multi-indices may still be allowed
+   \ifinmulti%
+      \let\do=\yquant at register@get at ids@subindex at nomulti%
+   \else%
+      \let\do=\yquant at register@get at ids@subindex at allowmulti%
+   \fi%
+   \docsvlist{#1}%
+   \let\do=\olddo%
+}
+
+\def\yquant at register@get at ids@subindex at nomulti#1{%
+   \yquant at register@get at ids@subindex at checkrange#1-\yquant at sep%
+}
+
+\def\yquant at register@get at ids@subindex at allowmulti#1{%
+   \ifyquant at firsttoken\yquant at register@get at ids@@multi{#1}{%
+      \unless\ifyquant at register@get at allowmulti%
+         \PackageError{yquant.sty}{Multi-register gate not allowed}%
+                      {The selected gate can only be used in a single-register context.}%
+      \fi%
+      \yquant at register@get at ids@subindex at multi#1\yquant at sep%
+   }{%
+      \yquant at register@get at ids@subindex at checkrange#1-\yquant at sep%
+   }%
+}
+
+\protected\def\yquant at register@get at ids@subindex at multi\yquant at register@get at ids@@multi#1\yquant at sep{%
+   \begingroup%
+      \let\yquant at register@get at ids@list=\empty%
+      \count0=2147483647 % minimal id
+      \count2=0 % maximal id
+      \count4=0 % number of total registers
+      \let\ifinmulti=\iftrue%
+      \let\do=\yquant at register@get at ids@subindex at nomulti%
+      \docsvlist{#1}%
+      \edef\process{%
+            \endgroup%
+         \noexpand\listadd\noexpand\yquant at register@get at ids@list{%
+            \noexpand\yquant at register@multi%
+               {\the\count0}{\the\count2}{\the\count4}%
+               {\yquant at register@get at ids@list}%
+         }%
+         \noexpand\ifnum\count0>\the\count0\space%
+            \count0=\the\count0\space%
+         \noexpand\fi%
+         \noexpand\ifnum\count2<\the\count2\space%
+            \count2=\the\count2\space%
+         \noexpand\fi%
+         \advance\count4 by 1 %
+      }%
+      \process%
+}
+
+\def\yquant at register@get at ids@subindex at checkrange#1-#2\yquant at sep{%
+   \if\relax\detokenize{#2}\relax%
+      % the string does not contain a dash, this is a single sub-item
+      \yquant at register@get at ids@subindex at norange{\trim at spaces{#1}}%
+   \else%
+      % this is a range argument
+      \yquant at register@get at ids@subindex at range#1-#2\yquant at sep%
+   \fi%
+}
+
+\protected\def\yquant at register@get at ids@subindex at norange#1{%
+   \yquant at register@get at id\idx{\current[#1]}%
+   \ifnum\idx<\count0 %
+      \count0=\idx\relax%
+   \fi%
+   \ifnum\idx>\count2 %
+      \count2=\idx\relax%
+   \fi%
+   \advance\count4 by 1\relax%
+   \listeadd\yquant at register@get at ids@list{\idx}%
+}
+
+\protected\def\yquant at register@get at ids@subindex at range#1-#2-\yquant at sep{%
+   \ifblank{#1}{%
+      \def\first{0}%
+   }{%
+      \yquant at langhelper@validate\first\count{#1}%
+   }%
+   \ifblank{#2}{%
+      \yquant at register@get at id@high\last\current%
+   }{%
+      \yquant at langhelper@validate\last\count{#2}%
+   }%
+   \yquant at for \i := \first to \last {%
+      \yquant at register@get at ids@subindex at norange\i%
+   }%
+}
+
+\protected\def\yquant at register@get at ids@range#1-#2-\yquant at sep{%
+   % being a range between two registers, those must be uniquely identifiable, i.e. either a single sub-indexed part of a vector register, or no vector specification at all.
+   \ifblank{#1}{%
+      \def\first{1}%
+   }{%
+      \yquant at register@get at ids@range at getfirst#1\yquant at register@get at ids@@index\yquant at sep%
+   }%
+   \ifblank{#2}{%
+      \letcs\last{\yquant at prefix registers}%
+   }{%%
+      \yquant at register@get at ids@range at getlast#2\yquant at register@get at ids@@index\yquant at sep%
+   }%
+   \ifnum\first<\last\relax%
+      \ifnum\first<\count0 %
+         \count0=\first\relax%
+      \fi%
+      \ifnum\last>\count2 %
+         \count2=\last\relax%
+      \fi%
+      \advance\count4 by \numexpr\last-\first+1\relax%
+   \else%
+      \ifnum\last<\count0 %
+         \count0=\last\relax%
+      \fi%
+      \ifnum\first>\count2 %
+         \count2=\first\relax%
+      \fi%
+      \advance\count4 by \numexpr\first-\last+1\relax%
+   \fi%
+   \yquant at for \i := \first to \last {%
+      \listeadd\yquant at register@get at ids@list{\i}%
+   }%
+}
+
+\def\yquant at register@get at ids@range at getfirst#1\yquant at register@get at ids@@index#2\yquant at sep{%
+   \if\relax\detokenize{#2}\relax%
+      \yquant at register@get at id\first{\trim at spaces{#1}[0]}%
+   \else%
+      \yquant at register@get at ids@range at get\first#1\yquant at register@get at ids@@index#2%
+   \fi%
+}
+
+\protected\def\yquant at register@get at ids@range at getlast#1\yquant at register@get at ids@@index#2\yquant at sep{%
+   \if\relax\detokenize{#2}\relax%
+      \yquant at register@get at id@high\last{\trim at spaces{#1}}%
+      \yquant at register@get at id\last{\trim at spaces{#1}[\last]}%
+   \else%
+      \yquant at register@get at ids@range at get\last#1\yquant at register@get at ids@@index#2%
+   \fi%
+}
+
+\def\yquant at register@get at ids@range at get#1#2\yquant at register@get at ids@@index#3\yquant at register@get at ids@@index{%
+   \yquant at register@get at id#1{\trim at spaces{#2}[\trim at spaces{\trim at spaces#3}]}%
+}
+
+\let\yquant at register@multi=\empty%
+% END_FOLD
+
+% BEGIN_FOLD Getters: extract the requested information from the register with given id
+\def\yquant at register@get at type#1{%
+   \expandafter\expandafter\expandafter%
+   \yquant at register@get at type@aux\csname\yquant at prefix register@#1\endcsname%
+}
+
+\def\yquant at register@get at type@aux#1#2#3#4{#1}
+
+\def\yquant at register@get at x#1{%
+   \expandafter\expandafter\expandafter%
+   \yquant at register@get at x@aux\csname\yquant at prefix register@#1\endcsname%
+}
+
+\def\yquant at register@get at x@aux#1#2#3#4{#2}
+
+\def\yquant at register@get at height#1{%
+   \expandafter\expandafter\expandafter%
+   \yquant at register@get at height@aux\csname\yquant at prefix register@#1\endcsname%
+}
+
+\def\yquant at register@get at height@aux#1#2#3#4{#3}
+
+% The y parameter get macros exist in two forms: The protected one is used during the storage to the draw macro; it should never be executed. The env environment then maps them to their proper expandable forms.
+\protected\def\yquant at register@get@@protected{%
+   \PackageError%
+      {yquant.sty}%
+      {Execution of a get-y macro in an illegal context}%
+      {get-y macros may not be called unless the yquant environment ends.}%
+}
+
+\let\yquant at register@get at y=\yquant at register@get@@protected
+\let\yquant at register@y=\yquant at register@get@@protected
+% This plays a similar role: It must never be expanded before the tikz command is invoked (because it does not exist).
+\let\nodepart=\yquant at register@get@@protected
+
+% getting the y position is the same as getting the height parameter, since we will reuse it at the end.
+\let\yquant at register@get at y@unprotected=\yquant at register@get at height
+
+% y distance between two registers.
+\def\yquant at register@get at ydist#1#2{%
+   \expandafter\yquant at abs\expandafter%
+      {\the\dimexpr\yquant at register@get at y{#2}-\yquant at register@get at y{#1}\relax}%
+}
+
+% y position of the current register
+\def\yquant at register@y at unprotected{0pt}%
+
+\protected\def\yquant at register@get at y@@expandable{%
+   \let\yquant at register@get at y=\yquant at register@get at y@unprotected%
+   \let\yquant at register@y=\yquant at register@y at unprotected%
+}
+
+\def\yquant at register@get at lastwire#1{%
+   \expandafter\expandafter\expandafter%
+   \yquant at register@get at lastwire@aux\csname\yquant at prefix register@#1\endcsname%
+}
+
+\def\yquant at register@get at lastwire@aux#1#2#3#4{#4}
+
+% Set #1 to the maximum x value found between #2 and #3
+\protected\def\yquant at register@get at maxxrange#1#2#3{%
+   \begingroup%
+      \dimen0=-16383.99999pt %
+      \yquant at for \yquant at register@get at maxx@i := #2 to #3 {%
+         \dimen2=\yquant at register@get at x{\yquant at register@get at maxx@i}\relax%
+         \ifdim\dimen0<\dimen2 %
+            \dimen0=\dimen2 %
+         \fi%
+      }%
+      \expandafter%
+   \endgroup%
+   \expandafter\def\expandafter#1\expandafter{\the\dimen0}%
+}
+
+% Set #1 to the maximum x value found in the list #2
+\protected\def\yquant at register@get at maxxlist#1#2{%
+   \begingroup%
+      \dimen0=-16383.99999pt %
+      \def\do##1{%
+         \dimen2=\yquant at register@get at x{##1}\relax%
+         \ifdim\dimen0<\dimen2 %
+            \dimen0=\dimen2 %
+         \fi%
+      }%
+      \dolistloop{#2}%
+      \expandafter%
+   \endgroup%
+   \expandafter\def\expandafter#1\expandafter{\the\dimen0}%
+}
+% END_FOLD
+
+% BEGIN_FOLD Setters: change register information
+\protected\long\def\yquant at register@set@@aux#1#2#3{%
+   \long\xdef#1{\expandafter#2#1{#3}}%
+}
+
+\protected\def\yquant at register@set at type#1{%
+   \expandafter\yquant at register@set@@aux%
+   \csname\yquant at prefix register@#1\endcsname\yquant at register@set at type@aux%
+}
+
+\long\def\yquant at register@set at type@aux#1#2#3#4#5{%
+   {#5}{#2}{#3}{#4}%
+}
+
+\protected\def\yquant at register@set at x#1{%
+   \expandafter\yquant at register@set@@aux%
+   \csname\yquant at prefix register@#1\endcsname\yquant at register@set at x@aux%
+}
+
+\long\def\yquant at register@set at x@aux#1#2#3#4#5{%
+   {#1}{#5}{#3}{#4}%
+}
+
+\protected\def\yquant at register@update at height#1#2{%
+   \ifdim#2>\yquant at register@get at height{#1} %
+      \expandafter\yquant at register@set@@aux%
+      \csname\yquant at prefix register@#1\endcsname\yquant at register@set at height@aux{#2}%
+   \fi%
+}
+
+\protected\def\yquant at register@set at y#1{%
+   \expandafter\yquant at register@set@@aux%
+   \csname\yquant at prefix register@#1\endcsname\yquant at register@set at height@aux%
+}
+
+% Set the currently used register
+\protected\def\yquant at register@use#1{%
+   \edef\yquant at register@y{\yquant at register@get at y{#1}}%
+}
+
+\long\def\yquant at register@set at height@aux#1#2#3#4#5{%
+   {#1}{#2}{#5}{#4}%
+}
+
+\protected\def\yquant at register@set at lastwire#1{%
+   \expandafter\yquant at register@set@@aux%
+   \csname\yquant at prefix register@#1\endcsname\yquant at register@set at lastwire@aux%
+}
+
+\long\def\yquant at register@set at lastwire@aux#1#2#3#4#5{%
+   {#1}{#2}{#3}{#5}%
+}
+% END_FOLD
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/latex/yquant/yquant-registers.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex	2020-03-24 20:57:29 UTC (rev 54527)
@@ -0,0 +1,614 @@
+% To draw the wires, we need to determine border angles. However, pgf's approach for this (giving the border point that lies on a line from the center to a desired probe point) is not suitable for this. Instead, we need to give a point that is projected perpendicularly onto the shape.
+\def\pgf at sh@anchorxproj#1{%
+   \csgdef{pgf at anchor@\pgf at sm@shape at name @xproj}##1{\pgf at process{##1}#1}%
+}%
+\def\pgf at sh@inheritanchorxproj[from=#1]{%
+   \global\csletcs{pgf at anchor@\pgf at sm@shape at name @xproj}{pgf at anchor@#1 at xproj}%
+}%
+\def\pgf at sh@anchoryproj#1{%
+   \csgdef{pgf at anchor@\pgf at sm@shape at name @yproj}##1{\pgf at process{##1}#1}%
+}%
+\def\pgf at sh@inheritanchoryproj[from=#1]{%
+   \global\csletcs{pgf at anchor@\pgf at sm@shape at name @yproj}{pgf at anchor@#1 at yproj}%
+}%
+\patchcmd%
+   \pgfdeclareshape%
+   {\let\anchorborder=\pgf at sh@anchorborder}%
+   {\let\anchorborder=\pgf at sh@anchorborder%
+    \let\anchorxproj=\pgf at sh@anchorxproj%
+    \let\inheritanchorxproj=\pgf at sh@inheritanchorxproj
+    \let\anchoryproj=\pgf at sh@anchoryproj%
+    \let\inheritanchoryproj=\pgf at sh@inheritanchoryproj}%
+   {}%
+   {\PackageError{yquant.sty}%
+                 {Failed to patch \string\pgfdeclareshape}%
+                 {yquant could not provide a necessary extension to pgf.}}%
+% This is mostly a copy of \pgfpointshapeborder, but we do not perform the center-anchor shift.
+\def\pgfpointshapexproj#1#2{%
+   % Ok, check whether #1 is known!
+   \ifcsname pgf at sh@ns@#1\endcsname%
+      \pgf at process{%
+         \edef\pgfreferencednodename{#1}% for use inside of anchors.
+         % MW install special macros
+         \csname pgf at sh@ma@#1\endcsname% MW
+         % install special coordinates
+         \csname pgf at sh@np@#1\endcsname%
+         \pgf at process{%
+            \pgf at process{\pgfpointtransformed{#2}}%
+            \pgfsettransform{\csname pgf at sh@nt@#1\endcsname}%
+            \pgftransforminvert%
+            \pgf at pos@transform at glob%
+            \pgf at xa=\pgf at x%
+            \pgf at ya=\pgf at y%
+            \csname pgf at anchor@\csname pgf at sh@ns@#1\endcsname @xproj\endcsname{\pgfqpoint{\pgf at xa}{\pgf at ya}}%
+            \pgfsettransform{\csname pgf at sh@nt@#1\endcsname}%
+            \pgf at pos@transform at glob%
+         }%
+         % Add inter picture transformation
+         \pgf at shape@interpictureshift{#1}%
+         % Undo current transformation
+         \pgftransforminvert%
+         \pgf at pos@transform at glob%
+      }%
+   \else%
+      \pgferror{No shape named #1 is known}%
+      \pgfpointorigin%
+   \fi%
+}%
+\def\ifpgfpointshapexproj#1{%
+   \pgfutil at ifundefined{pgf at sh@ns@#1}%
+      {\pgferror{No shape named #1 is known}}%
+      {\ifcsname pgf at anchor@\csname pgf at sh@ns@#1\endcsname @xproj\endcsname}%
+}
+\let\pgfpointshapeyproj=\pgfpointshapexproj%
+\patchcmd%
+   \pgfpointshapeyproj%
+   {xproj}{yproj}%
+   {}{\PackageError{yquant.sty}{Failed to provide \string\pgfpointshapeyproj}{}}%
+\def\ifpgfpointshapeyproj#1{%
+   \pgfutil at ifundefined{pgf at sh@ns@#1}%
+      {\pgferror{No shape named #1 is known}}%
+      {\ifcsname pgf at anchor@\csname pgf at sh@ns@#1\endcsname @yproj\endcsname}%
+}
+
+% Calculate the intersection of an ellipse centered at the origin with radii #1 and #2 with a horizontal line at position #3. Result goes to \pgf at xa, and it is the right intersection point.
+\protected\def\yquant at shape@ellipse at xfromy#1#2#3{%
+   \ifdim#3>#2\relax%
+      \global\pgf at xa=0pt %
+   \else%
+      \ifdim-\dimexpr#3\relax>#2\relax%
+         \global\pgf at xa=0pt %
+      \else%
+         \begingroup%
+            % Here, we essentially do #1*sqrt(1-(#3/#2)^2)
+            \dimen2=#2\relax%
+            \dimen3=#3\relax%
+            % if we divide by a dimension, it is internally converted to sp, so we divide by its pt-value and again by 65536. Same for multiplication. etex fuses muldiv to 64bit, so we don't get overflows.
+            % calculate the sqrt; but \pgfmathsqrt@ expects a real number without dimension suffix. It internally does \expandafter\pgfmath at x#1pt\relax, so just gobble the additional pt.
+            % TODO: is there a better way, exploiting perhaps a representation in sp?
+            \pgfmathsqrt@{\the\dimexpr1pt-\dimen3*\dimen3/\dimen2*65536/\dimen2\relax%
+                          \@gobbletwo}%
+            \global\pgf at xa=\pgfmathresult\dimexpr#1\relax%
+         \endgroup%
+      \fi%
+   \fi%
+}
+
+\pgfdeclareshape{yquant-text}{%
+   \inheritsavedanchors[from=rectangle]%
+   \foreach \anc in {center, mid, base, north, south, west, mid west, base west, north west, south west, east, mid east, base east, north east, south east} {%
+      \inheritanchor[from=rectangle]{\anc}%
+   }%
+   \global\cslet{pgf at anchor@yquant-text at circuit}\pgf at anchor@rectangle at center%
+   \inheritanchorborder[from=rectangle]%
+   \inheritbackgroundpath[from=rectangle]%
+   \anchorxproj{%
+      \pgf at xa=\pgf at x%
+      \pgf at ya=\pgf at y%
+      % The origin is at the left baseline of the text, i.e. to the left we have the inner + outer xsep, the the right there's the text + inner + outer xsep.
+      \northeast%
+      \pgf at xb=.5\pgf at x%
+      \southwest%
+      \advance \pgf at xb by .5\pgf at x%
+      \ifdim\pgf at xa>\pgf at xb%
+         % to the right
+         \northeast%
+      % else we already called \southwest
+      \fi%
+      \pgf at y=\pgf at ya%
+   }%
+   \anchoryproj{%
+      \pgf at xa=\pgf at x%
+      \pgf at ya=\pgf at y%
+      % The origin is at the left baseline of the text, i.e. to the top we have the text height + inner + outer ysep, the the bottom there's the text depth + inner + outer ysep.
+      \northeast%
+      \pgf at yb=.5\pgf at y%
+      \southwest%
+      \advance \pgf at yb by .5\pgf at y%
+      \ifdim\pgf at ya>\pgf at yb%
+         % to the top
+         \northeast%
+      % else we already called \southwest
+      \fi%
+      \pgf at x=\pgf at xa%
+   }
+}
+
+\pgfdeclareshape{yquant-rectangle}{%
+   % BEGIN_FOLD Saved anchors
+   \saveddimen\xradius{%
+      \pgfmathsetlength\pgf at x{\pgfkeysvalueof{/tikz/x radius}}%
+      \ifdim\wd\pgfnodeparttextbox=0pt %
+         \pgf at xa=0pt %
+      \else%
+         \pgfmathsetlength\pgf at xa{\pgfkeysvalueof{/pgf/inner xsep}}%
+      \fi%
+      \ifdim\dimexpr.5\wd\pgfnodeparttextbox+\pgf at xa\relax>\pgf at x%
+         \pgf at x=\dimexpr.5\wd\pgfnodeparttextbox+\pgf at xa\relax%
+      \fi%
+   }%
+   \saveddimen\yradius{%
+      \pgfmathsetlength\pgf at x{\pgfkeysvalueof{/tikz/y radius}}%
+      \ifdim\dimexpr\ht\pgfnodeparttextbox+\dp\pgfnodeparttextbox\relax=0pt %
+         \pgf at xa=0pt %
+      \else%
+         \pgfmathsetlength\pgf at xa{\pgfkeysvalueof{/pgf/inner ysep}}%
+      \fi%
+      \@tempdima=\dimexpr.5\ht\pgfnodeparttextbox+.5\dp\pgfnodeparttextbox+\pgf at xa\relax%
+      \ifdim\@tempdima>\pgf at x%
+         \pgf at x=\@tempdima%
+      \fi%
+   }%
+   \savedanchor\stext{%
+      \pgfqpoint%
+         {-.5\wd\pgfnodeparttextbox}%
+         {-\dimexpr.5\ht\pgfnodeparttextbox-.5\dp\pgfnodeparttextbox\relax}%
+   }%
+   % END_FOLD
+   % BEGIN_FOLD Operator anchors
+   \global\cslet{pgf at anchor@yquant-rectangle at center}\pgfpointorigin%
+   \anchor{text}{\stext}%
+   \anchor{north}%
+          {\pgfqpoint{0pt}%
+                     {\yradius}}%
+   \anchor{north east}%
+          {\pgfqpoint{\xradius}%
+                     {\yradius}}%
+   \anchor{east}%
+          {\pgfqpoint{\xradius}%
+                     {0pt}}%
+   \anchor{south east}%
+          {\pgfqpoint{\xradius}%
+                     {-\yradius}}%
+   \anchor{south}%
+          {\pgfqpoint{0pt}%
+                     {-\yradius}}%
+   \anchor{south west}%
+          {\pgfqpoint{-\xradius}%
+                     {-\yradius}}%
+   \anchor{west}%
+          {\pgfqpoint{-\xradius}% \dimexpr not really necessary...
+                     {0pt}}%
+   \anchor{north west}%
+          {\pgfqpoint{-\xradius}%
+                     {\yradius}}%
+   \anchorborder{%
+      \@tempdima=\pgf at x%
+      \@tempdimb=\pgf at y%
+      \pgfpointborderrectangle{\pgfqpoint{\@tempdima}{\@tempdimb}}%
+                              {\pgfqpoint{\xradius}{\yradius}}%
+   }%
+   \anchorxproj{%
+      \ifdim\pgf at x>0pt %
+         % to the right
+         \pgf at x=\xradius\relax%
+      \else%
+         % to the left
+         \pgf at x=-\xradius\relax%
+      \fi%
+   }%
+   \anchoryproj{%
+      \ifdim\pgf at y>0pt %
+         % to the top
+         \pgf at y=\yradius\relax%
+      \else%
+         % to the bottom
+         \pgf at y=-\yradius\relax%
+      \fi%
+   }%
+   % END_FOLD
+   % BEGIN_FOLD Circuit-related anchors
+   \global\csletcs{pgf at anchor@yquant-rectangle at circuit}%
+                  {pgf at anchor@yquant-rectangle at center}%
+   % END_FOLD
+   % BEGIN_FOLD Path
+   \backgroundpath{%
+      \pgfpathrectanglecorners%
+         {\pgfqpoint{-\xradius}{\yradius}}%
+         {\pgfqpoint{\xradius}{-\yradius}}%
+   }%
+   % END_FOLD
+}
+
+\pgfdeclareshape{yquant-circle}{%
+   \inheritsavedanchors[from=yquant-rectangle]%
+   \foreach \anc in {center, north, east, south, west, circuit, text} {%
+      \inheritanchor[from=yquant-rectangle]{\anc}%
+   }%
+   \anchor{north east}%
+          {\pgfqpoint{.707107\dimexpr\xradius\relax}%
+                     {.707107\dimexpr\yradius\relax}}%
+   \anchor{south east}%
+          {\pgfqpoint{.707107\dimexpr\xradius\relax}%
+                     {-.707107\dimexpr\yradius\relax}}%
+   \anchor{south west}%
+          {\pgfqpoint{-.707107\dimexpr\xradius\relax}%
+                     {-.707107\dimexpr\yradius\relax}}%
+   \anchor{north west}%
+          {\pgfqpoint{-.707107\dimexpr\xradius\relax}%
+                     {.707107\dimexpr\yradius\relax}}%
+   \anchorborder{%
+      \@tempdima=\pgf at x%
+      \@tempdimb=\pgf at y%
+      \pgfpointborderellipse{\pgfqpoint{\@tempdima}{\@tempdimb}}%
+                            {\pgfqpoint{.707107\dimexpr\xradius\relax}%
+                                       {.707107\dimexpr\yradius\relax}}%
+   }%
+   \anchorxproj{%
+      \yquant at shape@ellipse at xfromy\xradius\yradius\pgf at y%
+      \ifdim\pgf at x>0pt %
+         % to the right
+         \pgf at x=\pgf at xa%
+      \else%
+         % to the left
+         \pgf at x=-\pgf at xa%
+      \fi%
+   }%
+   \anchoryproj{%
+      \yquant at shape@ellipse at xfromy\yradius\xradius\pgf at x%
+      \ifdim\pgf at y>0pt %
+         % to the top
+         \pgf at y=\pgf at xa%
+      \else%
+         % to the bottom
+         \pgf at y=-\pgf at xa%
+      \fi%
+   }%
+   \foregroundpath{%
+      \pgfpathellipse{\pgfpointorigin}%
+                     {\pgfqpoint{\xradius}{0pt}}%
+                     {\pgfqpoint{0pt}{\yradius}}%
+   }%
+}
+
+\pgfdeclareshape{yquant-zz}{%
+   % Here, the radii have a special meaning, we don't put text into the shape
+   \saveddimen\xradius{%
+      \pgfmathsetlength\pgf at x{\pgfkeysvalueof{/tikz/x radius}}%
+   }%
+   \saveddimen\yradius{%
+      \pgfmathsetlength\pgf at x{\pgfkeysvalueof{/tikz/y radius}}%
+   }%
+   \foreach \anc in {center, north, east, south, west, circuit} {%
+      \inheritanchor[from=yquant-circle]{\anc}%
+   }%
+   \anchor{north east}%
+          {\pgfqpoint{.707107\dimexpr\xradius\relax}%
+                     {\dimexpr\yradius-.292893\dimexpr\xradius\relax\relax}}%
+   \anchor{south east}%
+          {\pgfqpoint{.707107\dimexpr\xradius\relax}%
+                     {\dimexpr-\yradius+.292893\dimexpr\xradius\relax\relax}}%
+   \anchor{south west}%
+          {\pgfqpoint{-.707107\dimexpr\xradius\relax}%
+                     {\dimexpr-\yradius+.292893\dimexpr\xradius\relax\relax}}%
+   \anchor{north west}%
+          {\pgfqpoint{-.707107\dimexpr\xradius\relax}%
+                     {\dimexpr\yradius-.292893\dimexpr\xradius\relax\relax}}%
+   % TODO: this is not really the correct border anchor
+   \inheritanchorborder[from=yquant-rectangle]%
+   \anchorxproj{%
+      \ifdim\pgf at y<0pt %
+         \pgf at ya=\dimexpr\pgf at y+\yradius-\xradius\relax%
+      \else%
+         \pgf at ya=\dimexpr\pgf at y-\yradius+\xradius\relax%
+      \fi%
+      \yquant at shape@ellipse at xfromy\xradius\xradius\pgf at ya%
+      \ifdim\pgf at x>0pt %
+         % to the right
+         \pgf at x=\pgf at xa%
+      \else%
+         % to the left
+         \pgf at x=-\pgf at xa%
+      \fi%
+   }%
+   \anchoryproj{%
+      \yquant at shape@ellipse at xfromy\xradius\xradius\pgf at xa%
+      \ifdim\pgf at y>0pt %
+         % to the top
+         \pgf at y=\dimexpr\yradius-\xradius+\pgf at xa\relax%
+      \else%
+         % to the bottom
+         \pgf at y=-\dimexpr\yradius-\xradius+\pgf at xa\relax%
+      \fi%
+   }%
+   \backgroundpath{%
+      \pgfpathmoveto{\pgfqpoint{0pt}{\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
+      \pgfpathlineto{\pgfqpoint{0pt}{-\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
+      \pgfpathcircle{\pgfqpoint{0pt}{\dimexpr\yradius-\xradius\relax}}%
+                    {\xradius}%
+      \pgfpathcircle{\pgfqpoint{0pt}{\dimexpr\xradius-\yradius\relax}}%
+                    {\xradius}%
+   }%
+}
+
+\pgfdeclareshape{yquant-xx}{%
+   \inheritsavedanchors[from=yquant-zz]%
+   \savedmacro\ifconnector{%
+      \let\ifconnector=\ifyquant at config@multi at line%
+   }%
+   \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west, circuit} {%
+      \inheritanchor[from=yquant-rectangle]{\anc}%
+   }%
+   % TODO: this is not really the correct border anchor
+   \inheritanchorborder[from=yquant-rectangle]%
+   \inheritanchorxproj[from=yquant-rectangle]%
+   \inheritanchoryproj[from=yquant-rectangle]%
+   % Draw the operator itself
+   \backgroundpath{%
+      \ifconnector%
+         \pgfpathmoveto{\pgfqpoint{0pt}{\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
+         \pgfpathlineto{\pgfqpoint{0pt}{-\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
+      \fi%
+      \pgfpathrectanglecorners%
+         {\pgfqpoint{-\xradius}{\dimexpr\yradius\relax}}%
+         {\pgfqpoint{\xradius}{\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
+      \pgfpathrectanglecorners%
+         {\pgfqpoint{-\xradius}{-\yradius}}%
+         {\pgfqpoint{\xradius}{-\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
+   }%
+}
+
+\pgfdeclareshape{yquant-slash}{%
+   \inheritsavedanchors[from=yquant-zz]%
+   \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west, circuit} {%
+      \inheritanchor[from=yquant-rectangle]{\anc}%
+   }%
+   \inheritanchorborder[from=yquant-rectangle]%
+   \backgroundpath{%
+      \pgfpathmoveto{\pgfqpoint{\xradius}{\yradius}}%
+      \pgfpathlineto{\pgfqpoint{-\xradius}{-\yradius}}%
+   }%
+}
+
+\pgfdeclareshape{yquant-swap}{%
+   \inheritsavedanchors[from=yquant-xx]%
+   \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west, circuit} {%
+      \inheritanchor[from=yquant-rectangle]{\anc}%
+   }%
+   \inheritanchorborder[from=yquant-rectangle]%
+   \inheritanchoryproj[from=yquant-rectangle]%
+   \backgroundpath{%
+      % Connector
+      \ifconnector%
+         \pgfpathmoveto{\pgfqpoint{0pt}{\dimexpr\yradius-\xradius\relax}}%
+         \pgfpathlineto{\pgfqpoint{0pt}{-\dimexpr\yradius-\xradius\relax}}%
+      \fi%
+      % Upper cross
+      \pgfpathmoveto{\pgfqpoint{-\xradius}{\yradius}}%
+      \pgfpathlineto{\pgfqpoint{\xradius}%
+                               {\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
+      \pgfpathmoveto{\pgfqpoint{\xradius}{\yradius}}%
+      \pgfpathlineto{\pgfqpoint{-\xradius}
+                               {\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
+      % Lower cross
+      \pgfpathmoveto{\pgfqpoint{-\xradius}%
+                               {-\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
+      \pgfpathlineto{\pgfqpoint{\xradius}{-\yradius}}%
+      \pgfpathmoveto{\pgfqpoint{\xradius}%
+                               {-\dimexpr\yradius-2\dimexpr\xradius\relax\relax}}%
+      \pgfpathlineto{\pgfqpoint{-\xradius}{-\yradius}}%
+   }%
+}
+
+\pgfdeclareshape{yquant-oplus}{%
+   \inheritsavedanchors[from=yquant-zz]%
+   \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west, circuit} {%
+      \inheritanchor[from=yquant-circle]{\anc}%
+   }%
+   \inheritanchorborder[from=yquant-circle]%
+   \inheritanchorxproj[from=yquant-circle]%
+   \inheritanchoryproj[from=yquant-circle]%
+   \backgroundpath{%
+      \pgfpathmoveto{\pgfqpoint{0pt}{\yradius}}%
+      \pgfpathlineto{\pgfqpoint{0pt}{-\yradius}}%
+      \pgfpathmoveto{\pgfqpoint{-\xradius}{0pt}}%
+      \pgfpathlineto{\pgfqpoint{\xradius}{0pt}}%
+      \pgfpathellipse{\pgfpointorigin}%
+                     {\pgfqpoint{\xradius}{0pt}}%
+                     {\pgfqpoint{0pt}{\yradius}}%
+   }%
+}
+
+\pgfdeclareshape{yquant-measure}{%
+   \saveddimen\xradius{%
+      \pgfmathsetlength\pgf at x{\pgfkeysvalueof{/tikz/x radius}}%
+      \ifdim.5\wd\pgfnodeparttextbox>\pgf at x%
+         \pgf at x=.5\wd\pgfnodeparttextbox%
+      \fi%
+   }%
+   \saveddimen\yradius{%
+      \pgfmathsetlength\pgf at x{\pgfkeysvalueof{/tikz/y radius}}%
+      \ifdim\dimexpr\ht\pgfnodeparttextbox+\dp\pgfnodeparttextbox\relax=0pt %
+         \ifdim\pgf at x<1.25mm %
+            \pgf at x=1.25mm %
+         \fi%
+      \else%
+         % We need the 2.3mm for the meter sign, the height of the text plus a minimum separation of 2pt
+         \pgf at y=.5\dimexpr\ht\pgfnodeparttextbox+\dp\pgfnodeparttextbox+2.3mm+4pt\relax%
+         \ifdim\pgf at x<\pgf at y%
+            \pgf at x=\pgf at y%
+         \fi%
+      \fi%
+   }%
+   \savedanchor\stext{%
+      \pgfqpoint%
+         {-.5\wd\pgfnodeparttextbox}%
+         {\dp\pgfnodeparttextbox}%
+   }%
+   \saveddimen\textheight{%
+      \pgf at x=\ht\pgfnodeparttextbox%
+   }
+   \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west, circuit} {%
+      \inheritanchor[from=yquant-rectangle]{\anc}%
+   }%
+   \anchor{text}{%
+      \stext%
+      \pgf at y=\dimexpr-\yradius+1pt+\pgf at y\relax%
+   }%
+   \inheritanchorborder[from=yquant-rectangle]%
+   \inheritanchorxproj[from=yquant-rectangle]%
+   \inheritanchoryproj[from=yquant-rectangle]%
+   \backgroundpath{%
+      \pgfpathrectanglecorners%
+         {\pgfqpoint{-\xradius}{\yradius}}%
+         {\pgfqpoint{\xradius}{-\yradius}}%
+   }
+   \beforebackgroundpath{%
+      % Make sure the meter does not extend beyond the box (we are in a scope here)
+      \path [clip]
+         (-\xradius, \yradius) rectangle (\xradius, -\yradius);%
+      % The position of the meter symbol depends on the presence of the text. If there is no text, we just vertically center. If there is some text, we shift the symbol upwards from the text until there is no overlap any more.
+      \csname pgf at anchor@yquant-measure at text\endcsname%
+      \advance\pgf at y by \textheight\relax%
+      \ifdim\pgf at y<-1.15mm %
+         \@tempdima=-1.15mm %
+      \else%
+         \@tempdima=\dimexpr\pgf at y+2pt\relax%
+      \fi%
+      \path [/yquant/operators/every measure meter]
+         (-2.25mm, \@tempdima) arc[start angle=160, end angle=20,%
+                                   x radius=2.25mm, y radius=1.4mm]
+         (0, \@tempdima) -- ++(1.6mm, 2.3mm);
+   }%
+}
+
+\pgfdeclareshape{yquant-dmeter}{%
+   \saveddimen\xradius{%
+      \pgfmathsetlength\pgf at x{\pgfkeysvalueof{/tikz/x radius}}%
+      \ifdim\wd\pgfnodeparttextbox=0pt %
+         \pgf at xa=0pt %
+      \else%
+         \pgfmathsetlength\pgf at xa{\pgfkeysvalueof{/pgf/inner xsep}+.5mm}%
+      \fi%
+      \ifdim\dimexpr.5\wd\pgfnodeparttextbox+\pgf at xa\relax>\pgf at x%
+         \pgf at x=\dimexpr.5\wd\pgfnodeparttextbox+\pgf at xa\relax%
+      \fi%
+   }%
+   \saveddimen\yradius{%
+      \pgfmathsetlength\pgf at x{\pgfkeysvalueof{/tikz/y radius}}%
+      \ifdim\dimexpr\ht\pgfnodeparttextbox+\dp\pgfnodeparttextbox\relax=0pt %
+         \pgf at xa=0pt %
+      \else%
+         \pgfmathsetlength\pgf at xa{\pgfkeysvalueof{/pgf/inner ysep}}%
+      \fi%
+      \@tempdima=\dimexpr.5\ht\pgfnodeparttextbox+.5\dp\pgfnodeparttextbox+\pgf at xa\relax%
+      \ifdim\@tempdima>\pgf at x%
+         \pgf at x=\@tempdima%
+      \fi%
+   }%
+   \savedanchor\stext{%
+      \pgfqpoint%
+         {-\dimexpr.5\wd\pgfnodeparttextbox+1mm\relax}%
+         {-\dimexpr.5\ht\pgfnodeparttextbox-.5\dp\pgfnodeparttextbox\relax}%
+   }%
+   \foreach \anc in {center, north, south, south west, west, north west, circuit, text} {%
+      \inheritanchor[from=yquant-rectangle]{\anc}%
+   }%
+   \foreach \anc in {north east, east, south east} {%
+      \inheritanchor[from=yquant-circle]{\anc}%
+   }%
+%   \anchor{text}{%
+%      \stext%
+%      \pgf at x=-.5\dimexpr\xradius-\pgf at x\relax%
+%   }%
+   \anchorborder{%
+      \@tempdima=\pgf at x%
+      \@tempdimb=\pgf at y%
+      \ifdim\pgf at x>\dimexpr\xradius-3mm\relax%
+         \pgfpointborderellipse{\pgfqpoint{\dimexpr\@tempdima-\xradius+3mm\relax}%
+                                          {\@tempdimb}}%
+                               {\pgfqpoint{3mm}%
+                                          {.707107\dimexpr\yradius\relax}}%
+         \advance\pgf at x by \dimexpr\xradius-3mm\relax%
+      \else%
+         \pgfpointborderrectangle{\pgfqpoint{\@tempdima}{\@tempdimb}}%
+                                 {\pgfqpoint{\xradius}{\yradius}}%
+      \fi%
+   }%
+   \anchorxproj{%
+      \ifdim\pgf at x>\dimexpr\xradius-3mm\relax%
+         % to the right
+         \advance\pgf at x by -\dimexpr\xradius-3mm\relax%
+         \yquant at shape@ellipse at xfromy{3mm}\yradius\pgf at y%
+         \pgf at x=\dimexpr\pgf at xa+\xradius-3mm\relax%
+      \else%
+         % to the left
+         \pgf at x=-\xradius\relax%
+      \fi%
+   }%
+   \anchoryproj{%
+      \ifdim\pgf at x>\dimexpr\xradius-3mm\relax%
+         % to the right
+         \advance\pgf at x by -\dimexpr\xradius-3mm\relax%
+         \yquant at shape@ellipse at xfromy\yradius{3mm}\pgf at x%
+         \advance\pgf at x by \dimexpr\xradius-3mm\relax%
+         \ifdim\pgf at y>0pt %
+            % to the top
+            \pgf at y=\pgf at xa%
+         \else%
+            % to the bottom
+            \pgf at y=-\pgf at xa%
+         \fi%
+      \else%
+         % to the left
+         \ifdim\pgf at y>0pt %
+            % to the top
+            \pgf at y=\yradius\relax%
+         \else%
+            \pgf at y=-\yradius\relax%
+         \fi%
+      \fi%
+   }%
+   \backgroundpath{%
+      \pgfpathmoveto{\pgfqpoint{-\xradius}{\yradius}}%
+      \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-3mm\relax}{\yradius}}%
+      \pgfpatharc{90}{-90}{3mm and \yradius}%
+      \pgfpathlineto{\pgfqpoint{-\xradius}{-\yradius}}%
+      \pgfpathclose%
+   }%
+}
+
+\pgfdeclareshape{yquant-barrier}{%
+   % Here, the radii have a special meaning, we don't put text into the shape
+   \saveddimen\xradius{%
+      \pgf at x=.5\pgflinewidth%
+   }%
+   \savedanchor\shorten{%
+      \pgfqpoint\pgf at shorten@end at additional\pgf at shorten@start at additional%
+   }%
+   \saveddimen\yradius{%
+      \pgfmathsetlength\pgf at x{\pgfkeysvalueof{/tikz/y radius}+.5*\yquant at config@register at sep}%
+   }%
+   \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west, circuit} {%
+      \inheritanchor[from=yquant-rectangle]{\anc}%
+   }%
+   \inheritanchorborder[from=yquant-rectangle]%
+   \backgroundpath{%
+      \pgfsetlinewidth{\xradius}%
+      \shorten%
+      \pgf at xa=\dimexpr\yradius+\pgf at x\relax%
+      \pgf at ya=\dimexpr\yradius+\pgf at y\relax%
+      \pgfpathmoveto{\pgfqpoint{0pt}{\pgf at xa}}%
+      \pgfpathlineto{\pgfqpoint{0pt}{-\pgf at ya}}%
+   }%
+}
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/yquant/yquant-tools.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-tools.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-tools.tex	2020-03-24 20:57:29 UTC (rev 54527)
@@ -0,0 +1,265 @@
+% from TeXbook, appendix D
+\protected\def\yquant at futurenonspacelet#1{%
+   \def\yquant at futurenonspacelet@cs{#1}%
+   \afterassignment\yquant at futurenonspacelet@i\let\yquant at futurenonspacelet@next= %
+}
+
+\def\yquant at futurenonspacelet@i{%
+   \expandafter\futurelet\yquant at futurenonspacelet@cs\yquant at futurenonspacelet@ii%
+}
+
+\def\yquant at futurenonspacelet@ii{%
+   \expandafter\ifx\yquant at futurenonspacelet@cs\@sptoken%
+      \expandafter\yquant at futurenonspacelet@iii%
+   \else%
+      \expandafter\yquant at futurenonspacelet@next%
+   \fi%
+}
+
+\def\yquant at futurenonspacelet@iii{%
+   \afterassignment\yquant at futurenonspacelet@i%
+   \let\@eattoken= %
+}
+
+% Loop #1 from min(#2, #3) to max(#2, #3), executing #4
+\protected\def\yquant at for #1:=#2to#3#{%
+   \yquant at for@aux#1{#2}{#3}%
+}
+
+\long\def\yquant at for@aux#1#2#3#4{%
+   \ifnum#2<#3\relax%
+      \numdef#1{#2}%
+      % to allow for things like \yquant at for \i := \i to ..., expand the boundaries
+      \expandafter\yquant at for@loop\expandafter#1\expandafter{\the\numexpr#3+1\relax}{#4}%
+   \else%
+      \numdef#1{#3}%
+      \expandafter\yquant at for@loop\expandafter#1\expandafter{\the\numexpr#2+1\relax}{#4}%
+   \fi%
+}
+
+\long\def\yquant at for@loop#1#2#3{%
+   \loop%
+      \ifnum#1<#2\relax%
+         #3%
+         \numdef#1{#1+1}%
+   \repeat%
+}
+
+% Def #1 to be the minimum of #2, ... until \relax
+\protected\def\yquant at min#1{%
+   \def#1{2147483647}%
+   \def\yquant at min@var{#1}%
+   \yquant at min@loop%
+}
+
+\def\yquant at min@loop#1{%
+   \unless\ifx#1\relax\relax%
+      \ifnum#1<\yquant at min@var\relax%
+         \expandafter\edef\yquant at min@var{#1}%
+      \fi%
+      \expandafter\yquant at min@loop%
+   \fi%
+}
+
+% Def #1 to be the maximum of #2, ... until \relax
+\protected\def\yquant at max#1{%
+   \def#1{-2147483647}%
+   \def\yquant at max@var{#1}%
+   \yquant at max@loop%
+}
+
+\def\yquant at max@loop#1{%
+   \unless\ifx#1\relax\relax%
+      \ifnum#1>\yquant at max@var\relax%
+         \expandafter\edef\yquant at max@var{#1}%
+      \fi%
+      \expandafter\yquant at max@loop%
+   \fi%
+}
+
+% Cleanup global tokens after environment
+\protected\def\yquant at cleanup@csadd#1{%
+   \csxappto{\yquant at prefix cleanup}{\expandafter\noexpand\csname#1\endcsname}%
+}
+
+\def\yquant at cleanup#1#2{%
+   \global\undef#1%
+   \unless\ifx|#2%
+      \expandafter\yquant at cleanup\expandafter#2%
+   \fi%
+}
+
+% Executes #3 if #1 (single token!) is equal (\ifx) to the first token of #2, and #4 else.
+\def\ifyquant at firsttoken#1#2{%
+   % First check whether #2 is present at all...
+   \if\relax\detokenize{#2}\relax%
+      \expandafter\@secondoftwo%
+   \else%
+      \ifyquant at firsttoken@aux#1#2\yquant at sep%
+   \fi%
+}
+
+\def\ifyquant at firsttoken@aux#1#2#3\yquant at sep{%
+   \ifx#1#2%
+      \expandafter\expandafter\expandafter\@firstoftwo%
+   \else%
+      \expandafter\expandafter\expandafter\@secondoftwo%
+   \fi%
+}
+
+% Executes #3 if #1 begins with #2, and #4 else - non-expandable
+\protected\def\ifyquant at beginswith#1#2{%
+   \def\ifyquant at beginswith@##1#2##2\yquant at end{%
+      \if\relax\detokenize{##1}\relax%
+         \expandafter\@firstoftwo%
+      \else%
+         \expandafter\@secondoftwo%
+      \fi%
+   }%
+   \ifyquant at beginswith@#1#2\yquant at end%
+}
+
+% absolute value of a dimension
+\def\yquant at abs#1{%
+   \ifdim#1<0pt %
+      \the\dimexpr-\dimexpr#1\relax\relax%
+   \else%
+      #1%
+   \fi%
+}
+
+% Sortlist related macros.
+\newcount\yquant at sort@count
+
+\protected\def\yquant at sort@clear{%
+   % Probably cleanup used macros?
+   \yquant at sort@count=0 %
+}
+
+\protected\def\yquant at sort@eadd#1{%
+   \csedef{yquant at sort@item\the\yquant at sort@count}{#1}%
+   \advance \yquant at sort@count by 1 %
+}
+
+% Perform quicksort on the stored sortlist.
+% #1: compare macro that expands to ##3 if its second argument is strictly larger than its first or to ##4 else
+\protected\def\yquant at sort#1{%
+   \let\yquant at sort@cmp=#1%
+   \expandafter\yquant at sort@aux\expandafter0\expandafter{\the\numexpr\yquant at sort@count-1\relax}%
+}
+
+\protected\def\yquant at sort@aux#1#2{%
+   \ifnum#1<#2\relax%
+      \yquant at sort@divide{#1}{#2}%
+      \edef\cmd{%
+         \noexpand\yquant at sort@aux{#1}{\the\numexpr\count0-1\relax}%
+         \noexpand\yquant at sort@aux{\the\numexpr\count0+1\relax}{#2}%
+      }%
+      \cmd%
+   \fi%
+}
+
+\protected\def\yquant at sort@divide#1#2{%
+   \count0=#1\relax% i
+   \count2=#2\relax% j
+   \advance\count2 by -1 %
+   \letcs\yquant at sort@pivot{yquant at sort@item#2}%
+   \loop%
+      % search an item from the left that is larger or equal to the pivot
+      {% protect the outer loop from finding \repeat
+         \csletcs{next}{iftrue}%
+         \loop%
+            \ifnum\count0<#2\relax%
+               \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\yquant at sort@cmp%
+                  \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{%
+                  \expandafter\expandafter\expandafter\yquant at sort@pivot%
+                  \expandafter\expandafter\expandafter}%
+                  \expandafter\expandafter\expandafter{%
+                     \csname yquant at sort@item\the\count0\endcsname%
+                  }{%
+                     \csletcs{next}{iffalse}%
+                  }{%
+                     \advance\count0 by 1 %
+                  }%
+            \else%
+               \csletcs{next}{iffalse}%
+            \fi%
+            \next%
+         \repeat%
+         \expandafter%
+      }%
+      \expandafter\count\expandafter0\expandafter=\the\count0\relax%
+      % search an item from the right that is small than the pivot
+      {% protect the outer loop from finding \repeat
+         \csletcs{next}{iftrue}%
+         \loop%
+            \ifnum\count2>#1\relax%
+               \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\yquant at sort@cmp%
+                  \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{%
+                  \expandafter\expandafter\expandafter\yquant at sort@pivot%
+                  \expandafter\expandafter\expandafter}%
+                  \expandafter\expandafter\expandafter{%
+                     \csname yquant at sort@item\the\count2\endcsname%
+                  }{%
+                     \advance\count2 by -1 %
+                  }{%
+                     \csletcs{next}{iffalse}%
+                  }%
+            \else%
+               \csletcs{next}{iffalse}%
+            \fi%
+            \next%
+         \repeat%
+         \expandafter
+      }%
+      \expandafter\count\expandafter2\expandafter=\the\count2\relax%
+      \ifnum\count0<\count2 %
+         % swap item i <> item j
+         \letcs\tmp{yquant at sort@item\the\count0}%
+         \csletcs{yquant at sort@item\the\count0}{yquant at sort@item\the\count2}%
+         \cslet{yquant at sort@item\the\count2}\tmp%
+      \fi%
+      \ifnum\count0<\count2 %
+   \repeat%
+   \letcs\tmp{yquant at sort@item\the\count0}%
+   \csletcs{yquant at sort@item\the\count0}{yquant at sort@item#2}%
+   \cslet{yquant at sort@item#2}\tmp%
+}
+
+% Sorts an internal etoolbox list #1 using macro #2
+\protected\def\yquant at sort@list#1#2{%
+   \begingroup%
+      \yquant at sort@count=0 %
+      \def\do##1{%
+         \csdef{yquant at sort@item\the\yquant at sort@count}{##1}%
+         \advance\yquant at sort@count by 1 %
+      }%
+      \dolistloop#1%
+      \yquant at sort#2%
+      \let#1=\empty%
+      \count0=0 %
+      \loop%
+         \ifnum\count0<\yquant at sort@count%
+            \expandafter\expandafter\expandafter\listadd%
+            \expandafter\expandafter\expandafter#1%
+            \expandafter\expandafter\expandafter{%
+               \csname yquant at sort@item\the\count0\endcsname%
+            }%
+            \advance\count0 by 1 %
+      \repeat%
+      \expandafter%
+   \endgroup%
+   \expandafter\def\expandafter#1\expandafter{#1}%
+}
+
+\protected\def\yquant at sort@dolistloop{%
+   \count0=0 %
+   \loop%
+      \ifnum\count0<\yquant at sort@count%
+         \expandafter\expandafter\expandafter\do%
+         \expandafter\expandafter\expandafter{%
+            \csname yquant at sort@item\the\count0\endcsname%
+         }
+         \advance\count0 by 1 %
+   \repeat%
+}
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/latex/yquant/yquant-tools.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/yquant/yquant.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant.sty	2020-03-24 20:57:29 UTC (rev 54527)
@@ -0,0 +1,40 @@
+% yquant.sty
+%  Typesetting quantum circuits using a flow-oriented language
+%
+% Copyright 2019-2020 Benjamin Desef
+%
+% This work may be distributed and/or modified under the conditions of the LaTeX Project
+% Public License, either version 1.3 of this license or (at your option) any later
+% version.
+% The latest version of this license is in
+%   http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or
+% later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Benjamin Desef.
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{yquant}[2020/03/22 v0.1.1 Yet another quantum circuit library for LaTeX]
+
+\RequirePackage{etoolbox}[2018/02/11]
+\RequirePackage{tikz}[2015/08/29]
+\RequirePackage{trimspaces}[2009/09/17]
+\usetikzlibrary{arrows.meta}
+
+\input yquant-config.tex
+\input yquant-tools.tex
+\input yquant-registers.tex
+\input yquant-env.tex
+\input yquant-langhelper.tex
+\input yquant-circuit.tex
+\input yquant-draw.tex
+\input yquant-shapes.tex
+\input yquant-lang.tex
+
+% usually, \\ is robust; but when using \centering, it is \let to \@centercr, which is not robust (probably because this happens only when not protecting). Fix this, so that \\ does not require \protect if a centered circuit is drawn.
+\robustify\@centercr
+
+\endinput
+%%
+%% End of file `yquant.sty'.
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/latex/yquant/yquant.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check	2020-03-24 20:54:13 UTC (rev 54526)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2020-03-24 20:57:29 UTC (rev 54527)
@@ -795,7 +795,7 @@
     xwatermark xyling xymtex xypic xypic-tut-pt xytree
   yafoot yagusylo yaletter yannisgr yathesis yax yazd-thesis
     ycbook ydoc yfonts yfonts-t1 yhmath
-    yinit-otf york-thesis youngtab yplan ytableau
+    yinit-otf york-thesis youngtab yplan yquant ytableau
   zapfchan zapfding zebra-goodies zed-csp
     zhlineskip zhlipsum zhnumber zhmetrics zhmetrics-uptex zhspacing
     ziffer zlmtt zootaxa-bst zref

Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds	2020-03-24 20:54:13 UTC (rev 54526)
+++ trunk/Master/tlpkg/libexec/ctan2tds	2020-03-24 20:57:29 UTC (rev 54527)
@@ -1380,6 +1380,7 @@
  'yinit',       "die 'skipping, use gothic'",
  'yinit-as',    "die 'skipping, wait request, old never-included variant of yinit'",
  'yplan',       "&MAKEnosymlinks",
+ 'yquant',	"&MAKEflatten",
  'yschwab',     "die 'skipping, use gothic'",
  'yt4pdf',      "die 'skipping, per author (dps) request'",
  'ytex',        "die 'skipping, noinfo license'",
@@ -2153,6 +2154,7 @@
  'xstring',     'xstring\.tex|' . $standardtex,
  'yathesis',    '\.(sty|cls)$',         # no .cfg
  'yax',         '(t-)?yax\.(sty|tex)|' . $standardtex,
+ 'yquant',	'\.sty|yquant-.*[^c]\.tex', # not yquant-doc.{tex,pdf}
  'zefonts',     '\.sty|\.fd',
 );
 

Modified: trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc	2020-03-24 20:54:13 UTC (rev 54526)
+++ trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc	2020-03-24 20:57:29 UTC (rev 54527)
@@ -209,4 +209,5 @@
 depend xymtex
 depend yhmath
 depend youngtab
+depend yquant
 depend ytableau

Added: trunk/Master/tlpkg/tlpsrc/yquant.tlpsrc
===================================================================


More information about the tex-live-commits mailing list.