texlive[54737] Master/texmf-dist: yquant (14apr20)

commits+karl at tug.org commits+karl at tug.org
Tue Apr 14 23:06:44 CEST 2020


Revision: 54737
          http://tug.org/svn/texlive?view=revision&revision=54737
Author:   karl
Date:     2020-04-14 23:06:44 +0200 (Tue, 14 Apr 2020)
Log Message:
-----------
yquant (14apr20)

Modified Paths:
--------------
    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/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

Modified: trunk/Master/texmf-dist/doc/latex/yquant/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/yquant/README.md	2020-04-14 21:06:20 UTC (rev 54736)
+++ trunk/Master/texmf-dist/doc/latex/yquant/README.md	2020-04-14 21:06:44 UTC (rev 54737)
@@ -7,6 +7,9 @@
 
 A detailed reference with lots of examples is provided in the PDF version of this Readme. We will sketch some basic usage.
 
+## License
+This material is subject to the LaTeX Project Public License 1.3.
+
 ## 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.
 

Modified: trunk/Master/texmf-dist/doc/latex/yquant/yquant-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/yquant/yquant-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/yquant/yquant-doc.tex	2020-04-14 21:06:20 UTC (rev 54736)
+++ trunk/Master/texmf-dist/doc/latex/yquant/yquant-doc.tex	2020-04-14 21:06:44 UTC (rev 54737)
@@ -117,16 +117,16 @@
    \begingroup%
       \setlength{\parskip}{0pt}%
       \setlength{\parindent}{0pt}%
-      \if\relax\detokenize{#5}\relax%
+      \ifstrempty{#5}{%
          \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{%
@@ -197,7 +197,7 @@
       This document outlines the scope and usage of the \Yquant{} package.
       It contains both a reference and a huge number of examples.
       \Yquant{} is a package that makes typesetting quantum circuits easy; the package is 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.
+      This alpha version~0.1.2 \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}
@@ -256,12 +256,12 @@
          \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.
+          This work may be distributed and/or modified under the conditions of the \LaTeX{} Project Public License, either version~1.3c 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.
+          and version~1.3c 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.
@@ -291,7 +291,9 @@
          \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!
+            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! \\
+            Finally note that in (non\hyp fragile) \texttt{beamer} frames, this discrimination between spaces and new lines does not work; the optional arguments will always be counted for the environment, not for the gate.
+            In this case, you can either declare the frame as fragile or (recommended) introduce a blank line between the environment and the options for the first gate.
          \end{warning}
       
       \subsection{Starred vs. unstarred environment}
@@ -321,18 +323,21 @@
 
 RegisterSingle = RegisterSingleNoRange | RegisterRange;
 RegisterSingleNoRange = ?name?, [ "[", IndexMultiList, "]" ];
-RegisterMulti = "(", ( RegisterMultiNoRange | RegisterRange ), ")";
-RegisterMultiNoRange = ?name?, [ "[", IndexSingleList, "]" ];
+RegisterMulti = "(", ( RegisterMultiNoRange | [ "*" ], RegisterRange ), ")";
+RegisterMultiNoRange = [ "*" ], ?name?, [ "[", IndexSingleMainList, "]" ];
 RegisterRange = [ RegisterUnique ], "-", [ RegisterUnique ];
 RegisterUnique = ?name?, [ "[", ?number?, "]" ];
 
-IndexMultiList = IndexMulti, [ ",", IndexMulti ];
-IndexSingleList = IndexSingle, [ ",", IndexSingle ];
+IndexMultiList = IndexMulti, [ ",", IndexMultiList ];
+IndexSingleList = IndexSingle, [ ",", IndexSingleList ];
+IndexSingleMainList = [ "*" ], IndexSingle, [ ",", IndexSingleMainList ];
 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.
+         Not all combinations that can be constructed by this grammar are actually allowed semantically; but it would make the grammar too verbose to spell this out in detail.
+         Deviations are noted in this manual.
          
          Valid values for
          \begin{BVerbatim}[commandchars=\\\{\}]
@@ -348,7 +353,7 @@
 \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.
+         Register names must not contain any of the control literals used before (semicolon, comma, parentheses, square brackets, dash, pipe, tilde, beginning star); 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?}
@@ -359,7 +364,7 @@
          \end{BVerbatim}
          ).
          
-      \subsection{Registers}
+      \subsection{Registers}\label{sec: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:
@@ -421,11 +426,31 @@
          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.
+            Note that some gates, such as the \gate{swap} gate, always require (semantically, not grammatically) multi\hyp register operations.
+            Since version 0.1.2, the number of constituents is no longer fixed; while a \gate{swap} gate with more than two targets is no longer well\hyp defined, other registers such as \gate{zz} may still be useful.
             \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}
+         Typically, multi\hyp register operations should only be carried out on adjacent registers---but sometimes, one might want to carry out a multi\hyp qubit operation on a visually discontiguous set of registers (which, due to a particular quantum computer topology, might even be physically feasible).
+         Since version 0.1.2, \Yquant{} supports these discontiguous operations explicitly (before, a single gate was drawn with all intermediate non\hyp affected register lines laying on top).
+         It will draw a \emph{main} part of the gate at the first contiguous slice of registers in the target list---you may select another register for this part by preceding the name or index with a star (which, contrary to the simplified grammar, may only occur \emph{once} in a target specification).
+         All other contiguous slices of target registers will be drawn in a \emph{subordinate style} for this gate.
+         Finally, all slices will be connected by a single vertical line with the style \style{/yquant/every multi line}.
+         \begin{warning}[Discontiguous targets and control lines]
+            A control line extends from the very first to the very last affected register in an operation.
+            A sub\hyp gate line that is used for discontiguous registers will only span the range of a multi\hyp register.
+            This distinction becomes crucial if you want to carry out a \emph{controlled} operation on more than one multi\hyp register, where at least one is discontiguous.
+            Without the controls, the separate multi\hyp registers could be identified, since no connecting vertical line extends between them (unless, which you should strictly avoid, they are intertwined).
+            However, with the controls, the control line will make it hard (for some gates, impossible) to visually distinguish the connected parts.
+            \Yquant{} will kindly provide a warning in this case.
+            You may choose to suppress this warning using the boolean key \style{/yquant/operator/multi warning}.
+         \end{warning}
+         \begin{warning}
+            There is no established style for discontiguous gates.
+            Note that at the moment, main and subordinate style coincide for all gates except for the \gate{measure} gate with a value.
+            In order to still make it possible to visually distinguish discontiguous multi\hyp register gates operating on slices of a single register from just a bunch of single\hyp register gates that are executed in a parallel manner, if controls are present, \Yquant's default vertical line style for the former case is a wavy line instead of a straight one.
+            Still, the meaning of this should probably be explained.
+            Please feel free to submit issues or pull requests with propositions of how default styles or alternative subordinate gate shapes may additionally help to mitigate the problem.
+         \end{warning}
       
       \subsection{Arguments}
          Every command may take one or multiple arguments.
@@ -474,6 +499,7 @@
          
          \begin{option}{register/separation}!1mm!
             This key controls the amount of vertical space that is inserted between two successive registers.
+            Half of this value is also the length that multi\hyp\gate{init} or multi\hyp\gate{output} braces extend beyond the mid position of the register.
          \end{option}
          
          \begin{option}{operator/minimum width}!3mm!
@@ -486,6 +512,12 @@
          \begin{option}{operator/separation}!1mm!
             This key controls the amount of horizontal space that is inserted between two successive operators.
          \end{option}
+         
+         \begin{option}{operator/multi warning}!true!
+            If this key is \texttt{true}, a warning is displayed whenever more than a single multi\hyp register gate, where at least one is discontiguous, are employed together with controls.
+            Even if a visual distinction between control and multi\hyp qubit line may be possible (depending on the style in use), they will overlap and produce unaesthetic output.
+            You may disable this warning globally, on a per\hyp circuit, or even on a per\hyp gate basis.
+         \end{option}
       
       \subsection{Register creation}\unskipOpt
          \begin{option}{register/default name}!\regidx!
@@ -499,7 +531,7 @@
             \end{itemize}
          \end{option}
          
-         \begin{option}{every label}!shape=yquant-text, anchor=circuit, align=right!
+         \begin{option}{every label}!shape=yquant-text, anchor=center, 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}
@@ -521,10 +553,12 @@
             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)}}!
+         \begin{option}{every multi label}!shift={(-.075, 0)}, draw, decoration={gapped brace, mirror}, decorate, /yquant/gapped brace/apply shift, every node/.append style={shape=yquant-text, anchor=east, align=right, shift={(-.05, 0)}, pos=-1}!
             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.
+            The decoration \texttt{gapped brace} allows to additionally specify the regions in which a line should be drawn by using the \texttt{/tikz/decoration/from to} key, which expects a comma\hyp separated list of dimension ranges, and which is automatically populated by \Yquant.
+            Since it may happen that the arch of the brace needs to be shifted from the value specified in \texttt{/tikz/decoration/aspect} (else, it would be drawn into a gap), the special key \texttt{/yquant/gapped brace/apply shift} is installed, which transforms the \texttt{pos=-1} specification into a position that corresponds to the actual \texttt{aspect} value.
          \end{option}
       
       \subsection{Register outputs}\unskipOpt
@@ -545,16 +579,19 @@
             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)}}!
+         \begin{option}{every multi output}!shift={(.075, 0)}, draw, decoration={gapped brace}, decorate, /yquant/gapped brace/apply shift, every node/.append style={shape=yquant-text, anchor=west, align=left, shift={(.05, 0)}, pos=-1}!
             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.
+            See \style{/yquant/every multi label} for a more detailed explanation.
          \end{option}
       
       \subsection{General styling}\unskipOpt
-         \begin{option}{every circuit}!!
+         \begin{option}{every circuit}!every node/.prefix style={transform shape}, every label/.prefix style={transform shape=false}!
             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.
+            Since version 0.1.2, the style's default path is, as with all other styles, \texttt{/tikz}.
+            The default style will make all nodes (which in particular means, all gates) respect outer canvas transformations.
+            Due to \TikZ{} bug \href{https://github.com/pgf-tikz/pgf/issues/843}{\#843}, this must be undone for \texttt{label}s.
          \end{option}
          
          \begin{option}{every wire}!draw!
@@ -577,7 +614,7 @@
             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!
+         \begin{option}{every control}!shape=yquant-circle, anchor=center, radius=.5mm!
             This style is used to draw the node for a control, both positive and negative.
          \end{option}
          
@@ -589,10 +626,14 @@
             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!
+         \begin{option}{every operator}!anchor=center!
             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}{every multi line}!draw, decoration={snake, amplitude=.25mm, segment length=5pt}, decorate!
+            This style is used to draw the vertical line that connects discontiguous slices of sub\hyp gates.
+         \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}
@@ -612,11 +653,18 @@
          \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}
+         
+         \begin{option}{operator/multi as single}!/yquant/every multi line/.style=/yquant/every control line!
+            This option is automatically set for certain gates such as the \gate{swap} or the \gate{zz} gate.
+            For those gates, neighboring registers will be treated as discontiguous; and this style will enforce their connecting line to have the style used by control lines.
+            
+            The default \style{/yquant/every multi line} is a wavy line; this allows to distinguish discontiguous multi\hyp qubit gates from multiple single\hyp qubit gates when using controls.
+            Still, some gates have such an established appearance that---despite being logically misleading---we rather use the same style as for a control line.
+         \end{option}
       
       \subsection{Styles for operators}\unskipOpt
-         \begin{option}{operators/every barrier}!shape=yquant-barrier, x radius=\pgflinewidth, dashed, draw!
+         \begin{option}{operators/every barrier}!shape=yquant-line, 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!
@@ -660,22 +708,21 @@
             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.
+         \begin{option}{operators/every swap}!shape=yquant-swap, radius=.75mm, draw!
+            This style is installed for every \gate{swap} gate that interchanges two qubits.
+            The \texttt{yquant-swap} shape consists of a single cross.
          \end{option}
          
+         \begin{option}{operators/every wave}!shape=yquant-circle, radius=.5mm, fill!
+            This style is installed for every \gate{correlate} gate.
+         \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.
+         \begin{option}{operators/every xx}!shape=yquant-rectangle, radius=.75mm, draw!
+            This style is installed for every \gate{xx} gate in symmetrized notation ($\ketbra{++}{++} + \ketbra{+-}{+-} + \ketbra{-+}{-+} - \ketbra{--}{--}$).
          \end{option}
          
          \begin{option}{operators/every y}!/yquant/operators/every pauli!
@@ -686,11 +733,8 @@
             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.
+         \begin{option}{operators/every zz}!shape=yquant-circle, radius=.5mm, fill!
+            This style is installed for every \gate{zz} gate (aka \textsc{CPhase}) in symmetrized notation ($\ketbra{00}{00} + \ketbra{01}{01} + \ketbra{10}{10} - \ketbra{11}{11}$).
          \end{option}
          
    \section{Doing the impossible}\label{sec:tikz}
@@ -708,15 +752,40 @@
       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}).
+      Multiple slices in a discontiguous multi\hyp register are additionally suffixed by \texttt{-s\textit{<slice index>}}.
       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.
+      Before version~0.1.2, \Yquant{} shapes needed to provide a \texttt{circuit} anchor and projection anchors.
+      These were removed in version~0.1.2 in favor of the common \texttt{center} anchor and clipping paths.
+      The latter is a \Yquant{} extension to \TikZ{} shapes: it is an additional path that must be declared for a given shape.
+      This path has to provide the ``clipping outline,'' i.e., anything that should not contain register or control lines.
+      There may be a difference between horizontal and vertical clipping outlines.
+      To understand clipping paths, \Yquant's drawing pipeline needs to be explained.
+      \begin{itemize}
+         \item In a first run---this is what happens directly at the position where you type the gate command---\Yquant{} will ``virtually'' draw the gates in order to determine their dimensions and calculate register heights.
+            The actual drawing commands are written to a macro (this is the cause that some macros must be preceded by \tex!\protect! if used in a gate \texttt{value}).
+         \item When \tex!\end{yquant}! is encountered, the actual drawing commands are executed.
+         \item Unless the operation changes the wire type or style, do the following (first two items for every register at which an operator node has to be created).
+            \begin{itemize}
+               \item Create the operator node at the appropriate position.
+               \item Call \tex!\pgfshapeclippath! on the newly created node.
+                  This will first determine whether the node was stroked; if not, \tex!\pgflinewidth! is set to zero.
+                  Then, it will call the horizontal clipping path, which is supposed to create some soft path commands.
+                  Those soft path commands are collected in a macro on a per\hyp register basis and the soft path is cleared.
+                  The same happens for the vertical clipping path, which is collected in a macro on a per\hyp operation basis.
+               \item If control lines or multi lines are to be drawn, the vertical clipping path commands are now executed and installed as an inverted\footnote{Inverting the clipping has two consequences: First, the region of inversion in vertical direction is given by the width of the operators. The line cannot be wider than the operator. Second, if you specify a register multiple times, whether as target, control, or mixed, funny effects can be expected, as the clipping region is inverted multiple times. Note that using a register more than once is always an error, but \Yquant{} does not check for it due to the high overhead.} clipping path.
+               \item Control lines and multi lines are drawn (in this order) from one to the next \texttt{center} anchor.
+                  Due to the clipping commands, this will create a perfect connection with the shape of the gate, but even transparent gates are possible without the lines being visible.
+            \end{itemize}
+         \item If the operation changes the wire type or style, or if there is no operation left on this register, the following is done.
+            \begin{itemize}
+               \item Load the clipping paths accumulated for all the gates acting on this register and install the inverted clipping.
+               \item Draw the wire as one continuous line from where the last wire ended (or the beginning of the circuit) to the center of the last gate, or to the common end position for all wires of the circuit.
+               \item Remove the clipping paths stored so far on this register, apart from the clipping on the last gate (which will be needed again if this was not the end of the circuit).
+            \end{itemize}
+      \end{itemize}
       
 %      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).
@@ -726,6 +795,19 @@
       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!addstyle!}{addstyle}}\label{gate:addstyle}
+         Syntax: \yquant!setstyle <target>;! \\
+         This is an invisible pseudo\hyp gate that immediately changes the \TikZ{} style with which the register lines of all target registers are drawn.
+         It adds to the styles that are already installed.
+         Use \gate{setstyle} to replace styles.
+         It may not span multiple registers and does not allow for controls.
+         
+         \emph{Possible attributes:}
+         \begin{itemize}
+            \item \yquant![value=<styles>]! (required) \\
+               Denotes the new styles; this should be a string that could be passed to \tex!\tikzset!.
+         \end{itemize}
+      
       \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.
@@ -759,6 +841,13 @@
          
          \emph{see \hyperref[gate:qubit]{\yquant!qubit!}}
       
+      \subsection{\texorpdfstring{\yquant!correlate!}{correlate}}\label{gate:correlate}
+         Syntax: \yquant!correlate <target>;! \\
+         This is a pseudo\hyp gate that indicates a correlation (usually a Bell\hyp state) present between the multi\hyp registers involved.
+         This gate should span multiple registers and does not allow for controls.
+         
+         \emph{Possible attributes:} none
+      
       \subsection{\texorpdfstring{\yquant!cnot!}{cnot}}\label{gate:cnot}
          Syntax: \yquant!cnot <target> | <pcontrol> ~ <ncontrol>;! \\
          This is a synonym for the \gate{not} gate.
@@ -769,7 +858,7 @@
          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.
+         To change into a register type on\hyp the\hyp fly into something different from \gate{nobit}, use the \gate{settype} pseudo\hyp gate.
          
          \emph{Possible attributes:} none
       
@@ -830,7 +919,6 @@
                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.
@@ -919,8 +1007,21 @@
          
          \emph{see \hyperref[gate:qubit]{\yquant!qubit!}}
       
-      \subsection{\texorpdfstring{\yquant!setwire!}{setwire}}\label{gate:setwire}
-         Syntax: \yquant!setwire <target>;! \\
+      \subsection{\texorpdfstring{\yquant!setstyle!}{setstyle}}\label{gate:setstyle}
+         Syntax: \yquant!setstyle <target>;! \\
+         This is an invisible pseudo\hyp gate that immediately changes the \TikZ{} style with which the register lines of all target registers are drawn.
+         It replaces all previous styles.
+         Use \gate{addstyle} to accumulate styles.
+         It may not span multiple registers and does not allow for controls.
+         
+         \emph{Possible attributes:}
+         \begin{itemize}
+            \item \yquant![value=<styles>]! (required) \\
+               Denotes the new styles; this should be a string that could be passed to \tex!\tikzset!.
+         \end{itemize}
+         
+      \subsection{\texorpdfstring{\yquant!settype!}{settype}}\label{gate:settype}
+         Syntax: \yquant!settype <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.
          
@@ -931,6 +1032,9 @@
                To change the type to \gate{nobit}, use the \hyperref[gate:discard]{\yquant!discard!} pseudo\hyp gate instead.
          \end{itemize}
       
+      \subsection{\texorpdfstring{\yquant!setwire!}{setwire}}\label{gate:setwire}
+         \emph{Deprecated as of version~0.1.2. Use \gate{settype} instead.}
+      
       \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.
@@ -962,11 +1066,9 @@
          
       \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.
+         This is a symmetric flip gate, denoted by joined open squares.
+         It should span multiple registers and it allows for controls.
+         The same warnings as for the \gate{swap} gate apply.
          The style \style{/yquant/operators/every xx} is installed.
          
          \emph{Possible attributes:} none
@@ -989,8 +1091,9 @@
          
       \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.
+         This is a symmetric phase gate, denoted by joined filled circles.
+         It should span multiple registers, but does not allow for controls.
+         The same warnings as for the \gate{swap} gate apply.
          The style \style{/yquant/operators/every zz} is installed.
          
          \emph{Possible attributes:} none
@@ -1195,8 +1298,8 @@
 \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.
+            The labels chosen for \pkg{qasm} do not fit well to the indices \Yquant{} assigns.
+            We might also have used a three\hyp register vector and used the \gate{settype} 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)]
@@ -1328,12 +1431,12 @@
    \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.
+            We needed to include an \gate{align} pseudo\hyp gate to put the slash at the desired position.
+            Usually, this would be sufficient to put the \gate{cnot} and the \gate{slash} gate directly under each other, as it is in the \pkg{qasm} example.
+            However, the \gate{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 \gate{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.
+            Note that \gate{discard} currently just drops the wire directly after the last operation.
          \end{example}
          
          \begin{example}[test17 (example from Nielsen paper on cluster states)]
@@ -1359,14 +1462,12 @@
    \begin{yquant}
       qubit {$\ket{q_{\idx}} = \ket{\ifcase\idx\relax \psi \or + \or + \or \phi \fi}$} q[4];
       
-      phase {} | q;
+      zz (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 gate is probably a generalization of \gate{zz}, $\symbb1 - 2 \ketbra{1\dotsm1}{1\dotsm1}$, and indeed since version~0.1.2, we can use \gate{zz} for this purpose.
             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
@@ -1506,15 +1607,27 @@
    \begin{yquant*}
       box {$U$} a;
       box {$U^\dagger$} b;
-      \yquantset{every wire/.append style={->}}
+      setstyle {->} -;
    \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.
+                  Since version~0.1.2, \Yquant{} allows to change wire styles by means of the \gate{setstyle} and \gate{addstyle} pseudo\hyp gates.
+                  Here, we use the gate on all wires in order to set an arrow style.
+                  Note that arrowheads are actually very special in two respects:
+                  \begin{itemize}
+                     \item \Yquant{} draws continuous wires for as long as possible.
+                        In this example, the wire path extends from the very left to the end of the circuit; since version 0.1.2, \Yquant{} does not draw a wire \emph{to} the gate and then a separate one \emph{from} the gate to the next or the end.
+                        The only way to force \Yquant{} to draw multiple wires is to change the wire style or type mid\hyp circuit.
+                        For example, by saying \yquant!addstyle {} -;!, all wire paths will be separated at the current position, which \emph{in theory} allows to draw arrowsheads on intermediate wires.
+                     \item \emph{In practice}, this will not work due to the clipping commands that \Yquant{} installs.
+                        Every wire extends from the center of the left to the center of the right gate, and the gate's shape acts as a clipping path.
+                        Consequently, though the arrowhead is drawn, it is actually drawn at the center of the gate instead of the \texttt{west} anchor and then clipped away (unless the gate is small, in which case you might still see some fragments of the arrowhead).
+                  \end{itemize}
+                  Thus, it is currently not possible to use arrowheads on intermediate wires.
+                  If you really need to do this (say, for only a single gate), you may experiment with the \TikZ{} \texttt{shorten} keys, which allow you to manually reduce the length of the wire, but the amount of reduction must be hand\hyp computed for every gate.
+                  If you need this more often, consider filing a feature request.
                \end{example}
                
-            \clearpage
             \paragraph{B. CNOT and other controlled single qubits gates}\leavevmode
                \begin{example}
                   \begin{codeexample}
@@ -1539,6 +1652,7 @@
                   \end{codeexample}
                \end{example}
                
+            \clearpage
             \paragraph{C. Vertical wires}\leavevmode
                \begin{example}
                   \begin{codeexample}
@@ -1590,7 +1704,7 @@
                   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.
+                  This is achieved by some trickery: the individual labels are given as initialization labels on the register; the global label is given as an \gate{init} multi\hyp qubit gate.
                \end{example}
                
          \clearpage
@@ -1633,13 +1747,12 @@
 \begin{tikzpicture}
    \begin{yquant*}
       box {$\symcal F$} (a[-1]);
-      [name=g]
-      box {$\symcal G$} a[0, 2];
-      \draw (g-0) -- (g-1);
+      box {$\symcal G$} (a[0, 2]);
    \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{codeexample}
+                  This demonstrates \Yquant's capabilities of discontiguous multi\hyp qubit gates that was added in version~0.1.2.
+                  \Yquant{} automatically splits multi\hyp qubit gates into slices of directly adjacent wires (which, for the $\symcal G$ case, are the single wires \yquant!a[0]! and as second slice \yquant!a[2]!).
                \end{example}
                
             \paragraph{B. Measurements and classical bits}\leavevmode
@@ -1662,7 +1775,7 @@
                   \begin{codeexample}
 \begin{tikzpicture}
    \begin{yquant*}
-      [shape=yquant-circle]
+      [rounded corners]
       box {Codebit} a;
       box {$\chi$} b | a;
       discard a;
@@ -1670,7 +1783,7 @@
    \end{yquant*}
 \end{tikzpicture}
                   \end{codeexample}
-                  Rectangles with rounded corners are not supported yet.
+                  Rectangles with rounded corners are not a specific style, but since the \texttt{yquant-rectangle} shape internally uses \tex!\pgfpathrectangle!, the ordinary \TikZ{} option can be used (also, an inset specification can control how much the corner is rounded).
                \end{example}
                
                \clearpage
@@ -1705,8 +1818,18 @@
    \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.
+                  Multi\hyp qubit gates (including measurements) on non\hyp adjacent registers are properly supported since version~0.1.2.
+                  As explained in \cref{sec:registers}, there is one main and multiple subordinate gate in such a discontiguous multi\hyp qubit operation (though at the moment, the \gate{measure} gate with text is the only gate that makes this distinction).
+                  In our case, the main part contains the measurement symbol and the text, while the subordinate gates only contain the text.
+                  By default, \Yquant{} uses the first slice as main part, but you may influence this by preceding what you want to be ``main'' by a star:
+                  
+                  \begin{codeexample}
+\begin{tikzpicture}
+   \begin{yquant*}
+      measure {$\ket{\xi_\mp}$} (a[-1, *3]);
+   \end{yquant*}
+\end{tikzpicture}
+                  \end{codeexample}
                \end{example}
                
             \clearpage
@@ -1725,7 +1848,7 @@
    \end{yquant*}
 \end{tikzpicture}
                   \end{codeexample}
-                  Here, the intermediate text was inserted by using a \tex!box! without drawing.
+                  Here, the intermediate text was inserted by using a \gate{box} without drawing.
                   Another way would be to use an \gate{init} command, although this is semantically wrong (probably).
                \end{example}
                
@@ -1762,10 +1885,9 @@
    \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}
+               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.
                
             \paragraph{E. How to control anything}\leavevmode
                \begin{example}
@@ -1785,6 +1907,7 @@
                   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.
+                  But note the relatively common (though unsupported by \Yquant{} at the moment) use of control lines that directly go from the measurement operator to the controlled operation; in this case, the opposite direction would be meant by using the same notation.
                \end{example}
                
          \subsubsection{VI. Bells and Whistles: Tweaking Your Diagram to Perfection}
@@ -1821,7 +1944,7 @@
    \end{yquant}
 \end{tikzpicture}
                   \end{codeexample}
-                  Measurement with bottom output are not supported (yet).
+                  Measurement with vertical output are not supported (yet).
                   Repositioning the initial labels needs some care and manual fine\hyp tuning.
                \end{example}
                
@@ -1915,8 +2038,9 @@
       ["$0$/$1$", type=qubit]
       measure a;
       
-      \yquantset{every wire/.append style={->}, operator/separation=5mm}
+      addstyle {->} a;
       output {$\ket1$} a;
+      \yquantset{operator/separation=5mm}
    \end{yquant}
 \end{tikzpicture}
                   \end{codeexample*}
@@ -1926,9 +2050,8 @@
                   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.
+                  In order to change the style of an individual wire, we use \gate{addstyle} as of version~0.1.2.
+                  To make the final line smaller, we change the operator separation by issuing \tex!\yquantset! at the end.
                \end{example}
                
                \begin{example}
@@ -2003,6 +2126,7 @@
                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.
+               Still, this is inferior to a wire drawn by \Yquant, as it does not use clippings: the connection with the \gate{cnot} gate may not be accurate; in particular, if the wire is of a different color or if you need to draw classical or bundle wires, the connection will become unpleasant.
             \end{example}
             
             \begin{example}
@@ -2122,11 +2246,11 @@
       cbit d;
       qubit e;
       box {$U$} (-);
-      setwire {qubit} c;
+      settype {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.
+                  This example for the first time demonstrates the declaration of a non\hyp existing register and the \gate{settype} pseudo\hyp gate that acts as a zero\hyp width, no\hyp content \gate{init} gate.
                \end{example}
             
          \clearpage
@@ -2195,7 +2319,7 @@
 \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.
+               However, the \texttt{yquant-line} 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.
@@ -2387,7 +2511,7 @@
             \paragraph{D. Scaling}\leavevmode
                \begin{example}
                   \begin{codeexample*}
-\begin{tikzpicture}[scale=1.5, every node/.append style={scale=1.5}]
+\begin{tikzpicture}[scale=1.5, every label/.append style={scale=1.5}]
    \begin{yquant*}
       h a;
       phase {$\beta$} a;
@@ -2396,7 +2520,8 @@
 \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.
+                  The default style for \style{/yquant/every circuit} sets the \texttt{transform shape} key for every node (which means any gate), so that those are also scaled.
+                  This is explicitly undone for \texttt{label}s due to \TikZ{} bug \href{https://github.com/pgf-tikz/pgf/issues/843}{\#843}, so the scaling must be specified explicitly for the \texttt{label}s.
                \end{example}
          
          \subsubsection{VII. Typesetting}
@@ -2448,7 +2573,7 @@
    \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.
+                  \Yquant{} properly splits discontiguous multi\hyp qubit operations as of version~0.1.2.
                \end{example}
             
             \paragraph{B. Per-Gate Styling}\leavevmode
@@ -2495,10 +2620,10 @@
                   \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.
+                  Additionally, \Yquant{} shapes must implement clipping paths.
+                  Those objects, which are a \Yquant{} addition to \TikZ{} allow \Yquant{} to properly clip wires and vertical lines to the shape of the gate.
+                  \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 (modulo clipping).
+                  To avoid the issues, we construct an invisible box operator and name it; \emph{outside} of the \tex!yquant! environment, we \texttt{fit} the special \TikZ{} shape on top of it.
                \end{example}
                
             \paragraph{C. Boxing/Highlighting Parts of a Circuit}\leavevmode
@@ -2551,6 +2676,7 @@
                
                \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.
+               Maybe even a multi\hyp swap gate using the \texttt{knots} library would be possible.
                
          \clearpage
          \subsubsection{VIII. Otherwise undocumented features}
@@ -2615,14 +2741,6 @@
             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.
@@ -2647,5 +2765,13 @@
          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.
+      
+      \subsection{2020-04-11: Version 0.1.2}
+         Introduce \gate{setstyle} and \gate{addstyle} pseudo\hyp gates that allow to style individual wires; rename \gate{setwire} to \gate{settype} (the old name is still available and shows a deprecation warning). \\
+         Complete rewrite of the way \Yquant{} draws wires; projection anchors are removed in favor of clipping paths.
+         This allows perfect connections between gates and wires, even if the (rather rectangular) wire lines meets with nonplanar shapes, while still preserving the possibility of transparent wires. \\
+         \Yquant{} now also properly draws non\hyp contiguous multi\hyp qubit operations. \\
+         New gate: \gate{correlate}.
+         Various bug fixes.
 %END_FOLD
 \end{document}
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex	2020-04-14 21:06:20 UTC (rev 54736)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex	2020-04-14 21:06:44 UTC (rev 54737)
@@ -1,222 +1,146 @@
 % 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.
+% 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}%
+\long\def\@firstoffour#1#2#3#4{#1}%
+\long\def\@secondoffour#1#2#3#4{#2}%
+\long\def\@thirdoffour#1#2#3#4{#3}%
+\long\def\@fourthoffour#1#2#3#4{#4}%
+\long\def\@thirdandfourthoffour#1#2#3#4{#3#4}%
+
+% extends the wire of register #1. Assumes a node called yquantbox is set up, and the \pgfshapeclippathhorzresult was set up appropriately for this node.
 \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}%
+      \pgfpointanchor{yquantbox}{center}%
+      \edef\wirexpos{\the\pgf at x}%
+      \yquant at register@get at typeywire{#1}\wiretype\wireypos\wirelast%
+      \edef\wirexprevpos{\expandafter\@firstoffour\wirelast}%
+      \ifnum\wiretype=\yquant at register@type at none%
+         % the clippings of the previous operator will for sure not be needed, but the type might be turned into an active one, so we need the last clipping.
+         \yquant at register@set at lastwire{#1}{%
+            {\wirexprevpos}{\wirexpos}{}%
+            {\unexpanded\expandafter{\pgfshapeclippathhorzresult}}%
+         }%
+      \else%
+         % append the previous `last' clipping to the old list and insert the new one
+         \yquant at register@set at lastwire{#1}{%
+            {\wirexprevpos}{\wirexpos}%
+            {\unexpanded\expandafter\expandafter\expandafter{%
+                \expandafter\@thirdandfourthoffour\wirelast%
+             }%
+            }
+            {\unexpanded\expandafter{\pgfshapeclippathhorzresult}}%
+         }%
       \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%
+% finishes the wire of registers 1 to #1 until x position \yquant at env@end at xpos
+\protected\def\yquant at circuit@endwires#1{%
+   \yquant at for \yquant at circuit@endwires at i := 1 to #1 {
+      \yquant at draw@wire\yquant at circuit@endwires at i\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);%
+% outputs the wire according to its previous instructions and prepares for a change in the wire style
+\protected\def\yquant at circuit@flushwire#1{%
+   \yquant at draw@wire{#1}{}%
+   \begingroup%
+      \yquant at register@get at lastwire{#1}\wirelast%
+      \yquant at register@set at lastwire{#1}{%
+         {\expandafter\@secondoffour\wirelast}{\expandafter\@secondoffour\wirelast}{}%
+         {\unexpanded\expandafter\expandafter\expandafter{%
+             \expandafter\@fourthoffour\wirelast%
+          }}%
       }%
-      \cmd%
-   \fi%
+   \endgroup%
 }
-
-% 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.
+% populates a drawing macro with the current control line with style #1 at position #2. Assumes a node called yquantbox is set up, and the \pgfshapeclippathvertresult was set up appropriately for this node. 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%
+   \eappto\yquant at circuit@extendcontrolline at clip{%
+      \unexpanded\expandafter{\pgfshapeclippathvertresult}%
+   }%
    \expandafter\@tempdima\the\pgflinewidth%
    \ifcase#1%
       % no control (or to a discarded target, which we don't do)
    \or%
       % qubit
+      \pgfpointanchor{yquantbox}{center}%
       \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)%
+            -- (#2,\the\pgf at y)%
          }%
       \fi%
       \yquant at circuit@extendcontrolline at store{#2}%
    \or%
       % cbit
+      \pgfpointanchor{yquantbox}{center}%
       \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{%
+            -- (\the\dimexpr#2-2\@tempdima\relax,\the\pgf at y)%
             \expandafter\@thirdofthree\yquant at circuit@extendcontrolline at prev%
-            -- (\the\pgf at x,\the\pgf at y)%
+            -- (\the\dimexpr#2+2\@tempdima\relax,\the\pgf at y)%
          }%
       \fi%
       \yquant at circuit@extendcontrolline at store{#2}%
    \or%
       % quantum-bundle (very unusual, but perhaps for transversal operations?)
+      \pgfpointanchor{yquantbox}{center}%
       \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{%
+            -- (\the\dimexpr#2-2\@tempdima\relax,\the\pgf at y)%
             \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{%
+            -- (\the\dimexpr#2\relax,\the\pgf at y)%
             \expandafter\@thirdofthree\yquant at circuit@extendcontrolline at prev%
-            -- (\the\pgf at x,\the\pgf at y)%
+            -- (\the\dimexpr#2+2\@tempdima\relax,\the\pgf at y)%
          }%
       \fi%
       \yquant at circuit@extendcontrolline at store{#2}%
    \else%
-      \PackageError{yquant.sty}{Invalid control line type `\the#1'}%
+      \PackageError{yquant.sty}{Invalid control line type `#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)}}%
+   \edef\yquant at circuit@extendcontrolline at prev{%
+      {(\the\dimexpr#1-2\@tempdima\relax,\the\pgf at y)}%
+      {(\the\dimexpr#1\relax,\the\pgf at y)}%
+      {(\the\dimexpr#1+2\@tempdima\relax,\the\pgf at y)}%
+   }%
 }
+
+% populates a drawing macro with the multi operation connector at position #2. Assumes a node called yquantbox is set up, and the \pgfshapeclippathvertresult was set up appropriately for this node. At the first call, \yquant at circuit@extendmultiline at cmd must be \let to \empty and \yquant at circuit@extendmultiline at prev to \relax.
+\protected\def\yquant at circuit@extendmultiline#1{%
+   \begingroup%
+      \tikzset{/yquant/every multi line}%
+      \expandafter%
+   \endgroup%
+   \eappto\yquant at circuit@extendmultiline at clip{%
+      \unexpanded\expandafter{\pgfshapeclippathvertresult}%
+   }%
+   \expandafter\@tempdima\the\pgflinewidth%
+   \pgfpointanchor{yquantbox}{center}%
+   \unless\ifx\yquant at circuit@extendmultiline at prev\relax%
+      \eappto\yquant at circuit@extendmultiline at cmd{%
+         \yquant at circuit@extendmultiline at prev -- (#1,\the\pgf at y)%
+      }%
+   \fi%
+   \edef\yquant at circuit@extendmultiline at prev{%
+      (\the\dimexpr#1\relax,\the\pgf at y)%
+   }%
+}
 % END_FOLD
 
 \newif\ifyquant at circuit@operator at hasControls%
@@ -364,9 +288,20 @@
 % 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%
+   \yquant at circuit@flushwire{#1}%
+   \yquant at register@set at type{#1}{\yquant at circuit@settype at to}%
 }
 
+\protected\long\def\yquant at circuit@setstyle#1#2{%
+   \yquant at circuit@flushwire{#1}%
+   \yquant at register@set at style{#1}{#2}%
+}
+
+\protected\long\def\yquant at circuit@addstyle#1#2{%
+   \yquant at circuit@flushwire{#1}%
+   \yquant at register@set at style{#1}{\yquant at register@get at style{#1},#2}%
+}
+
 % 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{%
@@ -393,10 +328,11 @@
    \endgroup%
 }
 
-% sets the type of a list of registers
-% #1: arbitrary register list
-% #2: new type
-\protected\def\yquant at circuit@settypes#1#2{%
+% applies an action to wires a list of registers and causes them to be redrawn
+% #1: action
+% #2: arbitrary register list
+% #3: parameter(s)
+\protected\def\yquant at circuit@actonwires#1#2#3{%
    \begingroup%
       \let\tmp=\empty%
       \def\do##1{%
@@ -403,9 +339,9 @@
          % 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}%
+         \appto\tmp{#1{##1}#3}%
       }%
-      \dolistloop{#1}%
+      \dolistloop{#2}%
       \csxappto{\yquant at prefix draw}{\tmp}%
    \endgroup%
 }
@@ -434,12 +370,12 @@
                   {\yquant at circuit@output at do@single{##1}{#3}}%
       }%
    }%
+   \csgappto{\yquant at prefix draw}{%
+      \yquant at circuit@output at group{#2}%
+   }
    % \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%
@@ -447,7 +383,7 @@
 }
 
 \def\yquant at circuit@output at do@multi@@extract#1#2#3#4#5{%
-   {#2}{#3}%
+   {#2}{#3}{#5}%
 }
 
 \protected\long\def\yquant at circuit@output at group#1{%
@@ -462,15 +398,27 @@
    \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};
+           /yquant/every \ifcase\yquant at register@get at type{#1} nobit\or 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{%
+\long\def\yquant at circuit@output at do@multi#1#2#3#4{%
+   % extremely similar to \yquant at draw@multiinit
+   \@tempdima=-.5\dimexpr\yquant at config@register at sep\relax%
+   \dimdef\yquant at draw@multiinit@@min{\yquant at register@get at y{#1}-\@tempdima}%
+   \dimdef\yquant at draw@multiinit@@max{\yquant at register@get at y{#2}+\@tempdima}%
+   \dimdef\yquant at draw@multiinit@@total{%
+      \yquant at draw@multiinit@@max-\yquant at draw@multiinit@@min%
+   }%
+   \def\pgfdecorationsegmentaspect{0}%
+   \let\yquant at register@multi at contiguous=\yquant at draw@multiinit at contiguous%
+   \let\pgfdecorationsegmentfromto=\empty%
+   #3%
+   \edef\pgfdecorationsegmentfromto{\expandafter\@gobble\pgfdecorationsegmentfromto}%
    \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};%
+      (\yquant at env@end at xpos, \yquant at draw@multiinit@@min) --
+      (\yquant at env@end at xpos, \yquant at draw@multiinit@@max)
+      node {#4};%
    \numdef\idx{\idx+1}%
 }
 % END_FOLD
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/latex/yquant/yquant-config.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-config.tex	2020-04-14 21:06:20 UTC (rev 54736)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-config.tex	2020-04-14 21:06:44 UTC (rev 54737)
@@ -1,4 +1,3 @@
-\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}}}
@@ -15,7 +14,10 @@
    }
 }
 \pgfqkeys{/yquant}{
-   every circuit/.style={},
+   every circuit/.style={%
+      every node/.prefix style={transform shape},%
+      every label/.prefix style={transform shape=false}% TODO: no, we don't really want this, but pgf bug #843 requires this if we still want to have `label position` available
+   },
    % register settings
    register/default name/.store in=%
       \yquant at config@register at default@name,
@@ -25,7 +27,7 @@
       {\dimdef\yquant at config@register at sep{#1}},
    % register label style
    every label/.style=%
-      {shape=yquant-text, anchor=circuit, align=right},
+      {shape=yquant-text, anchor=center, align=right},
    every initial label/.style=%
       {anchor=east},
    every qubit label/.style=%
@@ -35,8 +37,8 @@
    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)}}},
+      {shift={(-.075, 0)}, draw, decoration={gapped brace, mirror}, decorate, /yquant/gapped brace/apply shift,
+       every node/.append style={shape=yquant-text, anchor=east, align=right, shift={(-.05, 0)}, pos=-1}},
    % output label styles
    every output/.style=%
       {shape=yquant-text, anchor=west, align=left},
@@ -47,8 +49,8 @@
    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)}}},
+      {shift={(.075, 0)}, draw, decoration={gapped brace}, decorate, /yquant/gapped brace/apply shift,
+       every node/.append style={shape=yquant-text, anchor=west, align=left, shift={(.05, 0)}, pos=-1}},
    % wire style
    every wire/.style=%
       {draw},
@@ -63,11 +65,13 @@
       {\dimdef\yquant at config@operator at sep{#1}},
    operator/minimum width/.code=%
       {\dimdef\yquant at config@operator at minimum@width{#1}},
+   operator/multi warning/.is if=%
+      yquant at config@operator at multi@warn,
    % operator style: control
    every control line/.style=%
       {draw},
    every control/.style=%
-      {shape=yquant-circle, anchor=circuit, radius=.5mm},
+      {shape=yquant-circle, anchor=center, radius=.5mm},
    every positive control/.style=%
       {fill=black},
    every negative control/.style=%
@@ -74,7 +78,13 @@
       {draw},
    % operator style: main part
    every operator/.style=%
-      {anchor=circuit},
+      {anchor=center},
+   operator/multi main/.is if=%
+      yquant at config@operator at multi@main,
+   operator/multi as single/.style=%
+      {/yquant/every multi line/.style=/yquant/every control line},
+   every multi line/.style=%
+      {draw, decoration={snake, amplitude=.25mm, segment length=5pt}, decorate},
    % overwriting all styles
    this operator/.style=%
       {},
@@ -107,17 +117,13 @@
    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},
+      {shape=yquant-circle, radius=.5mm, fill},
    operators/every xx/.style=%
-      % same as zz
-      {shape=yquant-xx, x radius=.75mm, y radius=1.5mm, draw},
+      {shape=yquant-rectangle, radius=.75mm, 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},
+      {shape=yquant-swap, radius=.75mm, draw},
    operators/every not/.style=%
       {shape=yquant-oplus, radius=1.3mm, draw},
    operators/every measure/.style=%
@@ -127,8 +133,13 @@
    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,
+      {shape=yquant-line, dashed, draw},
+   operators/every wave/.style=%
+      {shape=yquant-circle, radius=.5mm, fill},
+   /pgf/decoration/from to/.store in=\pgfdecorationsegmentfromto,
+   gapped brace/apply shift/.code={%
+      \let\tikz at timer@line=\yquant at gappedbrace@timer%
+   },
 }
 
 \def\yquant at config@register at default@name{\regidx}
@@ -136,5 +147,142 @@
 \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
+\newif\ifyquant at config@operator at multi@main%
+\yquant at config@operator at multi@maintrue
+\newif\ifyquant at config@operator at multi@warn
+\yquant at config@operator at multi@warntrue
+\def\pgfdecorationsegmentfromto{0-1}%
+
+\protected\def\yquant at gappedbrace@extract#1-#2\yquant at sep{%
+   \dimdef\from{#1\pgfdecoratedremainingdistance}%
+   \dimdef\to{#2\pgfdecoratedremainingdistance}%
+}
+% This function is set to replace the transformation that changes the fraction value specified in the node property pos by a computation of the correct value for the gappedbrace decoration. It thus requires \pgfdecorationsegmentfromto to be already set up properly. Only if the special position -1 is given, these transformations are applied; else, the default behavior is reproduced (\tikz at timer@line).
+\protected\def\yquant at gappedbrace@timer{%
+   \ifdim\tikz at time pt=-1pt %
+      % first set \pgfdecoratedremainingdistance appropriately
+      \pgfpointdiff\tikz at timer@start\tikz at timer@end%
+      \pgfmathsqrt@{\dimexpr\pgf at x*\pgf at x/65536+\pgf at y*\pgf at y/65536\relax\@gobbletwo}
+      \pgfdecoratedremainingdistance=\pgfmathresult pt %
+      % now perform the transformation
+      \pgf at xc=\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance%
+      \expandafter\forcsvlist\expandafter\yquant at gappedbrace@shiftloop%
+         \expandafter{\pgfdecorationsegmentfromto}%
+      % and finally let us return the desired position, just ignoring \tikz at time...
+      \pgftransformlineattime{\pgfdecorationsegmentaspect}{\tikz at timer@start}{\tikz at timer@end}%
+   \else%
+      \pgftransformlineattime{\tikz at time}{\tikz at timer@start}{\tikz at timer@end}%
+   \fi%
+}
+\def\yquant at gappedbrace@shiftloop#1{%
+   \yquant at gappedbrace@extract#1\yquant at sep%
+   \unless\ifdim\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance<\from %
+      \unless\ifdim\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance>\to %
+         % be careful about arch positions at the border
+         \ifdim\dimexpr\to-\from\relax<2\pgfdecorationsegmentamplitude %
+            % The arch is larger than the segment. We do not draw a line to it or an end line and place it in the mid of the segment, even if it is too short (this issues one extra \pgfpathmoveto command, but catching this rare case is not worth the effort).
+            \edef\pgfdecorationsegmentaspect{\pgfmath at tonumber{\dimexpr%
+               .5\dimexpr\from+\to\relax*65536/\pgfdecoratedremainingdistance%
+            \relax}}%
+         \else%
+            % The segment is large enough to cover the whole arch. But maybe we are too close at the border?
+            \ifdim\dimexpr\pgf at xc-\pgfdecorationsegmentamplitude\relax<\from %
+               \pgf at xc=\dimexpr\from+\pgfdecorationsegmentamplitude\relax%
+            \fi%
+            \ifdim\dimexpr\pgf at xc+\pgfdecorationsegmentamplitude\relax>\to %
+               \pgf at xc=\dimexpr\to-\pgfdecorationsegmentamplitude\relax%
+            \fi%
+            \edef\pgfdecorationsegmentaspect{\pgfmath at tonumber{\dimexpr%
+               \dimexpr\pgf at xc*65536/\pgfdecoratedremainingdistance%
+            \relax}}%
+         \fi%
+         \expandafter\expandafter\expandafter\listbreak%
+      \fi%
+   \fi%
+}
+\def\yquant at gappedbrace@loop#1{%
+   \yquant at gappedbrace@extract#1\yquant at sep%
+   \unless\ifdim\from=0pt %
+      \pgfpathmoveto{%
+         \pgfqpoint{\from}{.5\pgfdecorationsegmentamplitude}%
+      }%
+   \fi%
+   \unless\ifdim\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance<\from %
+      \unless\ifdim\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance>\to %
+         % be careful about arch positions at the border
+         \ifdim\dimexpr\to-\from\relax<2\pgfdecorationsegmentamplitude %
+            % The arch is larger than the segment. We do not draw a line to it or an end line and place it in the mid of the segment, even if it is too short (this issues one extra \pgfpathmoveto command, but catching this rare case is not worth the effort).
+            \pgfpathmoveto{%
+               \pgfqpoint{\dimexpr.5\dimexpr\from+\to\relax-\pgfdecorationsegmentamplitude\relax}%
+                         {.5\pgfdecorationsegmentamplitude}%
+            }%
+            \edef\to{\the\pgfdecoratedremainingdistance}% to prevent the final line, we do not need "to" any more
+         \else%
+            % The segment is large enough to cover the whole arch. But maybe we are too close at the border?
+            \ifdim\dimexpr\pgf at xc-\pgfdecorationsegmentamplitude\relax<\from %
+               \pgf at xc=\dimexpr\from+\pgfdecorationsegmentamplitude\relax%
+            \fi%
+            \ifdim\dimexpr\pgf at xc+\pgfdecorationsegmentamplitude\relax>\to %
+               \pgf at xc=\dimexpr\to-\pgfdecorationsegmentamplitude\relax%
+            \fi%
+            % Both cases can't occur at the same time in this \else clause.
+            \pgfpathlineto{%
+               \pgfqpoint{\dimexpr\pgf at xc-\pgfdecorationsegmentamplitude\relax}%
+                         {.5\pgfdecorationsegmentamplitude}%
+            }%
+         \fi%
+         \pgfpathcurveto{%
+            \pgfqpoint{\dimexpr\pgf at xc-.5\pgfdecorationsegmentamplitude\relax}%
+                      {.5\pgfdecorationsegmentamplitude}%
+         }{%
+            \pgfqpoint{\dimexpr\pgf at xc-.15\pgfdecorationsegmentamplitude\relax}%
+                      {.7\pgfdecorationsegmentamplitude}%
+         }{%
+            \pgfqpoint{\pgf at xc}{\pgfdecorationsegmentamplitude}%
+         }%
+         \pgfpathcurveto{%
+            \pgfqpoint{\dimexpr\pgf at xc+.15\pgfdecorationsegmentamplitude\relax}%
+                      {.7\pgfdecorationsegmentamplitude}%
+         }{%
+            \pgfqpoint{\dimexpr\pgf at xc+.5\pgfdecorationsegmentamplitude\relax}%
+                      {.5\pgfdecorationsegmentamplitude}%
+         }{%
+            \pgfqpoint{\dimexpr\pgf at xc+\pgfdecorationsegmentamplitude\relax}%
+                      {.5\pgfdecorationsegmentamplitude}%
+         }%
+      \fi%
+   \fi%
+   \unless\ifdim\to=\pgfdecoratedremainingdistance %
+      \pgfpathlineto{%
+         \pgfqpoint{\to}{.5\pgfdecorationsegmentamplitude}%
+      }%
+   \fi%
+}
+% This is a variant of the brace in pathreplacing that allows for holes
+\pgfdeclaredecoration{gapped brace}{final}{%
+   \state{final}{%
+      \pgf at xc=\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance%
+      \pgfpathcurveto{%
+         \pgfqpoint{.15\pgfdecorationsegmentamplitude}{.3\pgfdecorationsegmentamplitude}%
+      }{%
+         \pgfqpoint{.5\pgfdecorationsegmentamplitude}{.5\pgfdecorationsegmentamplitude}%
+      }{%
+         \pgfqpoint{\pgfdecorationsegmentamplitude}{.5\pgfdecorationsegmentamplitude}%
+      }%
+      \expandafter\forcsvlist\expandafter\yquant at gappedbrace@loop%
+         \expandafter{\pgfdecorationsegmentfromto}%
+      \pgfpathlineto{%
+         \pgfqpoint{\dimexpr\pgfdecoratedremainingdistance-\pgfdecorationsegmentamplitude\relax}%
+                   {.5\pgfdecorationsegmentamplitude}%
+      }%
+      \pgfpathcurveto{%
+         \pgfqpoint{\dimexpr\pgfdecoratedremainingdistance-.5\pgfdecorationsegmentamplitude\relax}%
+                   {.5\pgfdecorationsegmentamplitude}%
+      }{%
+         \pgfqpoint{\dimexpr\pgfdecoratedremainingdistance-.15\pgfdecorationsegmentamplitude\relax}%
+                   {.3\pgfdecorationsegmentamplitude}%
+      }{%
+         \pgfqpoint{\pgfdecoratedremainingdistance}{0pt}%
+      }%
+   }%
+}%
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex	2020-04-14 21:06:20 UTC (rev 54736)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex	2020-04-14 21:06:44 UTC (rev 54737)
@@ -11,6 +11,8 @@
       \fi%
       \let\yquant at circuit@extendcontrolline at cmd=\empty%
       \let\yquant at circuit@extendcontrolline at prev=\relax%
+      \let\yquant at circuit@extendcontrolline at clip=\empty%
+      \let\yquant at circuit@extendmultiline at total=\empty%
       \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%
@@ -47,6 +49,7 @@
          \yquant at draw@alias at ctrl{#2}p%
          \yquant at draw@alias at ctrl{#2}n%
       \fi%
+      \yquant at circuit@extendmultiline at total%
    \endgroup%
 }
 
@@ -57,22 +60,42 @@
          node[/yquant/every operator, \yquant at draw@@style, /yquant/this operator,%
               name prefix=, name suffix=, name=yquantbox]%
          {\unexpanded\expandafter{\yquant at draw@@content}};%
+      \pgfshapeclippath{yquantbox}%
+                       {/yquant/every operator, \yquant at draw@@style,%
+                        /yquant/this operator}%
    }%
    \cmd%
-   \ifpgfpointshapexproj{yquantbox}%
-      \yquant at circuit@extendwire{#1}%
-   \fi%
-   \yquant at circuit@extendcontrolline\yquant at draw@@currentcontroltype\yquant at draw@@x%
+   \yquant at circuit@extendwire{#1}%
+   \expandafter\yquant at circuit@extendcontrolline\expandafter%
+      {\the\yquant at draw@@currentcontroltype}\yquant at draw@@x%
    % check for empty name parameter
-   \if\relax\detokenize{#2}\relax%
-   \else%
+   \ifstrempty{#2}\relax{%
       \pgfnodealias{\tikz at pp@name{#2}}{yquantbox}%
+   }%
+   \numdef\yquant at draw@@idx at content{\yquant at draw@@idx at content+1}%
+}
+
+\protected\def\yquant at draw@multi#1#2#3#4#5{%
+   \let\idx=\yquant at draw@@idx at content%
+   \edef\yquant at draw@multi@@name{#5}%
+   \def\yquant at draw@@idx at multipart{0}%
+   \let\yquant at circuit@extendmultiline at cmd=\empty%
+   \let\yquant at circuit@extendmultiline at prev=\relax%
+   \let\yquant at circuit@extendmultiline at clip=\empty%
+   \let\yquant at register@multi at contiguous=\yquant at draw@multi at contiguous%
+   #4%
+   \ifnum\yquant at draw@@idx at multipart>1 %
+      % make sure also the first split part is available via the "-s0" suffix
+      \unless\ifx\yquant at draw@multi@@name\empty%
+         \pgfnodealias{\tikz at pp@name{\yquant at draw@multi@@name-s0}}%
+                      {\tikz at pp@name{\yquant at draw@multi@@name}}%
+      \fi%
+      \yquant at draw@mline at prep%
    \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%
+\protected\def\yquant at draw@multi at contiguous#1#2#3{%
    % We need to somehow extract the y radius
    \edef\cmd{%
       \noexpand\path (\yquant at draw@@x, \the\dimexpr.5\dimexpr%
@@ -79,46 +102,101 @@
                          \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,%
+              /yquant/operator/multi main=\ifnum#3=1 true\else false\fi\unless\ifnum#1=#2 ,%
               y radius/.expanded=\the\dimexpr.5\dimexpr\yquant at register@get at ydist{#1}{#2}\relax\relax+%
-                     .5*\noexpand\pgfkeysvalueof{/tikz/y radius},%
+                     .5*\noexpand\pgfkeysvalueof{/tikz/y radius}\fi,%
               name prefix=, name suffix=, name=yquantbox]%
             {\unexpanded\expandafter{\yquant at draw@@content}};
+      \pgfshapeclippath{yquantbox}%
+                       {/yquant/every operator, \yquant at draw@@style,%
+                        /yquant/this operator}%
    }%
    \cmd%
-   \ifpgfpointshapexproj{yquantbox}%
-      \let\do=\yquant at circuit@extendwire%
-      \dolistloop{#4}%
+   \yquant at for \i := #1 to #2 {%
+      \yquant at circuit@extendwire\i%
+   }%
+   \yquant at circuit@extendmultiline\yquant at draw@@x%
+   \expandafter\yquant at circuit@extendcontrolline\expandafter%
+      {\the\yquant at draw@@currentcontroltype}\yquant at draw@@x%
+   \unless\ifx\yquant at draw@multi@@name\empty%
+      \ifnum\yquant at draw@@idx at multipart=0 %
+         \pgfnodealias{\tikz at pp@name{\yquant at draw@multi@@name}}{yquantbox}%
+      \else%
+         \pgfnodealias{\tikz at pp@name{\yquant at draw@multi@@name-s\yquant at draw@@idx at multipart}}{yquantbox}%
+      \fi%
    \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}%
+   \numdef\yquant at draw@@idx at multipart{\yquant at draw@@idx at multipart+1}%
 }
 
-\protected\long\def\yquant at draw@multiinit#1#2#3#4#5{%
+\protected\def\yquant at draw@multiinit#1#2#3#4#5{%
    \let\idx=\yquant at draw@@idx at content%
+   \@tempdima=-.5\dimexpr\yquant at config@register at sep\relax%
+   \dimdef\yquant at draw@multiinit@@min{\yquant at register@get at y{#1}-\@tempdima}%
+   \dimdef\yquant at draw@multiinit@@max{\yquant at register@get at y{#2}+\@tempdima}%
+   \dimdef\yquant at draw@multiinit@@total{%
+      \yquant at draw@multiinit@@max-\yquant at draw@multiinit@@min%
+   }%
+   \def\pgfdecorationsegmentaspect{0}%
+   \let\yquant at register@multi at contiguous=\yquant at draw@multiinit at contiguous%
+   \let\pgfdecorationsegmentfromto=\empty%
+   #4%
+   \edef\pgfdecorationsegmentfromto{\expandafter\@gobble\pgfdecorationsegmentfromto}%
    % 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})%
+         (\yquant at draw@@x, \yquant at draw@multiinit@@min) --%
+         (\yquant at draw@@x, \yquant at draw@multiinit@@max)%
          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)
+   % 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), no multi line
    % check for empty name parameter
-   \if\relax\detokenize{#5}\relax%
-   \else%
+   \ifstrempty{#5}\relax{%
       \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@multiinit at contiguous#1#2#3{%
+   \edef\yquant at draw@multiinit@@from{%
+      \pgfmath at tonumber{\dimexpr%
+         \dimexpr\yquant at register@get at y{#1}-\@tempdima-\yquant at draw@multiinit@@min\relax*65536/%
+         \dimexpr\yquant at draw@multiinit@@total\relax%
+      \relax}%
+   }%
+   \edef\yquant at draw@multiinit@@to{%
+      \pgfmath at tonumber{\dimexpr%
+         \dimexpr\yquant at register@get at y{#2}+\@tempdima-\yquant at draw@multiinit@@min\relax*65536/%
+         \dimexpr\yquant at draw@multiinit@@total\relax%
+      \relax}%
+   }%
+   \eappto\pgfdecorationsegmentfromto{,%
+      \yquant at draw@multiinit@@from-\yquant at draw@multiinit@@to%
+   }%
+   % We need to decide where to put the brace arch.
+   \ifdim\yquant at draw@multiinit@@from pt<.5pt %
+      \ifdim\yquant at draw@multiinit@@to pt>.5 pt%
+         % This segment covers the true 1/2 position, take it
+         \def\pgfdecorationsegmentaspect{.5}%
+      \else%
+         % We are not there yet, so the end of this segment is the closest we can get to the mid so far
+         \edef\pgfdecorationsegmentaspect{\yquant at draw@multiinit@@to}%
+      \fi%
+   \else%
+      % We are already beyond the mid...
+      \ifdim\pgfdecorationsegmentaspect pt<.5pt %
+         % ...but we did not find an ideal position yet
+         \ifdim\dimexpr\yquant at draw@multiinit@@from pt-.5pt\relax<%
+            \dimexpr.5pt-\pgfdecorationsegmentaspect pt\relax%
+            % this one is closer to the mid than anything found before
+            \edef\pgfdecorationsegmentaspect{\yquant at draw@multiinit at from}%
+         \fi%
+      \fi%
+   \fi%
+}
+
 \protected\def\yquant at draw@control#1#2#3{%
    \edef\cmd{%
       \noexpand\path (\yquant at draw@@x, \yquant at register@get at y{#2})%
@@ -125,18 +203,19 @@
          node[/yquant/every control, /yquant/every #1 control, /yquant/this control,%
               name prefix=, name suffix=, name=yquantbox]%
          {};%
+      \pgfshapeclippath{yquantbox}%
+                       {/yquant/every control, /yquant/every #1 control,%
+                        /yquant/this control}%
    }%
    \cmd%
-   \ifpgfpointshapexproj{yquantbox}%
-      \yquant at circuit@extendwire{#2}%
-   \fi%
+   \yquant at circuit@extendwire{#2}%
    \yquant at draw@@currentcontroltype=\yquant at register@get at type{#2}\relax%
-   \yquant at circuit@extendcontrolline\yquant at draw@@currentcontroltype\yquant at draw@@x%
+   \expandafter\yquant at circuit@extendcontrolline\expandafter%
+      {\yquant at draw@@currentcontroltype}\yquant at draw@@x%
    % check for empty name parameter
-   \if\relax\detokenize{#3}\relax%
-   \else%
+   \ifstrempty{#3}\relax{%
       \pgfnodealias{\tikz at pp@name{#3}}{yquantbox}%
-   \fi%
+   }%
 }
 
 \protected\def\yquant at draw@pcontrol#1#2{%
@@ -152,13 +231,64 @@
 }
 
 \protected\def\yquant at draw@cline{%
-   \edef\cmd{%
-      \noexpand\path[/yquant/every control line]%
-         \yquant at circuit@extendcontrolline at cmd;
+   \pgfscope%
+      % install the clipping
+      \pgfsyssoftpath at setcurrentpath\yquant at circuit@extendcontrolline at clip%
+      % and invert it. It is sufficient to cover the current bounding box, as the wire will be drawn between existing operators.
+      \ifyquantdebug%
+         \pgfsetfillcolor{teal}%
+         \pgfsetfillopacity{.3}%
+         \pgfusepathqfill%
+      \else%
+         \begingroup%
+            \pgftransformreset%
+            \pgfpathrectanglecorners%
+               {\pgfqpoint{\pgf at picminx}{\pgf at picminy}}%
+               {\pgfqpoint{\pgf at picmaxx}{\pgf at picmaxy}}%
+            \pgfseteorule% even-odd to properly invert the clipping
+            \pgfusepathqclip%
+         \endgroup%
+      \fi%
+      \edef\cmd{%
+         \noexpand\path[/yquant/every control line]%
+            \yquant at circuit@extendcontrolline at cmd;
+      }%
+      \cmd%
+   \endpgfscope%
+}
+
+\protected\def\yquant at draw@mline at prep{%
+   \eappto\yquant at circuit@extendmultiline at total{%
+      \yquant at draw@mline%
+         {\unexpanded\expandafter{\yquant at circuit@extendmultiline at clip}}%
+         {\yquant at circuit@extendmultiline at cmd}%
    }%
-   \cmd%
 }
 
+\protected\def\yquant at draw@mline#1#2{%
+   \pgfscope%
+      % install the clipping
+      \def\pgfsyssoftpath at thepath{#1}%
+      \pgfsyssoftpath at setcurrentpath\pgfsyssoftpath at thepath%
+      % and invert it. It is sufficient to cover the current bounding box, as the wire will be drawn between existing operators.
+      \ifyquantdebug%
+         \pgfsetfillcolor{teal}%
+         \pgfsetfillopacity{.3}%
+         \pgfusepathqfill%
+      \else%
+         \begingroup%
+            \pgftransformreset%
+            \pgfpathrectanglecorners%
+               {\pgfqpoint{\pgf at picminx}{\pgf at picminy}}%
+               {\pgfqpoint{\pgf at picmaxx}{\pgf at picmaxy}}%
+            \pgfseteorule% even-odd to properly invert the clipping
+            \pgfusepathqclip%
+         \endgroup%
+      \fi%
+      \path[/yquant/every multi line] #2;
+   \endpgfscope%
+}
+
 \protected\def\yquant at draw@alias#1{%
    \pgfnodealias{\tikz at pp@name{#1}}{\tikz at pp@name{#1-0}}%
 }
@@ -166,6 +296,106 @@
 \protected\def\yquant at draw@alias at ctrl#1#2{%
    \pgfnodealias{\tikz at pp@name{#1-#2}}{\tikz at pp@name{#1-#20}}%
 }
+
+\protected\def\yquant at draw@wire#1#2{%
+   \begingroup%
+      \yquant at register@get at typeywire{#1}\wiretype\wireypos\wirelast%
+      \edef\wirexprevpos{\expandafter\@firstoffour\wirelast}%
+      \ifx\yquant at env@end at xpos#2\relax%
+         \let\wirexpos=\yquant at env@end at xpos%
+      \else%
+         \edef\wirexpos{\expandafter\@secondoffour\wirelast}%
+      \fi%
+      \unless\ifnum\wiretype=\yquant at register@type at none%
+         \ifdim\wirexpos>\wirexprevpos %
+            \edef\wirestyle{\noexpand\tikzset{%
+               /yquant/this wire/.style={%
+                  /yquant/every wire,%
+                  /yquant/every \ifcase\wiretype\relax nobit\or qubit \or cbit \or qubits \fi wire,%
+                     \yquant at register@get at style{#1}%
+               }, /yquant/this wire%
+            }}%
+            \wirestyle%
+            % load all clippings
+            \edef\wireclipping{%
+               \unexpanded\expandafter\expandafter\expandafter{%
+                  \expandafter\@thirdandfourthoffour\wirelast%
+               }%
+            }%
+            \pgfscope%
+               % install the clipping
+               \pgfsyssoftpath at setcurrentpath\wireclipping%
+               % invert the clipping
+               \ifyquantdebug%
+                  \pgfsetfillcolor{orange}%
+                  \pgfsetfillopacity{.3}%
+                  \pgfusepathqfill%
+               \else%
+                  % We need to access the current bounding box as well as other positions in the local coordinate frame. For this, transform the bounding box to the current frame (though this is expensive). Does this capture rotations correctly?
+                  \begingroup%
+                     \pgftransforminvert%
+                     \pgfpointtransformednonlinear{\pgfqpoint{\pgf at picminx}{\pgf at picminy}}
+                     \global\@tempdima=\pgf at y%
+                     \pgfpointtransformednonlinear{\pgfqpoint{\pgf at picmaxx}{\pgf at picmaxy}}%
+                     \global\@tempdimb=\pgf at y%
+                  \endgroup%
+                  % To avoid rendering artifacts at all zoom levels with all renderers, we need to make the clipping region large. Let's try the current bounding box first.
+                  % This may be insufficient if there no or a tiny wire label and only registers of a small height. In this case, take at ten times the line width or at least 1cm, but don't let it affect the bounding box.
+                  \ifdim\dimexpr\@tempdimb-\@tempdima\relax<10\pgflinewidth %
+                     \@tempdima=\dimexpr\wireypos-5\pgflinewidth\relax%
+                     \@tempdimb=\dimexpr\wireypos+5\pgflinewidth\relax%
+                  \fi%
+                  \ifdim\dimexpr\@tempdimb-\@tempdima\relax<1cm %
+                     \@tempdima=\dimexpr\wireypos-5mm\relax%
+                     \@tempdimb=\dimexpr\wireypos+5mm\relax%
+                  \fi%
+                  \pgfinterruptboundingbox%
+                     \pgfpathrectanglecorners%
+                        {\pgfqpoint{\dimexpr\wirexprevpos-2\pgflinewidth\relax}%
+                                   {\@tempdima}}%
+                        {\pgfqpoint{\dimexpr\wirexpos+2\pgflinewidth\relax}%
+                                   {\@tempdimb}}%
+                  \endpgfinterruptboundingbox%
+                  \pgfseteorule% even-odd to properly invert the clipping
+                  \pgfusepathqclip%
+               \fi%
+               % the clip inversion is left to the drawing commands (clip two \pgflinewidth more to avoid renderer artifacts)
+               \csname yquant at draw@wire@\wiretype\endcsname{#1}%
+            \endpgfscope%
+         \fi%
+      \fi%
+   \endgroup%
+}
+
+% quantum wire
+\protected\csdef{yquant at draw@wire@\yquant at register@type at q}#1{%
+   \edef\cmd{%
+      \noexpand\path [/yquant/this wire]
+         (\wirexprevpos,\wireypos) -- (\wirexpos,\wireypos);%
+   }%
+   \cmd%
+}
+
+% classical wire
+\protected\csdef{yquant at draw@wire@\yquant at register@type at c}#1{%
+   \edef\cmd{%
+      \noexpand\path [/yquant/this wire]
+         (\wirexprevpos,\wireypos+2\pgflinewidth)--(\wirexpos,\wireypos+2\pgflinewidth)%
+         (\wirexprevpos,\wireypos-2\pgflinewidth)--(\wirexpos,\wireypos-2\pgflinewidth);%
+   }%
+   \cmd%
+}
+
+% quantum-bundle
+\protected\csdef{yquant at draw@wire@\yquant at register@type at qs}#1{%
+   \edef\cmd{%
+      \noexpand\path [/yquant/this wire]
+         (\wirexprevpos,\wireypos+2\pgflinewidth)--(\wirexpos,\wireypos+2\pgflinewidth)%
+         (\wirexprevpos,\wireypos)--(\wirexpos,\wireypos)%
+         (\wirexprevpos,\wireypos-2\pgflinewidth)--(\wirexpos,\wireypos-2\pgflinewidth);%
+   }%
+   \cmd%
+}
 % END_FOLD
 
 % BEGIN_FOLD Preparation of drawing a generic shape
@@ -274,7 +504,7 @@
    \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.
+      % If we draw a control line, all intermediate registers are affected in their position so that the line is never crossed. If the vertical line is instead caused by a multi register, \yquant at draw@finalize at ctrl will be responsible for advancing only the affected positions.
       \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}%
       }%
@@ -354,16 +584,41 @@
          #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?)
+   % Determining the actual height is a problem - where to store its value? If there are single-register parts, we update the height accordingly; else we just assume that there is always enough space for such a control, since it anyways 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};
+      \def\yquant at draw@@content{#1}%
+      \def\yquant at draw@@style{#2}%
+      \let\yquant at register@multi at contiguous=\yquant at draw@@multi at contiguous%
+      \@fifthoffive#3%
+      \ifdim\pgf at picmaxy=-16000pt %
+         % if there was no single contiguous part before, determine the width now
+         \path%
+            (0pt, 0pt)
+            node[/yquant/every operator, #2, /yquant/this operator,%
+                 name prefix=, name suffix=, name=] {#1};
+      \fi%
 }
 
+\protected\def\yquant at draw@@multi at contiguous#1#2#3{%
+   \ifnum#1=#2 %
+      % we only care about single-register parts
+      \global\pgf at picmaxy=-16000pt %
+      \global\pgf at picminy=16000pt %
+      \edef\cmd{%
+         \noexpand\path (0pt, 0pt)%
+            node[/yquant/every operator, \yquant at draw@@style, /yquant/this operator,%
+                 /yquant/operator/multi main=\ifnum#3=1 true\else false\fi,
+                 name prefix=, name suffix=, name=]%
+               {\unexpanded\expandafter{\yquant at draw@@content}};
+      }%
+      \cmd%
+      \yquant at register@update at height{#1}{%
+         \the\dimexpr\pgf at picmaxy-\pgf at picminy\relax%
+      }%
+   \fi%
+}
+
 \protected\def\yquant at draw@@multiinit#1#2#3{%
    \yquant at sort@eadd{%
       \yquant at draw@multiinit%
@@ -373,11 +628,10 @@
    % 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};
+         node[/yquant/every operator, #2, /yquant/every multi label,%
+              name prefix=, name suffix=, name=] {#1};
 }
 
 \def\yquant at draw@finalize at ctrl#1{%
@@ -401,6 +655,12 @@
    }%
 }
 
+\protected\def\yquant at draw@finalize at ctrl@singleinit#1#2{%
+   \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.
@@ -410,13 +670,57 @@
       }%
    }\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}%
+   \let\yquant at register@multi at contiguous=\yquant at draw@finalize at ctrl@multi at contiguous%
+   \ifyquant at circuit@operator at hasControls%
+      \ifyquant at config@operator at multi@warn%
+         \def\yquant at draw@finalize at ctrl@multi at contiguous@warn{0}%
+      \else%
+         \def\yquant at draw@finalize at ctrl@multi at contiguous@warn{2}%
+      \fi%
+   \else%
+      \def\yquant at draw@finalize at ctrl@multi at contiguous@warn{2}%
+   \fi%
+   \cslet{\yquant at prefix finalize at ctrl@draw at appto}\empty%
+   #4%
+   \eappto\yquant at draw@append{\csname\yquant at prefix finalize at ctrl@draw at appto\endcsname}%
+   \csgundef{\yquant at prefix finalize at ctrl@draw at appto}%
+}
+
+\protected\def\yquant at draw@finalize at ctrl@multiinit#1#2#3#4#5{%
+   % this is called from a do loop itself, so preserve \do (but do not enter grouping)
+   \let\yquant at register@multi at contiguous=\yquant at draw@finalize at ctrl@multi at contiguous%
+   \ifyquant at circuit@operator at hasControls%
+      \ifyquant at config@operator at multi@warn%
+         \def\yquant at draw@finalize at ctrl@multi at contiguous@warn{0}%
+      \else%
+         \def\yquant at draw@finalize at ctrl@multi at contiguous@warn{2}%
+      \fi%
+   \else%
+      \def\yquant at draw@finalize at ctrl@multi at contiguous@warn{2}%
+   \fi%
+   \cslet{\yquant at prefix finalize at ctrl@draw at appto}\empty%
+   #4%
+   \eappto\yquant at draw@append{\csname\yquant at prefix finalize at ctrl@draw at appto\endcsname}%
+   \csgundef{\yquant at prefix finalize at ctrl@draw at appto}%
+}
+
+\protected\def\yquant at draw@finalize at ctrl@multi at contiguous#1#2#3{%
+   \ifnum\yquant at draw@finalize at ctrl@multi at contiguous@warn=1 %
+      \PackageWarning{yquant.sty}{Ambiguous operation: multiple discontiguous multi-register operations in combination with controls make it hard to visually determine on which registers the gates act on.}%
+      % switch the warning off for this group (which is a single operation)
+      \yquant at config@operator at multi@warnfalse%
+      \def\yquant at draw@finalize at ctrl@multi at contiguous@warn{2}%
+   \else%
+      \numdef\yquant at draw@finalize at ctrl@multi at contiguous@warn{%
+         \yquant at draw@finalize at ctrl@multi at contiguous@warn+1%
       }%
+   \fi%
+   {% save \body
+      \yquant at for \yquant at i := #1 to #2 {{% let inner loop mess up with macros
+         \csxappto{\yquant at prefix finalize at ctrl@draw at appto}{%
+            \expandafter\yquant at draw@callback at wire\expandafter{\yquant at i}%
+         }%
+      }}%
    }%
-   \dolistloop{#4}%
-   \let\do=\yquant at draw@update at x@multi@@olddo%
 }
 % END_FOLD
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/latex/yquant/yquant-env.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-env.tex	2020-04-14 21:06:20 UTC (rev 54736)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-env.tex	2020-04-14 21:06:44 UTC (rev 54737)
@@ -49,7 +49,6 @@
       \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}{%
@@ -61,7 +60,7 @@
       \ifnum\yquant at env=1 %
          \yquant at env@substikz%
       \fi%
-      \scope[{/yquant/.cd, every circuit, #1}]%
+      \scope[{/yquant/.cd, #1, /tikz/.cd, /yquant/every circuit}]%
 }
 \newif\ifyquantdebug
 \protected\def\yquant at env@end{%
@@ -74,6 +73,7 @@
                \def\noexpand\yquant at env@end at xpos{%
                   \the\dimexpr\yquant at env@end at xpos+\yquant at config@operator at sep\relax%
                }%
+               \yquant at circuit@endwires{\yquant at env@end at registers}%
             }
             % also calculate the true y positions
             \dimen0=0pt %
@@ -80,10 +80,6 @@
             \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%

Modified: trunk/Master/texmf-dist/tex/latex/yquant/yquant-lang.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-lang.tex	2020-04-14 21:06:20 UTC (rev 54736)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-lang.tex	2020-04-14 21:06:44 UTC (rev 54737)
@@ -68,25 +68,25 @@
 }
 
 \def\yquant at lang@create at parse@name#1[#2;{%
-   \if\relax\detokenize{#2}\relax%
+   \ifstrempty{#2}{%
       \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%
+   \ifstrempty{#3}{%
       \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%
@@ -157,47 +157,25 @@
 \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%
+      \ifstrempty{#4}{%
          % 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%
+      \yquant at register@set at lastwire{#1}{{\the\pgf at x}{\the\pgf at x}{}{}}%
+      \ifstrempty{#5}\relax{%
          \pgfnodealias{\tikz at pp@name{#5}}{yquantbox}%
-      \fi%
+      }%
    \endgroup%
 }
 % END_FOLD
@@ -289,14 +267,11 @@
 % 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%
+\def\yquant at lang@@xx{%
+   \yquant at register@get at multiassingle%
+   \yquant at draw%
+      {}%
+      {/yquant/operators/every xx}%
 }
 
 % two-qubit controlled phase (symmetric notation)
@@ -303,7 +278,7 @@
 \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 register@get at multiassingle%
    \yquant at draw%
       {}%
       {/yquant/operators/every zz}%
@@ -333,14 +308,11 @@
 % 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%
+\def\yquant at lang@@swap{%
+   \yquant at register@get at multiassingle%
+   \yquant at draw%
+      {}%
+      {/yquant/operators/every swap}%
 }
 
 % not
@@ -433,6 +405,18 @@
       {}{}
 }
 
+\yquant at langhelper@declare at command@uncontrolled{correlate}\yquant at lang@@correlate
+\yquant at langhelper@setup at attrs{correlate}{}{}
+\def\yquant at lang@@correlate{%
+   % do not call \yquant at register@get at multiassingle, we do not want to install a different multi line style!
+   \yquant at register@get at allowmultitrue%
+   \let\yquant at register@multi at splitparts=\yquant at register@multi at splitparts@sepall%
+   \yquant at draw%
+      {}%
+      {/yquant/operators/every wave}%
+      {}{}%
+}
+
 \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{%
@@ -452,14 +436,24 @@
 \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%
+   \let\yquant at circuit@settype at to=\yquant at register@type at none%
+   \yquant at circuit@actonwires%
+      \yquant at circuit@settype%
+      \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 at multi@@extract#1#2#3{%
+   \yquant at for \yquant at i := #1 to #2 {%
+      \edef\yquant at circuit@settype at to{\yquant at register@get at type\yquant at i}%
+      \unless\ifx\yquant at circuit@settype at to\yquant at register@type at none%
+         \expandafter\yquant at for@break%
+      \fi%
+   }%
 }
+\long\def\@fifthoffive#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}%
@@ -483,13 +477,9 @@
       \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}%
+            \let\yquant at register@multi at contiguous=\yquant at lang@@init at multi@@extract%
+            \@fifthoffive##1%
+            % we should reset multi at contiguous to the original command; but this is really just a placeholder. As long as it is \protected, everything is fine.
          }{%
             \edef\yquant at circuit@settype at to{\yquant at register@get at type{##1}}%
          }%
@@ -518,6 +508,8 @@
    % 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}%
+      \let\yquant at draw@finalize at ctrl@single=\yquant at draw@finalize at ctrl@singleinit%
+      \let\yquant at draw@finalize at ctrl@multi=\yquant at draw@finalize at ctrl@multiinit%
       \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}%
@@ -536,9 +528,9 @@
    \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 langhelper@declare at command@uncontrolled{settype}\yquant at lang@@settype
+\yquant at langhelper@setup at attrs{settype}{value}{}
+\protected\def\yquant at lang@@settype#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}%
@@ -554,6 +546,35 @@
             }%
          }%
       }%
-   \yquant at circuit@settypes\yquant at register@get at ids@list\yquant at circuit@settype at to%
+   \yquant at circuit@actonwires%
+      \yquant at circuit@settype%
+      \yquant at register@get at ids@list%
+      {}%
 }
+
+\def\yquant at lang@setwire{%
+   \PackageWarning{yquant.sty}{`setwire' gate is deprecated as of yquant 0.1.2. Use `settype' instead.}%
+   \yquant at lang@settype%
+}
+\yquant at langhelper@setup at attrs{setwire}{value}{}
+
+\yquant at langhelper@declare at command@uncontrolled{setstyle}\yquant at lang@@setstyle
+\yquant at langhelper@setup at attrs{setstyle}{value}{}
+\protected\def\yquant at lang@@setstyle#1{%
+   \yquant at register@get at ids{#1}%
+   \yquant at circuit@actonwires%
+      \yquant at circuit@setstyle%
+      \yquant at register@get at ids@list%
+      {{\yquant at lang@attr at value}}%
+}
+
+\yquant at langhelper@declare at command@uncontrolled{addstyle}\yquant at lang@@addstyle
+\yquant at langhelper@setup at attrs{addstyle}{value}{}
+\protected\def\yquant at lang@@addstyle#1{%
+   \yquant at register@get at ids{#1}%
+   \yquant at circuit@actonwires%
+      \yquant at circuit@addstyle%
+      \yquant at register@get at ids@list%
+      {{\yquant at lang@attr at value}}%
+}
 % END_FOLD
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/latex/yquant/yquant-langhelper.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-langhelper.tex	2020-04-14 21:06:20 UTC (rev 54736)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-langhelper.tex	2020-04-14 21:06:44 UTC (rev 54737)
@@ -244,19 +244,19 @@
 }
 
 \def\yquant at langhelper@declare at command@@extract at nctrl#1~#2;{%
-   \if\relax\detokenize{#2}\relax%
+   \ifstrempty{#2}{%
       \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%
+   \ifstrempty{#2}{%
       \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;{%
@@ -301,7 +301,7 @@
    % 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%
+   \ifstrempty{#1}{%
       \def\tmp{#2}%
       \ifx\empty\tmp%
          \csletcs{ifvalid}{iftrue}%
@@ -310,6 +310,6 @@
             \csletcs{ifvalid}{iftrue}%
          \fi%
       \fi%
-   \fi%
+   }\relax%
    % eat the rest (which should be empty anyway)
 }
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/latex/yquant/yquant-registers.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-registers.tex	2020-04-14 21:06:20 UTC (rev 54736)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-registers.tex	2020-04-14 21:06:44 UTC (rev 54737)
@@ -17,7 +17,8 @@
       {#1}% type
       {#2}% x pos
       {\yquant at config@register at minimum@height}% height; at the end, the y position
-      {}% wire start positions
+      {{0pt}{0pt}{}{}}% wire start positions and clipping
+      {}% wire style
    }%
    \global\csletcs{\yquant at prefix registername@#3[#4]}{\yquant at prefix registers}%
    \csxdef{\yquant at prefix registerhigh@\reg}{#4}%
@@ -63,34 +64,34 @@
 }
 
 \def\yquant at register@get at id@lazycreate at parse#1[#2;{%
-   \if\relax\detokenize{#2}\relax%
+   \ifstrempty{#2}{%
       \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.}%
+   \begingroup%
+      % parse length
+      \ifstrempty{#3}{%
+         \yquant at langhelper@validate\len\count{#2}%
+         \numdef\len{\len+1}%
+      }{%
+         \PackageError{yquant.sty}{Invalid register name}%
+            {Register names must not contain `[' apart from register length indication.}%
+      }%
+      \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%
-   \else%
-      \def\idx{0}%
-   \fi%
-   \begingroup%
       % pre-set y position
       \yquant at for \idx := \idx to \numexpr \len -1\relax {%
          \yquant at register@define%
@@ -129,6 +130,7 @@
       \count4=0 % number of total registers
       \ifblank{#1}{}{%
          \let\ifinmulti=\iffalse%
+         \let\ifallowmain=\iffalse%
          \let\do=\yquant at register@get at ids@outerlist%
          \begingroup%
             \catcode`[=\active%
@@ -169,9 +171,15 @@
       \count0=2147483647 % minimal id
       \count2=0 % maximal id
       \count4=0 % number of total registers
+      \count6=-1 % index of main register
       \let\ifinmulti=\iftrue%
+      \let\ifallowmain=\iftrue%
       \let\do=\yquant at register@get at ids@multilist%
       \docsvlist{#1}%
+      \ifnum\count6=-1 %
+         \count6=\count0 %
+      \fi%
+      \yquant at register@multi at splitparts%
       \edef\process{%
             \endgroup%
          \noexpand\listadd\noexpand\yquant at register@get at ids@list{%
@@ -195,13 +203,13 @@
 }
 
 \def\yquant at register@get at ids@checkrange#1-#2\yquant at sep{%
-   \if\relax\detokenize{#2}\relax%
+   \ifstrempty{#2}{%
       % 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{%
@@ -214,7 +222,30 @@
 
 \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%
+   \ifallowmain%
+      \expandafter\ifyquant at firsttoken\expandafter*\expandafter{\current}{%
+         \edef\current{%
+            \expandafter\expandafter\expandafter\trim at spaces%
+            \expandafter\expandafter\expandafter{%
+               \expandafter\@gobble\current%
+            }%
+         }%
+         % catch the minimal index
+         \edef\yquant at register@get at ids@norange at checkindex@setmain{%
+            \count6=\count2%
+            \ifnum\count0<\the\count0 %
+               \count0=\the\count0 %
+            \fi%
+         }%
+         \count0=2147483647 %
+         \csletcs{ifallowmain}{iffalse}%
+      }{
+         \let\yquant at register@get at ids@norange at checkindex@setmain=\relax%
+      }%
+   \else%
+      \let\yquant at register@get at ids@norange at checkindex@setmain=\relax%
+   \fi%
+   \ifstrempty{#2}{%
       % 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}%
@@ -230,9 +261,10 @@
          \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%
+   }%
+   \yquant at register@get at ids@norange at checkindex@setmain%
 }
 
 \protected\def\yquant at register@get at ids@norange at index#1\yquant at register@get at ids@@index{%
@@ -269,9 +301,15 @@
       \count0=2147483647 % minimal id
       \count2=0 % maximal id
       \count4=0 % number of total registers
+      \count6=-1 % index of main register
       \let\ifinmulti=\iftrue%
+      \let\ifallowmain=\iftrue%
       \let\do=\yquant at register@get at ids@subindex at nomulti%
       \docsvlist{#1}%
+      \ifnum\count6=-1 %
+         \count6=\count0 %
+      \fi%
+      \yquant at register@multi at splitparts%
       \edef\process{%
             \endgroup%
          \noexpand\listadd\noexpand\yquant at register@get at ids@list{%
@@ -291,17 +329,29 @@
 }
 
 \def\yquant at register@get at ids@subindex at checkrange#1-#2\yquant at sep{%
-   \if\relax\detokenize{#2}\relax%
+   \ifstrempty{#2}{%
       % 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%
+      \edef\idx{\trim at spaces{#1}}%
+      \expandafter\yquant at register@get at ids@subindex at norange\expandafter{\idx}%
+   }{%
       % 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]}%
+   \ifallowmain%%
+      \ifyquant at firsttoken*{#1}{%
+         \edef\idx{\current[\expandafter\trim at spaces\expandafter{\@gobble#1}]}%
+         \expandafter\yquant at register@get at id\expandafter\idx\expandafter{\idx}%
+         \count6=\idx%
+         \csletcs{ifallowmain}{iffalse}%
+      }{
+         \yquant at register@get at id\idx{\current[#1]}%
+      }%
+   \else%
+      \yquant at register@get at id\idx{\current[#1]}%
+   \fi%
    \ifnum\idx<\count0 %
       \count0=\idx\relax%
    \fi%
@@ -313,16 +363,55 @@
 }
 
 \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}%
-   }%
+   \ifallowmain%
+      \ifyquant at firsttoken*{#1}{%
+         \expandafter\ifblank\expandafter{\@gobble#1}{%
+            \def\first{0}%
+         }{%
+            \expandafter\yquant at langhelper@validate\expandafter\first\expandafter\count\expandafter{\@gobble#1}%
+         }%
+         \yquant at register@get at id\idx{\current[\first]}%
+         \count6=\idx%
+         \csletcs{ifallowmain}{iffalse}%
+      }{%
+         \ifblank{#1}{%
+            \def\first{0}%
+         }{%
+            \yquant at langhelper@validate\first\count{#1}%
+         }%
+      }%
+   \else%
+      \ifblank{#1}{%
+         \def\first{0}%
+      }{%
+         \yquant at langhelper@validate\first\count{#1}%
+      }%
+   \fi%
+   \ifallowmain%
+      % in #1, all initial spaces are gobbled automatically, but not in #2
+      \expandafter\ifyquant at firsttoken\expandafter*\expandafter{\empty#2}{%
+         \expandafter\ifblank\expandafter{\@gobble#2}{%
+            \yquant at register@get at id@high\last\current%
+         }{%
+            \expandafter\yquant at langhelper@validate\expandafter\last\expandafter\count\expandafter{\@gobble#2}%
+         }%
+         \yquant at register@get at id\idx{\current[\last]}%
+         \count6=\idx%
+         \csletcs{ifallowmain}{iffalse}%
+      }{%
+         \ifblank{#2}{%
+            \yquant at register@get at id@high\last\current%
+         }{%
+            \yquant at langhelper@validate\last\count{#2}%
+         }%
+      }%
+   \else%
+      \ifblank{#2}{%
+         \yquant at register@get at id@high\last\current%
+      }{%
+         \yquant at langhelper@validate\last\count{#2}%
+      }%
+   \fi%
    \yquant at for \i := \first to \last {%
       \yquant at register@get at ids@subindex at norange\i%
    }%
@@ -330,14 +419,33 @@
 
 \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%
-   }%
+   \ifallowmain%
+      \ifyquant at firsttoken*{#1}{%
+         \expandafter\ifblank\expandafter{\@gobble#1}{%
+            \def\first{1}%
+         }{%
+            \expandafter\yquant at register@get at ids@range at getfirst\@gobble#1\yquant at register@get at ids@@index\yquant at sep%
+         }%
+         \count6=\first%
+         \csletcs{ifallowmain}{iffalse}%
+      }{%
+         \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%
+         }%
+      }%
+   \else%
+      \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%
+      }%
+   \fi%
+   % it does not make sense to allow to set the main part on the second half of the range, since a range over registers (not indices) is automatically visual, so this range will be contiguous.
    \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%
@@ -363,20 +471,20 @@
 }
 
 \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%
+   \ifstrempty{#2}{%
       \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%
+   \ifstrempty{#2}{%
       \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{%
@@ -384,6 +492,94 @@
 }
 
 \let\yquant at register@multi=\empty%
+\protected\def\yquant at register@multi at contiguous{}%
+
+% splits \yquant at register@get at ids@list into a list of contiguous parts
+\protected\def\yquant at register@multi at splitparts{%
+   \begingroup%
+      \let\registers=\yquant at register@get at ids@list%
+      \yquant at sort@list\registers\yquant at sort@ascending%
+      \let\newlist=\empty%
+      \count2=-1 %
+      \def\do##1{%
+         \ifnum\count2=-1 %
+            \count2=##1 %
+            \count4=\count2 %
+         \else%
+            \advance\count2 by 1 %
+            \ifnum##1>\count2 %
+               % this is a discontiguous change (we disallow duplicate entries)
+               \eappto\newlist{%
+                  \yquant at register@multi at contiguous%
+                     {\the\count4}{\the\numexpr\count2-1\relax}%
+                     {\ifnum\count6<\count2 %
+                         \ifnum\count4>\count6 %
+                            0%
+                         \else%
+                            1%
+                         \fi%
+                      \else%
+                         0%
+                      \fi}%
+               }%
+               \count2=##1 %
+               \count4=\count2 %
+            \fi%
+         \fi%
+      }%
+      \dolistloop\registers%
+      % we disallow empty lists
+      \eappto\newlist{%
+         \yquant at register@multi at contiguous%
+            {\the\count4}{\the\count2}%
+            {\ifnum\count6>\count2 %
+                0%
+             \else%
+                \ifnum\count4>\count6 %
+                   0%
+                \else%
+                   1%
+                \fi%
+             \fi}%
+      }%
+      \expandafter%
+   \endgroup%
+   \expandafter\def\expandafter\yquant at register@get at ids@list\expandafter{%
+      \newlist%
+   }%
+}
+
+% splits \yquant at register@get at ids@list into a list of discontiguous parts
+\protected\def\yquant at register@multi at splitparts@sepall{%
+   \begingroup%
+      \let\registers=\yquant at register@get at ids@list%
+      \yquant at sort@list\registers\yquant at sort@ascending%
+      \let\newlist=\empty%
+      \def\do##1{%
+         \eappto\newlist{%
+            \yquant at register@multi at contiguous%
+               {##1}{##1}%
+               {\ifnum##1=\count6 %
+                   1%
+                \else%
+                   0%
+                \fi%
+               }%
+         }%
+      }%
+      \dolistloop\registers%
+      \expandafter%
+   \endgroup%
+   \expandafter\def\expandafter\yquant at register@get at ids@list\expandafter{%
+      \newlist%
+   }%
+}
+
+\protected\def\yquant at register@get at multiassingle{%
+   \yquant at register@get at allowmultitrue%
+   \let\yquant at register@multi at splitparts=\yquant at register@multi at splitparts@sepall%
+   \preto\yquant at attrs@remaining{/yquant/operator/multi as single,}%
+}
 % END_FOLD
 
 % BEGIN_FOLD Getters: extract the requested information from the register with given id
@@ -392,7 +588,7 @@
    \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 type@aux#1#2#3#4#5{#1}
 
 \def\yquant at register@get at x#1{%
    \expandafter\expandafter\expandafter%
@@ -399,7 +595,7 @@
    \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 x@aux#1#2#3#4#5{#2}
 
 \def\yquant at register@get at height#1{%
    \expandafter\expandafter\expandafter%
@@ -406,7 +602,7 @@
    \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}
+\def\yquant at register@get at height@aux#1#2#3#4#5{#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{%
@@ -443,8 +639,28 @@
    \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}
+\protected\def\yquant at register@get at lastwire@aux#1#2#3#4#5#6{%
+   \def#6{#4}%
+}
 
+\def\yquant at register@get at style#1{%
+   \expandafter\expandafter\expandafter%
+   \yquant at register@get at style@aux\csname\yquant at prefix register@#1\endcsname%
+}
+
+\def\yquant at register@get at style@aux#1#2#3#4#5{#5}
+
+\def\yquant at register@get at typeywire#1{%
+   \expandafter\expandafter\expandafter%
+   \yquant at register@get at typeywire@aux\csname\yquant at prefix register@#1\endcsname%
+}
+
+\protected\def\yquant at register@get at typeywire@aux#1#2#3#4#5#6#7#8{%
+   \def#6{#1}%
+   \def#7{#3}%
+   \def#8{#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%
@@ -487,8 +703,8 @@
    \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}%
+\long\def\yquant at register@set at type@aux#1#2#3#4#5#6{%
+   {#6}\unexpanded{{#2}{#3}{#4}{#5}}%
 }
 
 \protected\def\yquant at register@set at x#1{%
@@ -496,8 +712,8 @@
    \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}%
+\long\def\yquant at register@set at x@aux#1#2#3#4#5#6{%
+   \unexpanded{{#1}}{#6}\unexpanded{{#3}{#4}{#5}}%
 }
 
 \protected\def\yquant at register@update at height#1#2{%
@@ -513,20 +729,25 @@
 }
 
 % 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#6{%
+   \unexpanded{{#1}{#2}}{#6}\unexpanded{{#4}{#5}}%
 }
 
-\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}%
+\long\def\yquant at register@set at lastwire@aux#1#2#3#4#5#6{%
+   \unexpanded{{#1}{#2}{#3}}{#6}\unexpanded{{#5}}%
 }
+
+\protected\def\yquant at register@set at style#1{%
+   \expandafter\yquant at register@set@@aux%
+   \csname\yquant at prefix register@#1\endcsname\yquant at register@set at style@aux%
+}
+
+\long\def\yquant at register@set at style@aux#1#2#3#4#5#6{%
+   \unexpanded{{#1}{#2}{#3}{#4}}{#6}%
+}
 % END_FOLD
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex	2020-04-14 21:06:20 UTC (rev 54736)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex	2020-04-14 21:06:44 UTC (rev 54737)
@@ -1,137 +1,92 @@
-% 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}%
-}%
+\long\def\pgf at sh@clippathhorz#1{%
+   \csgdef{pgf at sh@cliphorz@\pgf at sm@shape at name}{#1}%
+}
+\let\pgf at sh@clippath=\pgf at sh@clippathhorz%
+\long\def\pgf at sh@clippathvert#1{%
+   \csgdef{pgf at sh@clipvert@\pgf at sm@shape at name}{#1}%
+}
+\def\pgf at sh@inheritclippath[from=#1]{%
+   \global\csletcs{pgf at sh@cliphorz@\pgf at sm@shape at name}{pgf at sh@cliphorz@#1}%
+   \global\csletcs{pgf at sh@clipvert@\pgf at sm@shape at name}{pgf at sh@clipvert@#1}%
+}
 \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}%
+    \let\clippathhorz=\pgf at sh@clippathhorz%
+    \let\clippathvert=\pgf at sh@clippathvert%
+    \let\clippath=\pgf at sh@clippath%
+    \let\inheritclippath=\pgf at sh@inheritclippath}%
    {}%
    {\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{%
+% Every shape additionally provides information about how it should clip the wires. The clipping softpath instructions of shape #1 are stored into \pgfshapeclippathresult. The path is drawn with the tikz options #2 in place.
+\protected\def\pgfshapeclippath#1#2{%
    % Ok, check whether #1 is known!
    \ifcsname pgf at sh@ns@#1\endcsname%
-      \pgf at process{%
+      \begin{pgfinterruptpath}%
          \edef\pgfreferencednodename{#1}% for use inside of anchors.
+         % install the given style and extract whether we draw a line.
+         \let\tikz at mode=\pgfutil at empty%
+         \tikzset{every path/.try,#2}%
+         \edef\oldpgflinewidth{\the\pgflinewidth}%
+         \tikz at mode@drawfalse%
+         \tikz at mode%
+         \unless\iftikz at mode@draw%
+            \pgflinewidth=0pt %
+         \fi%
          % 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%
-      }%
+         \pgfsettransform{\csname pgf at sh@nt@#1\endcsname}%
+         \csname pgf at sh@cliphorz@\csname pgf at sh@ns@#1\endcsname\endcsname%
+         \pgfsyssoftpath at getcurrentpath\pgfshapeclippathresult%
+         \pgfprocessround{\pgfshapeclippathresult}{\pgfshapeclippathresult}%
+         \global\let\pgfshapeclippathhorzresult=\pgfshapeclippathresult%
+         \ifcsname pgf at sh@clipvert@\csname pgf at sh@ns@#1\endcsname\endcsname%
+            % different clipping in vertical direction
+            \pgfsyssoftpath at setcurrentpath\pgfutil at empty%
+            \csname pgf at sh@clipvert@\csname pgf at sh@ns@#1\endcsname\endcsname%
+            \pgfsyssoftpath at getcurrentpath\pgfshapeclippathresult%
+            \pgfprocessround{\pgfshapeclippathresult}{\pgfshapeclippathresult}%
+         \fi%
+         \global\let\pgfshapeclippathvertresult=\pgfshapeclippathresult%
+      \end{pgfinterruptpath}%
    \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%
+   \clippath{%
+      % all pgf temporaries may be overwritten by \pgfpathrectanglecorners
+      \begingroup%
+         % the outer sep may depend on the line width (though there may not be any line)
+         \pgflinewidth=\oldpgflinewidth%
+         \global\@tempdima=\pgfkeysvalueof{/pgf/outer xsep} %
+         \global\@tempdimb=\pgfkeysvalueof{/pgf/outer ysep} %
+      \endgroup%
+      \advance\@tempdima by -.5\pgflinewidth%
+      \advance\@tempdimb by -.5\pgflinewidth%
+      \pgfpathrectanglecorners%
+         {\southwest%
+          \advance\pgf at x by \@tempdima%
+          \advance\pgf at y by \@tempdimb%
+         }
+         {\northeast%
+          \advance\pgf at x by -\@tempdima%
+          \advance\pgf at y by -\@tempdimb%
+         }%
    }%
-   \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}{%
@@ -198,29 +153,7 @@
       \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%
@@ -227,12 +160,19 @@
          {\pgfqpoint{-\xradius}{\yradius}}%
          {\pgfqpoint{\xradius}{-\yradius}}%
    }%
+   \clippath{%
+      \pgfpathrectanglecorners%
+         {\pgfqpoint{-\dimexpr\xradius+.5\pgflinewidth\relax}%
+                    {\dimexpr\yradius+.5\pgflinewidth\relax}}%
+         {\pgfqpoint{\dimexpr\xradius+.5\pgflinewidth\relax}%
+                    {-\dimexpr\yradius+.5\pgflinewidth\relax}}%
+   }%
    % END_FOLD
 }
 
 \pgfdeclareshape{yquant-circle}{%
    \inheritsavedanchors[from=yquant-rectangle]%
-   \foreach \anc in {center, north, east, south, west, circuit, text} {%
+   \foreach \anc in {center, north, east, south, west, text} {%
       \inheritanchor[from=yquant-rectangle]{\anc}%
    }%
    \anchor{north east}%
@@ -254,35 +194,19 @@
                             {\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{%
+   \backgroundpath{%
       \pgfpathellipse{\pgfpointorigin}%
                      {\pgfqpoint{\xradius}{0pt}}%
                      {\pgfqpoint{0pt}{\yradius}}%
    }%
+   \clippath{%
+      \pgfpathellipse{\pgfpointorigin}%
+                     {\pgfqpoint{\dimexpr\xradius+.5\pgflinewidth}{0pt}}%
+                     {\pgfqpoint{0pt}{\dimexpr\yradius+.5\pgflinewidth}}%
+   }%
 }
 
-\pgfdeclareshape{yquant-zz}{%
-   % Here, the radii have a special meaning, we don't put text into the shape
+\pgfdeclareshape{yquant-slash}{%
    \saveddimen\xradius{%
       \pgfmathsetlength\pgf at x{\pgfkeysvalueof{/tikz/x radius}}%
    }%
@@ -289,135 +213,156 @@
    \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} {%
+   \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west} {%
       \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}}%
    }%
+   \clippath{%
+      % we need to clip to the line; but this is not possible, we can only clip to the inner of a path. For this reason, calculate the rectangle that represents the line.
+      % TODO: for round line endings, this is not a rectangle. Only a problem if the yradius is so short that the slash ends within a wire.
+      \ifcsname yquant at math@cache1@\xradius @\yradius @\the\pgflinewidth\endcsname%
+         \letcs\tmp{yquant at math@cache1@\xradius @\yradius @\the\pgflinewidth}%
+         \dimen2=\expandafter\@firstoftwo\tmp%
+         \dimen4=\expandafter\@secondoftwo\tmp%
+      \else%
+         % cos(arctan(x)) = 1/sqrt(1+x^2)
+         % sin(arctan(x)) = x/sqrt(1+x^2)
+         \dimen2=\xradius %
+         \dimen4=\yradius %
+         % 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.
+         \dimen0=\dimexpr\dimen4*\dimen4/\dimen2*65536/\dimen2\relax%
+         % 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.
+         \pgfmathsqrt@{\the\dimexpr1pt+\dimen0\relax\@gobbletwo}%
+         \pgfmathreciprocal@\pgfmathresult%
+         \dimen2=\dimexpr.5\pgflinewidth*\dimexpr\pgfmathresult pt\relax/65536\relax%
+         \dimen4=\dimexpr\dimexpr\yradius\relax*\dimen2/\dimexpr\xradius\relax\relax%
+         \csxdef{yquant at math@cache1@\xradius @\yradius @\the\pgflinewidth}%
+                {{\the\dimen2}{\the\dimen4}}%
+      \fi%
+      \pgfpathmoveto{\pgfqpoint{-\dimexpr\xradius+\dimen4\relax}%
+                               {-\dimexpr\yradius-\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-\dimen4\relax}%
+                               {\dimexpr\yradius+\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{\dimexpr\xradius+\dimen4\relax}%
+                               {\dimexpr\yradius-\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius-\dimen4\relax}%
+                               {-\dimexpr\yradius+\dimen2\relax}}%
+      \pgfpathclose%
+   }%
 }
 
 \pgfdeclareshape{yquant-swap}{%
-   \inheritsavedanchors[from=yquant-xx]%
-   \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west, circuit} {%
+   \inheritsavedanchors[from=yquant-slash]%
+   \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west} {%
       \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}}%
+      \pgfpathlineto{\pgfqpoint{\xradius}{-\yradius}}%
       \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}}%
    }%
+   \clippathhorz{%
+      % we need to clip to the line; but this is not possible, we can only clip to the inner of a path. For this reason, calculate the rectangle that represents the line.
+      % TODO: for round line endings, this is not a rectangle. Only a problem if the yradius is so short that the slash ends within a wire.
+      \ifcsname yquant at math@cache1@\xradius @\yradius @\the\pgflinewidth\endcsname%
+         \letcs\tmp{yquant at math@cache1@\xradius @\yradius @\the\pgflinewidth}%
+         \dimen2=\expandafter\@firstoftwo\tmp%
+         \dimen4=\expandafter\@secondoftwo\tmp%
+      \else%
+         % cos(arctan(x)) = 1/sqrt(1+x^2)
+         % sin(arctan(x)) = x/sqrt(1+x^2)
+         \dimen2=\xradius %
+         \dimen4=\yradius %
+         % 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.
+         \dimen0=\dimexpr\dimen4*\dimen4/\dimen2*65536/\dimen2\relax%
+         % 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.
+         \pgfmathsqrt@{\the\dimexpr1pt+\dimen0\relax\@gobbletwo}%
+         \pgfmathreciprocal@\pgfmathresult%
+         \dimen2=\dimexpr.5\pgflinewidth*\dimexpr\pgfmathresult pt\relax/65536\relax%
+         \dimen4=\dimexpr\dimexpr\yradius\relax*\dimen2/\dimexpr\xradius\relax\relax%
+         \csxdef{yquant at math@cache1@\xradius @\yradius @\the\pgflinewidth}%
+                {{\the\dimen2}{\the\dimen4}}%
+      \fi%
+      \dimen6=\dimexpr\dimen2*\dimexpr\xradius\relax/\dimexpr\yradius\relax+%
+                      \dimen2*\dimexpr\yradius\relax/\dimexpr\xradius\relax\relax%
+      \pgfpathmoveto{\pgfqpoint{-\dimexpr\xradius+\dimen4\relax}%
+                               {\dimexpr\yradius-\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius-\dimen4\relax}%
+                               {\dimexpr\yradius+\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-\dimen4\relax}%
+                               {\dimexpr\yradius+\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{\dimexpr\xradius+\dimen4\relax}%
+                               {\dimexpr\yradius-\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{\dimen6}{0pt}}%
+      \pgfpathlineto{\pgfqpoint{\dimexpr\xradius+\dimen4\relax}%
+                               {-\dimexpr\yradius-\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-\dimen4\relax}%
+                               {-\dimexpr\yradius+\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius-\dimen4\relax}%
+                               {-\dimexpr\yradius+\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius+\dimen4\relax}%
+                               {-\dimexpr\yradius-\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{-\dimen6}{0pt}}%
+      \pgfpathclose%
+   }%
+   \clippathvert{%
+      % we need to clip to the line; but this is not possible, we can only clip to the inner of a path. For this reason, calculate the rectangle that represents the line.
+      % TODO: for round line endings, this is not a rectangle. Only a problem if the yradius is so short that the slash ends within a wire.
+      \ifcsname yquant at math@cache1@\xradius @\yradius @\the\pgflinewidth\endcsname%
+         \letcs\tmp{yquant at math@cache1@\xradius @\yradius @\the\pgflinewidth}%
+         \dimen2=\expandafter\@firstoftwo\tmp%
+         \dimen4=\expandafter\@secondoftwo\tmp%
+      \else%
+         % cos(arctan(x)) = 1/sqrt(1+x^2)
+         % sin(arctan(x)) = x/sqrt(1+x^2)
+         \dimen2=\xradius %
+         \dimen4=\yradius %
+         % 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.
+         \dimen0=\dimexpr\dimen4*\dimen4/\dimen2*65536/\dimen2\relax%
+         % 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.
+         \pgfmathsqrt@{\the\dimexpr1pt+\dimen0\relax\@gobbletwo}%
+         \pgfmathreciprocal@\pgfmathresult%
+         \dimen2=\dimexpr.5\pgflinewidth*\dimexpr\pgfmathresult pt\relax/65536\relax%
+         \dimen4=\dimexpr\dimexpr\yradius\relax*\dimen2/\dimexpr\xradius\relax\relax%
+         \csxdef{yquant at math@cache1@\xradius @\yradius @\the\pgflinewidth}%
+                {{\the\dimen2}{\the\dimen4}}%
+      \fi%
+      \dimen6=\dimexpr\dimen4*\dimexpr\xradius\relax/\dimexpr\yradius\relax+%
+                      \dimen4*\dimexpr\yradius\relax/\dimexpr\xradius\relax\relax%
+      \pgfpathmoveto{\pgfqpoint{-\dimexpr\xradius+\dimen4\relax}%
+                               {\dimexpr\yradius-\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius-\dimen4\relax}%
+                               {\dimexpr\yradius+\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{0pt}{\dimen6}}%
+      \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-\dimen4\relax}%
+                               {\dimexpr\yradius+\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{\dimexpr\xradius+\dimen4\relax}%
+                               {\dimexpr\yradius-\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{\dimexpr\xradius+\dimen4\relax}%
+                               {-\dimexpr\yradius-\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-\dimen4\relax}%
+                               {-\dimexpr\yradius+\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{0pt}{-\dimen6}}%
+      \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius-\dimen4\relax}%
+                               {-\dimexpr\yradius+\dimen2\relax}}%
+      \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius+\dimen4\relax}%
+                               {-\dimexpr\yradius-\dimen2\relax}}%
+      \pgfpathclose%
+   }%
 }
 
 \pgfdeclareshape{yquant-oplus}{%
-   \inheritsavedanchors[from=yquant-zz]%
-   \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west, circuit} {%
+   \inheritsavedanchors[from=yquant-slash]%
+   \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west} {%
       \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}}%
@@ -427,6 +372,7 @@
                      {\pgfqpoint{\xradius}{0pt}}%
                      {\pgfqpoint{0pt}{\yradius}}%
    }%
+   \inheritclippath[from=yquant-circle]%
 }
 
 \pgfdeclareshape{yquant-measure}{%
@@ -443,8 +389,10 @@
             \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%
+         \pgf at y=\dimexpr.5\ht\pgfnodeparttextbox+.5\dp\pgfnodeparttextbox+2pt\relax%
+         \ifyquant at config@operator at multi@main%
+            \advance\pgf at y by 1.25mm %
+         \fi%
          \ifdim\pgf at x<\pgf at y%
             \pgf at x=\pgf at y%
          \fi%
@@ -451,44 +399,63 @@
       \fi%
    }%
    \savedanchor\stext{%
-      \pgfqpoint%
-         {-.5\wd\pgfnodeparttextbox}%
-         {\dp\pgfnodeparttextbox}%
+      \ifyquant at config@operator at multi@main%
+         \pgfqpoint%
+            {-.5\wd\pgfnodeparttextbox}%
+            {\dp\pgfnodeparttextbox}%
+      \else%
+         \pgfqpoint%
+            {-.5\wd\pgfnodeparttextbox}%
+            {-\dimexpr.5\ht\pgfnodeparttextbox-.5\dp\pgfnodeparttextbox\relax}%
+      \fi%
    }%
    \saveddimen\textheight{%
       \pgf at x=\ht\pgfnodeparttextbox%
-   }
-   \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west, circuit} {%
+   }%
+   \savedmacro\main{%
+      \ifyquant at config@operator at multi@main%
+         \def\main{\noexpand\yquant at config@operator at multi@maintrue}%
+      \else%
+         \ifdim\dimexpr\ht\pgfnodeparttextbox+\dp\pgfnodeparttextbox\relax=0pt%
+            \def\main{\noexpand\yquant at config@operator at multi@maintrue}%
+         \else%
+            \def\main{\noexpand\yquant at config@operator at multi@mainfalse}%
+         \fi%
+      \fi%
+   }%
+   \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west} {%
       \inheritanchor[from=yquant-rectangle]{\anc}%
    }%
    \anchor{text}{%
       \stext%
-      \pgf at y=\dimexpr-\yradius+1pt+\pgf at y\relax%
+      \main%
+      \ifyquant at config@operator at multi@main%
+         \pgf at y=\dimexpr-\yradius+1pt+\pgf at y\relax%
+      \fi%
    }%
    \inheritanchorborder[from=yquant-rectangle]%
-   \inheritanchorxproj[from=yquant-rectangle]%
-   \inheritanchoryproj[from=yquant-rectangle]%
-   \backgroundpath{%
-      \pgfpathrectanglecorners%
-         {\pgfqpoint{-\xradius}{\yradius}}%
-         {\pgfqpoint{\xradius}{-\yradius}}%
-   }
+   \inheritbackgroundpath[from=yquant-rectangle]%
+   \inheritclippath[from=yquant-rectangle]%
    \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%
+      \main%
+      % we only draw the meter symbol if this is the main part of a multi-register (or there is no text)
+      \ifyquant at config@operator at multi@main%
+         % 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);
       \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);
    }%
 }
 
@@ -521,16 +488,12 @@
          {-\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} {%
+   \foreach \anc in {center, north, south, south west, west, north west, 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%
@@ -545,40 +508,6 @@
                                  {\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}}%
@@ -586,25 +515,34 @@
       \pgfpathlineto{\pgfqpoint{-\xradius}{-\yradius}}%
       \pgfpathclose%
    }%
+   \clippath{%
+      \pgfpathmoveto{\pgfqpoint{-\dimexpr\xradius+.5\pgflinewidth\relax}%
+                               {\dimexpr\yradius+.5\pgflinewidth\relax}}%
+      \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-3mm\relax}%
+                               {\dimexpr\yradius+.5\pgflinewidth\relax}}%
+      \pgfpatharc{90}{-90}{3mm+.5\pgflinewidth and \yradius+.5\pgflinewidth}%
+      \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius+.5\pgflinewidth\relax}%
+                               {-\dimexpr\yradius+.5\pgflinewidth\relax}}%
+      \pgfpathclose%
+   }%
 }
 
-\pgfdeclareshape{yquant-barrier}{%
-   % Here, the radii have a special meaning, we don't put text into the shape
+\pgfdeclareshape{yquant-line}{%
+   \savedanchor\shorten{%
+      \pgfqpoint\pgf at shorten@end at additional\pgf at shorten@start at additional%
+   }%
    \saveddimen\xradius{%
+      % we only need this for the border anchor; the value is automatically correct in the paths.
       \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} {%
+   \foreach \anc in {center, north, north east, east, south east, south, south west, west, north west} {%
       \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%
@@ -611,4 +549,12 @@
       \pgfpathmoveto{\pgfqpoint{0pt}{\pgf at xa}}%
       \pgfpathlineto{\pgfqpoint{0pt}{-\pgf at ya}}%
    }%
+   \clippath{%
+      \shorten%
+      \@tempdima=\dimexpr\yradius+\pgf at x\relax%
+      \@tempdimb=\dimexpr\yradius+\pgf at y\relax%
+      \pgfpathrectanglecorners
+         {\pgfqpoint{-.5\pgflinewidth}{\@tempdima}}%
+         {\pgfqpoint{.5\pgflinewidth}{-\@tempdimb}}%
+   }%
 }
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/latex/yquant/yquant-tools.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant-tools.tex	2020-04-14 21:06:20 UTC (rev 54736)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant-tools.tex	2020-04-14 21:06:44 UTC (rev 54737)
@@ -45,6 +45,11 @@
    \repeat%
 }
 
+\def\yquant at for@break{%
+   \fi%
+   \iffalse%
+}
+
 % Def #1 to be the minimum of #2, ... until \relax
 \protected\def\yquant at min#1{%
    \def#1{2147483647}%
@@ -92,11 +97,11 @@
 % 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%
+   \ifstrempty{#2}{%
       \expandafter\@secondoftwo%
-   \else%
+   }{%
       \ifyquant at firsttoken@aux#1#2\yquant at sep%
-   \fi%
+   }%
 }
 
 \def\ifyquant at firsttoken@aux#1#2#3\yquant at sep{%
@@ -110,11 +115,7 @@
 % 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%
+      \ifstrempty{##1}%
    }%
    \ifyquant at beginswith@#1#2\yquant at end%
 }
@@ -148,6 +149,14 @@
    \expandafter\yquant at sort@aux\expandafter0\expandafter{\the\numexpr\yquant at sort@count-1\relax}%
 }
 
+\def\yquant at sort@ascending#1#2{%
+   \ifnum#2>#1 %
+      \expandafter\@firstoftwo%
+   \else%
+      \expandafter\@secondoftwo%
+   \fi%
+}
+
 \protected\def\yquant at sort@aux#1#2{%
    \ifnum#1<#2\relax%
       \yquant at sort@divide{#1}{#2}%
@@ -159,6 +168,8 @@
    \fi%
 }
 
+\def\iftrue at hidden{\iftrue}%
+\def\iffalse at hidden{\iffalse}%
 \protected\def\yquant at sort@divide#1#2{%
    \count0=#1\relax% i
    \count2=#2\relax% j
@@ -167,7 +178,6 @@
    \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%
@@ -177,14 +187,14 @@
                   \expandafter\expandafter\expandafter{%
                      \csname yquant at sort@item\the\count0\endcsname%
                   }{%
-                     \csletcs{next}{iffalse}%
+                     \expandafter\iffalse at hidden%
                   }{%
                      \advance\count0 by 1 %
+                     \expandafter\iftrue at hidden%
                   }%
             \else%
-               \csletcs{next}{iffalse}%
+               \expandafter\iffalse at hidden%
             \fi%
-            \next%
          \repeat%
          \expandafter%
       }%
@@ -191,7 +201,6 @@
       \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%
@@ -202,13 +211,13 @@
                      \csname yquant at sort@item\the\count2\endcsname%
                   }{%
                      \advance\count2 by -1 %
+                     \expandafter\iftrue at hidden%
                   }{%
-                     \csletcs{next}{iffalse}%
+                     \expandafter\iffalse at hidden%
                   }%
             \else%
-               \csletcs{next}{iffalse}%
+               \expandafter\iffalse at hidden%
             \fi%
-            \next%
          \repeat%
          \expandafter
       }%

Modified: trunk/Master/texmf-dist/tex/latex/yquant/yquant.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/yquant/yquant.sty	2020-04-14 21:06:20 UTC (rev 54736)
+++ trunk/Master/texmf-dist/tex/latex/yquant/yquant.sty	2020-04-14 21:06:44 UTC (rev 54737)
@@ -4,11 +4,11 @@
 % 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
+% Public License, either version 1.3c 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
+% and version 1.3c or later is part of all distributions of LaTeX version 2005/12/01 or
 % later.
 %
 % This work has the LPPL maintenance status `maintained'.
@@ -15,12 +15,12 @@
 %
 % 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]
+\ProvidesPackage{yquant}[2020/04/11 v0.1.2 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}
+\usetikzlibrary{arrows.meta,decorations.pathreplacing,decorations.pathmorphing}
 
 \input yquant-config.tex
 \input yquant-tools.tex



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