texlive[60768] Master: zx-calculus (16oct21)

commits+karl at tug.org commits+karl at tug.org
Sat Oct 16 00:13:44 CEST 2021


Revision: 60768
          http://tug.org/svn/texlive?view=revision&revision=60768
Author:   karl
Date:     2021-10-16 00:13:43 +0200 (Sat, 16 Oct 2021)
Log Message:
-----------
zx-calculus (16oct21)

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

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/zx-calculus/
    trunk/Master/texmf-dist/doc/latex/zx-calculus/README.md
    trunk/Master/texmf-dist/doc/latex/zx-calculus/zx-calculus.pdf
    trunk/Master/texmf-dist/doc/latex/zx-calculus/zx-calculus.tex
    trunk/Master/texmf-dist/tex/latex/zx-calculus/
    trunk/Master/texmf-dist/tex/latex/zx-calculus/tikzlibraryzx-calculus.code.tex
    trunk/Master/texmf-dist/tex/latex/zx-calculus/zx-calculus.sty
    trunk/Master/tlpkg/tlpsrc/zx-calculus.tlpsrc

Added: trunk/Master/texmf-dist/doc/latex/zx-calculus/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/zx-calculus/README.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/zx-calculus/README.md	2021-10-15 22:13:43 UTC (rev 60768)
@@ -0,0 +1,7 @@
+# `zx-calculus`: a library to typeset ZX-calculus in LaTeX
+
+This library (based on the great TikZ and Tikz-cd packages) allows you to typeset ZX-calculus directly in LaTeX. It comes with a default (but highly customizable) style. For more information, see the documentation in [`zx-calculus.pdf`][1].
+
+The project is hosted at https://github.com/leo-colisson/zx-calculus , feel free to report any bug there. It is licensed under MIT and its author is Léo Colisson.
+
+ [1]: https://raw.githubusercontent.com/leo-colisson/zx-calculus/main/doc/zx-calculus.pdf


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

Index: trunk/Master/texmf-dist/doc/latex/zx-calculus/zx-calculus.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/zx-calculus/zx-calculus.pdf	2021-10-15 22:12:13 UTC (rev 60767)
+++ trunk/Master/texmf-dist/doc/latex/zx-calculus/zx-calculus.pdf	2021-10-15 22:13:43 UTC (rev 60768)

Property changes on: trunk/Master/texmf-dist/doc/latex/zx-calculus/zx-calculus.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/zx-calculus/zx-calculus.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/zx-calculus/zx-calculus.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/zx-calculus/zx-calculus.tex	2021-10-15 22:13:43 UTC (rev 60768)
@@ -0,0 +1,1049 @@
+\documentclass[a4paper]{ltxdoc}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Packages
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\usepackage[margin=3cm]{geometry}
+\usepackage{calc}
+\usepackage{tikz}
+\usetikzlibrary{shadows,fit}
+% \usetikzlibrary fails because file is not in current directory, lazy to setup TEXINPUTS
+\makeatletter
+  \usetikzlibrary{zx-calculus}
+\makeatother
+% Loads the great package that produces tikz-like manual (see also tikzcd for examples)
+\input{pgfmanual-en-macros.tex} % Is supposed to be included in recent TeX distributions, but I get errors...
+\usepackage{makeidx} % Produces an index of commands.
+\makeindex % Useful or not index will be created
+\usepackage[hidelinks]{hyperref}
+\newcommand{\mylink}[2]{\href{#1}{#2}\footnote{\url{#1}}}
+\usepackage{verbatim}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Documentation
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\begin{document}
+%%% Title: thanks tikzcd for the styling
+\begin{center}
+  \vspace*{1em} % Thanks tikzcd
+  \tikz\node[scale=1.2]{%
+    \color{gray}\Huge\ttfamily \char`\{\raisebox{.09em}{\textcolor{red!75!black}{zx\raisebox{-0.1em}{-}calculus}}\char`\}};
+
+  \vspace{0.5em}
+  {\Large\bfseries ZX-calculus with \tikzname}
+
+  \vspace{1em}
+  {Version 2021/10/15}\\[3mm]
+  {\href{https://github.com/leo-colisson/zx-calculus}{\texttt{github.com/leo-colisson/zx-calculus}}}
+\end{center}
+
+\tableofcontents
+
+\section{Introduction}
+
+This library (based on the great \tikzname{} and \tikzname-cd packages) allows you to typeset ZX-calculus directly in \LaTeX{}. It comes with a default---but highly customizable---style:
+\begin{codeexample}[]
+  \begin{ZX}
+    \zxZ{\alpha} \arrow[r] & \zxFracX-{\pi}{4}
+  \end{ZX}
+\end{codeexample}
+Even if this has not yet been tested a lot, you can also use a ``phase in label'' style, without really changing the code:
+\begin{codeexample}[]
+  \begin{ZX}[phase in label right]
+    \zxZ{\alpha} \arrow[d] \\
+    \zxFracX-{\pi}{4}
+  \end{ZX}
+\end{codeexample}
+
+
+The goal is to provide an alternative to the great |tikzit| package: we wanted a solution that does not require the creation of an additional file, the use of an external software, and which automatically adapts the width of columns and rows depending on the content of the nodes (in |tikzit| one needs to manually tune the position of each node, especially when dealing with large nodes). Our library also provides a default style and tries to separate the content from the style: that way it should be easy to globally change the styling of a given project without redesigning all diagrams. However, it should be fairly easy to combine tikzit and this library: when some diagrams are easier to design in tikzit, then it should be possible to directly load the style of this library inside tikzit.
+
+This library is quite young, so feel free to propose improvements or report issues on \href{https://github.com/leo-colisson/zx-calculus}{\texttt{github.com/leo-colisson/zx-calculus}}. We will of course try to maintain backward compatibility as much as possible, but we can't guarantee at 100\% that small changes (spacing\dots{}) won't be made later. In case you want a completely unalterable style, just copy this library in your project forever! The documentation is also a work in progress, so feel free to check the code to discover new functionalities.
+
+\section{Installation}
+
+If your CTAN distribution is recent enough, you can directly insert in your file:
+% verse indents stuff, index adds to the index of command at the end of the file, || is a shortcut of \verb||
+\begin{verse}
+  \index{zx@\protect\texttt{zx-calculus} package}%
+  \index{Packages and files!zx-calculus@\protect\texttt{zx-calculus}}%
+  |\usepackage{zx-calculus}|%
+\end{verse}
+or load \tikzname{} and then use:
+\begin{verse}%
+   \index{cd@\protect\texttt{zx-calculus} library}%
+   \index{Libraries!cd@\protect\texttt{zx-calculus}}%
+   |\usetikzlibrary{zx-calculus}|%
+\end{verse}
+If this library is not yet packaged into CTAN (which is very likely in 2021), you must first download \mylink{https://github.com/leo-colisson/zx-calculus/blob/main/tikzlibraryzx-calculus.code.tex}{\texttt{tikzlibraryzx-calculus.code.tex}} and \mylink{https://github.com/leo-colisson/zx-calculus/blob/main/zx-calculus.sty}{\texttt{zx-calculus.sty}} (right-click on ``Raw'' and ``Save link as'') and save them at the root of your project.
+
+\section{Usage}
+
+\subsection{Add a diagram}
+\begin{pgfmanualentry}
+  \extractcommand\zx\opt{\oarg{options}}\marg{your diagram}\@@
+  \extractenvironement{ZX}\opt{\oarg{options}}\@@
+  \pgfmanualbody
+  You can create a new ZX-diagram either with a command (quicker for inline diagrams) or with an environment. The \meta{options} can be used to locally change the style of the diagram, using the same options as the |{tikz-cd}| environment (from the \mylink{https://www.ctan.org/pkg/tikz-cd}{\texttt{tikz-cd} package}). The \meta{your diagram} argument, or the content of |{ZX}| environment is a \tikzname{} matrix of nodes, exactly like in the |tikz-cd| package: columns are separated using |&|, columns using |\\|, and nodes are created using \verb#|[tikz style]| node content# or with shortcut commands presented later in this document (recommended). Content is typeset in math mode by default, and diagrams can be included in any equation. Wires can be added like in |tikz-cd| (see more below) using |\arrow| or |\ar|: we provide later recommended styles to quickly create different kinds of wires which can change with the configured style.
+{\catcode`\|=12 % Ensures | is not anymore \verb|...|
+% Do not indent not to put space in final code
+\begin{codeexample}[]
+Spider \zx{\zxZ{\alpha}}, equation $\zx{\zxZ{}} = \zx{\zxX{}}$ %
+and custom diagram: %
+\begin{ZX}[red]
+  \zxZ{\beta} \arrow[r]                           & \zxZ{\alpha} \\
+  |[fill=pink,draw]| \gamma \arrow[ru,bend right]
+\end{ZX}
+\end{codeexample}
+}
+\end{pgfmanualentry}
+
+\subsection{Nodes}
+
+The following commands are useful to create different kinds of nodes. Always add empty arguments like |\example{}| if none are already present, otherwise if you type |\example| we don't guarantee backward compatibility.
+
+\begin{command}{\zxEmptyDiagram{}}
+  Create an empty diagram.
+\begin{codeexample}[width=3cm]
+\begin{ZX}
+  \zxEmptyDiagram{}
+\end{ZX}
+\end{codeexample}
+\end{command}
+
+
+\begin{pgfmanualentry}
+  \extractcommand\zxNone\opt{+}\opt{-}\marg{text}\@@
+  \extractcommand\zxN\opt{+}\opt{-}\marg{text}\@@
+  \pgfmanualbody
+  Adds an empty node with |\zxNone{}| (alias |\zxN{}|). |\zxNone| is just a coordinate, but |\zxNone-{}| and \verb#\zxNone|{}# are actually nodes with |inner sep=0| along one direction. For that reason, they still have a tiny height or width (impossible to remove as far as I know). If you don't want to get holes when connecting multiple wires to them, it is therefore necessary to use the |wire centered| style for straight lines or |C|-like wires (alias |wc|), or |between none| style (alias |bn|) for other curved lines. Moreover, you should also add column and row spacing |&[\zxWCol]| and |\\[\zxWRow]| to avoid too shrinked diagrams when only wires are involved. The \verb#-|+# decorations are used to add a bit of (respectively) horizontal (\verb#\zxNone-{}#), vertical (\verb#\zxNone|{}#) and both (\verb#\zxNone+{}#) spacing (I don't know how to add \verb#|# in the documentation of the function).
+\begin{codeexample}[width=3cm]
+\begin{ZX}
+  \zxNone{} \ar[C,d] \ar[rd,s,bn] &[\zxWCol] \zxNone{}\\[\zxWRow]
+  \zxNone{}          \ar[ru,s,bn] &          \zxNone{}
+\end{ZX}
+\end{codeexample}
+\end{pgfmanualentry}
+
+
+\begin{command}{\zxNoneDouble\opt{+-}\marg{text}}
+  Like |\zxNone|, but the spacing for \verb#+-|# is large enough to fake two lines in only one. Not extremely useful (or one needs to play with |start anchor=south,end anchor=north|).
+\begin{codeexample}[width=3cm]
+\begin{ZX}
+  \zxNoneDouble|{} \ar[r,s,start anchor=north,end anchor=south,ls=1.2] \ar[r,s,start anchor=south,end anchor=north,ls=1.2] &[\zxWCol] \zxNoneDouble|{}
+\end{ZX}
+\end{codeexample}
+\end{command}
+
+\begin{command}{\zxFracZ\opt{-}\marg{numerator}\opt{\oarg{numerator with parens}\oarg{denominator with parens}}\marg{denominator}}
+  Adds a Z node with a fraction, use the minus decorator to add a small minus in front (the default minus is very big).
+\begin{codeexample}[width=3cm]
+\begin{ZX}
+  \zxFracZ{\pi}{2} & \zxFracZ-{\pi}{2}
+\end{ZX}
+\end{codeexample}
+The optional arguments are useful when the numerator or the denominator need parens when they are written inline (in that case optional arguments must be specified): it will prove useful when using a style that writes the fraction inline, for instance the default style for labels:
+\begin{codeexample}[]
+Compare
+\begin{ZX}
+  \zxFracZ{a+b}[(a+b)][(c+d)]{c+d}
+\end{ZX} with %
+\begin{ZX}[phase in label right]
+  \zxFracZ{a+b}[(a+b)][(c+d)]{c+d}
+\end{ZX}
+\end{codeexample}
+\end{command}
+
+\begin{command}{\zxFracX\opt{-}\marg{numerator}\marg{denominator}}
+  Adds an X node with a fraction.
+\begin{codeexample}[width=3cm]
+\begin{ZX}
+  \zxFracX{\pi}{2} & \zxFracX-{\pi}{2}
+\end{ZX}
+\end{codeexample}
+\end{command}
+
+
+\begin{command}{\zxZ\opt{\oarg{other styles}}\marg{text}}
+  Adds a Z node.
+\begin{codeexample}[width=3cm]
+\begin{ZX}
+  \zxZ{} & \zxZ{\alpha} & \zxZ{\alpha + \beta} & \zxZ[text=red]{(a \oplus b)\pi}
+\end{ZX}
+\end{codeexample}
+\end{command}
+
+\begin{command}{\zxX\opt{\oarg{other styles}}\marg{text}}
+  Adds an X node.
+\begin{codeexample}[width=3cm]
+\begin{ZX}
+  \zxX{} & \zxX{\alpha} & \zxX{\alpha + \beta} & \zxX[text=green]{(a \oplus b)\pi}
+\end{ZX}
+\end{codeexample}
+\end{command}
+
+\begin{command}{\zxH\opt{\oarg{other styles}}}
+  Adds an Hadamard node. See also |H| wire style.
+\begin{codeexample}[width=3cm]
+\begin{ZX}
+  \zxNone{} \rar & \zxH{} \rar & \zxNone{}
+\end{ZX}
+\end{codeexample}
+\end{command}
+
+
+
+\begin{command}{\leftManyDots\opt{\oarg{text scale}\oarg{dots scale}}\marg{text}}
+  Shortcut to add a dots and a text next to it. It automatically adds the new column, see more examples below.
+\begin{codeexample}[]
+\begin{ZX}
+  \leftManyDots{n} \zxX{\alpha}
+\end{ZX}
+\end{codeexample}
+\end{command}
+
+\begin{command}{\leftManyDots\opt{\oarg{text scale}\oarg{dots scale}}\marg{text}}
+  Shortcut to add a dots and a text next to it. It automatically adds the new column, see more examples below.
+\begin{codeexample}[width=3cm]
+\begin{ZX}
+  \zxX{\alpha} \rightManyDots{m}
+\end{ZX}
+\end{codeexample}
+\end{command}
+
+\begin{command}{\middleManyDots{}}
+  Shortcut to add a dots and a text next to it. It automatically adds the new column, see more examples below.
+\begin{codeexample}[width=3cm]
+\begin{ZX}
+  \zxX{\alpha} \middleManyDots{} & \zxX{\beta}
+\end{ZX}
+\end{codeexample}
+\end{command}
+
+\begin{command}{\zxLoop\opt{\oarg{direction angle}\oarg{opening angle}\oarg{other styles}}}
+  Adds a loop in \meta{direction angle} (defaults to $90$), with opening angle \meta{opening angle} (defaults to $20$).
+\begin{codeexample}[width=3cm]
+\begin{ZX}
+  \zxX{\alpha} \zxLoop{} & \zxX{} \zxLoop[45]{} & \zxX{} \zxLoop[0][30][red]{}
+\end{ZX}
+\end{codeexample}
+\end{command}
+
+\begin{command}{\zxLoopAboveDots\opt{\oarg{opening angle}\oarg{other styles}}}
+  Adds a loop above the node with some dots.
+\begin{codeexample}[width=3cm]
+\begin{ZX}
+  \zxX{\alpha} \zxLoopAboveDots{}
+\end{ZX}
+\end{codeexample}
+\end{command}
+
+\noindent The previous commands can be useful to create this figure:
+\begin{codeexample}[width=0pt]% Forces code/example on two lines.
+\begin{ZX}
+  \leftManyDots{n} \zxX{\alpha} \zxLoopAboveDots{} \middleManyDots{} \ar[r,o'=60]
+      & \zxX{\beta} \zxLoopAboveDots{} \rightManyDots{m}
+\end{ZX}
+\end{codeexample}
+
+\subsection{Phase in label style}
+
+We also provide styles to place the phase on a label next to an empty node (not yet very well tested):
+
+\begin{pgfmanualentry}
+  \makeatletter
+  \def\extrakeytext{style, }
+  \extractkey/zx/styles rounded style/phase in content\@nil%
+  \extractkey/zx/styles rounded style/phase in label=style (default {})\@nil%
+  \extractkey/zx/styles rounded style/pil=style (default {})\@nil%
+  \extractkey/zx/styles rounded style/phase in label above=style (default {})\@nil%
+  \extractkey/zx/styles rounded style/pila=style (default {})\@nil%
+  \extractkey/zx/styles rounded style/phase in label below=style (default {})\@nil%
+  \extractkey/zx/styles rounded style/pilb=style (default {})\@nil%
+  \extractkey/zx/styles rounded style/phase in label right=style (default {})\@nil%
+  \extractkey/zx/styles rounded style/pilr=style (default {})\@nil%
+  \extractkey/zx/styles rounded style/phase in label left=style (default {})\@nil%
+  \extractkey/zx/styles rounded style/pill=style (default {})\@nil%
+  \makeatother
+  \pgfmanualbody
+  The above styles are useful to place a spider phase in a label outside the node. They can either be put on the style of a node to modify a single node at a time:
+\begin{codeexample}[]
+  \zx{\zxX[phase in label]{\alpha} \rar & \zxX{\alpha}}
+\end{codeexample}
+\noindent It can also be configured on a per-figure basis:
+\begin{codeexample}[]
+\zx[phase in label right]{
+  \zxZ{\alpha} \dar \\
+  \zxX{\alpha} \dar \\
+  \zxZ{}}
+\end{codeexample}
+\noindent or globally:
+\begin{codeexample}[]
+{
+  \tikzset{
+    /zx/user post preparation labels/.style={
+      phase in label={label position=-45, text=purple,fill=none}
+    }
+  }
+  \zx{
+    \zxFracX-{\pi}{2}
+  }
+}
+\end{codeexample}
+Note that we must use |user post preparation labels| and not |/zx/user overlay nodes| because this will be run after all the machinery for labels has been setup.
+
+  While |phase in content| forces the content of the node to be inside the node instead of inside a label (which is the default behavior), all other styles are special cases of |phase in label|. The \meta{style} parameter can be any style made for a tikz label:
+\begin{codeexample}[width=3cm]
+  \zx{
+    \zxX[phase in label={label position=45, text=purple}]{\alpha}
+  }
+\end{codeexample}
+
+For ease of use, the special cases of label position |above|, |below|, |right| and |left| have their respective shortcut style. The |pil*| versions are shortcuts of the longer style written above. For instance, |pilb| stands for |phase in label below|. Note also that by default labels will take some space, but it's possible to make them overlay without taking space using the |overlay| label style\dots{} however do it at your own risks as it can overlay the content around (also the text before and after):
+\begin{codeexample}[width=0pt]
+  \zx{
+    \zxZ[pilb]{\alpha+\beta} \rar & \zxX[pilb]{\gamma} \rar & \zxZ[pilb=overlay]{\gamma+\eta}
+  }
+\end{codeexample}
+The above also works for fractions:
+\begin{codeexample}[]
+\zx{\zxFracX[pilr]-{\pi}{2}}
+\end{codeexample}
+For fractions, you can configure how you want the label text to be displayed, either in a single line (default) or on two lines, like in nodes. The function |\zxConvertToFracInLabel| is in charge of that conversion, and can be changed to your needs to change this option document-wise. To use the same notation in both content and labels, you can do:
+\begin{codeexample}[width=0pt]
+  Compare
+  \begin{ZX}[phase in label right]
+    \zxFracZ{\pi}{2} \dar \\
+    \zxFracZ{a+b}[(a+b)][(c+d)]{c+d}
+  \end{ZX} with
+{\RenewExpandableDocumentCommand{\zxConvertToFracInLabel}{mmmmm}{
+    \zxConvertToFracInContent{#1}{#2}{#3}{#4}{#5}%
+  }
+  \begin{ZX}[phase in label right]
+    \zxFracZ{\pi}{2} \dar \\
+    \zxFracZ{a+b}[(a+b)][(c+d)]{c+d}
+  \end{ZX} (exact same code!)
+}
+\end{codeexample}
+Note that in |\zxFracZ{a+b}[(a+b)][(c+d)]{c+d}| the optional arguments are useful to put parens appropriately when the fraction is written inline.
+\end{pgfmanualentry}
+
+\begin{command}{\zxDebugMode{}}
+  If this macro is defined, debug mode is active. See below how it can be useful.
+\end{command}
+\begin{stylekey}{/tikz/every node/a=alias}
+  Shortcut to add an |alias| to a wire, and in debug mode it also displays the alias of the nodes next to it (very practical to quickly add wires as we will see later). To enable debug mode, just type |\def\zxDebugMode{}| before your drawing, potentially in a group like |{\def\zxDebugMode{} your diagram...}| if you want to apply it to a single diagram.
+
+  This will be very practical later when using names instead of directions to connect wires (this can improve readability and maintainability). This is added automatically in |/tikz/every node| style. Note that debug mode is effective only for |a| and not |alias|.
+\begin{codeexample}[width=3cm]
+  \begin{ZX}
+    \zxX[a=A]{} & \zxZ[a=B]{\beta}
+    \ar[from=A,to=B]
+  \end{ZX}
+  {\def\zxDebugMode{} %% Enable debug mode for next diagram%
+    \begin{ZX}
+      \zxX[a=A]{} & \zxZ[a=B]{\beta}
+      \ar[from=A,to=B]
+    \end{ZX}
+  }
+\end{codeexample}
+\end{stylekey}
+
+
+\subsection{Wires}
+
+\begin{pgfmanualentry}
+  \extractcommand\arrow\opt{\oarg{options}}\@@
+  \extractcommand\ar\opt{\oarg{options}}\@@
+  \pgfmanualbody
+  These synonym commands (actually coming from |tikz-cd|) are used to draw wires between nodes. We refer to |tikz-cd| for an in-depth documentation, but what is important for our purpose is that the direction of the wires can be specified in the \meta{options} using a string of letters |r| (right), |l| (left), |u| (up), |d| (down). It's also possible to specify a node alias as a source or destination as shown below.
+\begin{codeexample}[]
+\zx{\zxZ{} \ar[r] & \zxX{}} = \zx{\zxX{} \arrow[rd] \\ & \zxZ{}}
+\end{codeexample}
+  \meta{options} can also be used to add any additional style, either custom ones, or the ones defined in this library (this is recommended since it can be easily changed document-wise by simply changing the style). Multiple wires can be added in the same cell. Other shortcuts provided in |tikz-cd| like |\rar|\dots{} can be used.
+{\catcode`\|=12 % Ensures | is not anymore \verb|...|
+\begin{codeexample}[width=0pt]
+\begin{ZX}
+  \zxZ{\alpha} \arrow[d, C] % C = Bell-like wire
+               \ar[r,H,o']  % o' = top part of circle
+               % H adds Hadamard, combine with \zxHCol
+               \ar[r,H,o.] &[\zxHCol] \zxZ{\gamma}\\
+  \zxZ{\beta}  \rar        & \zxX{} \ar[ld,red,"\circ" {marking,blue}] \ar[rd,s] \\
+  \zxFracX-{\pi}{4}        & &\zxZ{}
+\end{ZX}
+\end{codeexample}
+}
+\end{pgfmanualentry}
+
+As explained in |tikz-cd|, there are further shortened forms:
+\begin{pgfmanualentry}
+  \extractcommand\rar\opt{\oarg{options}}\@@
+  \extractcommand\lar\opt{\oarg{options}}\@@
+  \extractcommand\dar\opt{\oarg{options}}\@@
+  \extractcommand\uar\opt{\oarg{options}}\@@
+  \extractcommand\drar\opt{\oarg{options}}\@@
+  \extractcommand\urar\opt{\oarg{options}}\@@
+  \extractcommand\dlar\opt{\oarg{options}}\@@
+  \extractcommand\ular\opt{\oarg{options}}\@@
+  \pgfmanualbody
+\end{pgfmanualentry}
+The first one is equivalent to
+\begin{verse}
+  |\arrow|{\oarg{options}}|{r}|
+\end{verse}
+and the other ones work analogously.
+
+Note that sometimes, it may be practical to properly organize big diagrams to increase readability. To that end, one surely wants to have a small and well indented matrix (emacs |M-x align-current| is very practical to indent matrices automatically). Unfortunately, adding wires inside the matrix can make the line really long and hard to read. Similarly, some nodes involving fractions or long expressions can also be quite long. It is however easy to increase readability (and maintainability) by moving the wires at the very end of the diagram, using |alias| (shortcut |a|) to connect nodes and |\def| to create shortcuts. Putting inside a macro with |\def| long node definitions can also be useful to keep small items in the matrix:
+\begin{codeexample}[width=0pt]
+\begin{ZX}[row sep=1pt,
+  execute at begin picture={%
+    %%% Definition of long items (the goal is to have a small and readable matrix
+    % (warning: macro can't have numbers in TeX. Also, make sure not to use existing names)
+    \def\Zpifour{\zxFracZ[a=Zpi4]-{\pi}{4}}%
+    \def\mypitwo{\zxFracX[a=mypi2]{\pi}{2}}%
+  }
+  ]
+  %%% Matrix: in emacs "M-x align-current" is practical to automatically format it.
+  %%% a is for 'alias'... but also provides a debug mode, see below.
+                &              &                   &                 & \zxZ[a=toprightpi]{\pi} \\
+  \zxN[a=in1]{} & \zxX[a=X1]{} &                   &                 &  & \zxN[a=out1]{}       \\
+                &              & \zxZ[a=xmiddle]{} & \mypitwo{}      &  & \zxN[a=out2]{}       \\
+  \zxN[a=in2]{} & \Zpifour{}   &                   & \zxX[a=Xdown]{} &  & \zxN[a=out3]{}
+  %%% Arrows
+  % Column 1
+  \ar[from=in1,to=X1]
+  \ar[from=in2,to=Zpi4]
+  % Column 2
+  \ar[from=X1,to=xmiddle,(.]
+  \ar[from=X1,to=toprightpi,<',H]
+  \ar[from=Zpi4,to=xmiddle,(']
+  \ar[from=Zpi4,to=Xdown,o.]
+  % Column 3
+  \ar[from=xmiddle,to=Xdown,s.]
+  \ar[from=xmiddle,to=mypi2]
+  % Column 4
+  \ar[from=mypi2,to=toprightpi,(']
+  \ar[from=mypi2,to=out1,<']
+  \ar[from=mypi2,to=out2]
+  \ar[from=Xdown,to=out3]
+\end{ZX}
+\end{codeexample}
+In that setting, it is often useful to enable the debug mode via |\def\zxDebugMode{}| as explained above to quickly visualize the alias given to each node (note that debug mode works with |a=| but not with |alias=|). For instance, it was easy to rewrite the above diagram by moving nodes in the matrix and arrows after checking their name on the produced pdf (NB: you can increase |column sep| and |row sep| temporarily to make the debug information more visible):
+\begin{codeexample}[width=0pt]
+{
+  \def\zxDebugMode{}%%%%
+  \begin{ZX}[row sep=1pt,
+    execute at begin picture={%
+      %%% Definition of long items (the goal is to have a small and readable matrix
+      % (warning: macro can't have numbers in TeX. Also, make sure not to use existing names)
+      \def\Zpifour{\zxFracZ[a=Zpi4]-{\pi}{4}}%
+      \def\mypitwo{\zxFracX[a=mypi2]{\pi}{2}}%
+    }
+    ]
+    %%% Matrix: in emacs "M-x align" is practical to automatically format it. a is for 'alias'
+    & \zxN[a=n]{}  & \zxZ[a=xmiddle]{}       &            & \zxN[a=out1]{} \\
+    \zxN[a=in1]{} & \Zpifour{}   & \zxX[a=Xdown]{}         & \mypitwo{} &                \\
+    &              &                         &            & \zxN[a=out2]{} \\
+    \zxN[a=in2]{} & \zxX[a=X1]{} & \zxZ[a=toprightpi]{\pi} &            & \zxN[a=out3]{}
+    %%% Arrows
+    % Column 1
+    \ar[from=in1,to=X1,s]
+    \ar[from=in2,to=Zpi4,.>]
+    % Column 2
+    \ar[from=X1,to=xmiddle,N'=70]
+    \ar[from=X1,to=toprightpi,H]
+    \ar[from=Zpi4,to=n,C] \ar[from=n,to=xmiddle,wc]
+    \ar[from=Zpi4,to=Xdown]
+    % Column 3
+    \ar[from=xmiddle,to=Xdown,C-]
+    \ar[from=xmiddle,to=mypi2,)]
+    % Column 4
+    \ar[from=mypi2,to=toprightpi,(']
+    \ar[from=mypi2,to=out1,<']
+    \ar[from=mypi2,to=out2,<.]
+    \ar[from=Xdown,to=out3,<.]
+  \end{ZX}
+}
+\end{codeexample}
+
+We give now a list of wire styles provided in this library (|/zx/wires definition/| is an automatically loaded style). We recommend using them instead of manual styling to ensure they are the same document-wise, but they can of course be customized to your need. Note that the name of the styles are supposed to graphically represent the action of the style, and some characters are added to precise the shape: typically |'| means top, |.| bottom, |X-| is right to X (or should arrive with angle 0), |-X| is left to X (or should leave with angle zero). These shapes are usually designed to work when the starting node is left most (or above of both nodes have the same column). But they may work both way for some of them.
+
+
+\begin{pgfmanualentry}
+  \makeatletter
+  \def\extrakeytext{style, }
+  \extractkey/zx/wires definition/C=radius ratio (default 1)\@nil%
+  \extractkey/zx/wires definition/C.=radius ratio (default 1)\@nil%
+  \extractkey/zx/wires definition/C'=radius ratio (default 1)\@nil%
+  \extractkey/zx/wires definition/C-=radius ratio (default 1)\@nil%
+  \makeatother
+  \pgfmanualbody
+  Bell-like wires with an arrival at ``right angle'', |C| represents the shape of the wire, while |.| (bottom), |'| (top) and |-| (side) represent (visually) its position. Combine with |wire centered| (|wc|) to avoid holes when connecting multiple wires.
+\begin{codeexample}[]
+  Bell pair \zx{\zxNone{} \ar[d,C,wc] \\[\zxWRow]
+                \zxNone{}}
+  and funny graph
+  \begin{ZX}
+    \zxX{} \ar[d,C] \ar[r,C']  & \zxZ{} \ar[d,C-]\\
+    \zxZ{} \ar[r,C.]           & \zxX{}
+  \end{ZX}.
+\end{codeexample}
+Note that this style is actually connecting the nodes using a perfect circle (it is \emph{not} based on |curve to|), and therefore should \emph{not} be used together with |in|, |out|, |looseness|\dots{} It has the advantage of connecting nicely nodes which are not aligned or with different shapes:
+\begin{codeexample}[]
+  \begin{ZX}
+    \zxX{\alpha} \ar[dr,C]\\
+    & \zxNone{}
+  \end{ZX}
+\end{codeexample}
+The \meta{radius ratio} parameter can be used to turn the circle into an ellipse using this ratio between both axis:
+\begin{codeexample}[]
+  \begin{ZX}
+    \zxX{\alpha}
+      \ar[dr,C=0.5,red]
+      \ar[dr,C,green]
+      \ar[dr,C=2,blue]
+      \ar[dr,C=3,purple]\\
+                        & \zxNone{}
+  \end{ZX}
+  \begin{ZX}
+    \zxX{} \ar[d,C=2] \ar[r,C'=2]  & \zxZ{} \ar[d,C-=2,H]\\
+    \zxZ{} \ar[r,C.=2]           & \zxX{}
+  \end{ZX}.
+\end{codeexample}
+\end{pgfmanualentry}
+
+
+\begin{pgfmanualentry}
+  \makeatletter
+  \def\extrakeytext{style, }
+  \extractkey/zx/wires definition/o'=angle (default 40)\@nil%
+  \extractkey/zx/wires definition/o.=angle (default 40)\@nil%
+  \extractkey/zx/wires definition/o-=angle (default 40)\@nil%
+  \extractkey/zx/wires definition/-o=angle (default 40)\@nil%
+  \makeatother
+  \pgfmanualbody
+  Curved wire, similar to |C| but with a soften angle (optionally specified via \meta{angle}, and globally editable with |\zxDefaultLineWidth|). Again, the symbols specify which part of the circle (represented with |o|) must be kept.
+\begin{codeexample}[width=3cm]
+  \begin{ZX}
+    \zxX{} \ar[d,-o] \ar[d,o-]\\
+    \zxZ{} \ar[r,o'] \ar[r,o.] & \zxX{}
+  \end{ZX}.
+\end{codeexample}
+ Note that these wires can be combined with |H|, |X| or |Z|, in that case one should use appropriate column and row spacing as explained in their documentation:
+\begin{codeexample}[width=3cm]
+  \begin{ZX}
+    \zxX{\alpha} \ar[d,-o,H] \ar[d,o-,H]\\[\zxHRow]
+    \zxZ{\beta} \rar & \zxZ{} \ar[r,o',X] \ar[r,o.,Z] &[\zxSCol] \zxX{}
+  \end{ZX}.
+\end{codeexample}
+\end{pgfmanualentry}
+
+\begin{pgfmanualentry}
+  \makeatletter
+  \def\extrakeytext{style, }
+  \extractkey/zx/wires definition/(=angle (default 30)\@nil%
+  \extractkey/zx/wires definition/)=angle (default 30)\@nil%
+  \extractkey/zx/wires definition/('=angle (default 30)\@nil%
+  \extractkey/zx/wires definition/('=angle (default 30)\@nil%
+  \makeatother
+  \pgfmanualbody
+  Curved wire, similar to |o| but can be used for diagonal items. The angle is, like in |bend right|, the opening angle from the line which links the two nodes. For the first two commands, the |(| and |)| symbols must be imagined as if the starting point was on top of the parens, and the ending point at the bottom.
+\begin{codeexample}[width=3cm]
+  \begin{ZX}
+    \zxX{} \ar[rd,(] \ar[rd,),red]\\
+    & \zxZ{}
+  \end{ZX}.
+\end{codeexample}
+Then, |('|=|(| and |(.|=|)|; this notation is, I think, more intuitive when linking nodes from left to right. |('| is used when going to top right and |(.| when going to bottom right.
+\begin{codeexample}[width=3cm]
+\begin{ZX}
+  \zxN{}                       & \zxX{}\\
+  \zxZ{} \ar[ru,('] \ar[rd,(.] & \\
+                               & \zxX{}
+\end{ZX}
+\end{codeexample}
+When the nodes are too far appart, the default angle of |30| may produce strange results as it will go above (for |('|) the vertical line. Either choose a shorter angle, or see |<'| instead.
+\end{pgfmanualentry}
+
+\begin{pgfmanualentry}
+  \makeatletter
+  \def\extrakeytext{style, }
+  \extractkey/zx/wires definition/s\@nil%
+  \extractkey/zx/wires definition/s'=angle (default 30)\@nil%
+  \extractkey/zx/wires definition/s.=angle (default 30)\@nil%
+  \extractkey/zx/wires definition/-s'=angle (default 30)\@nil%
+  \extractkey/zx/wires definition/-s.=angle (default 30)\@nil%
+  \extractkey/zx/wires definition/s'-=angle (default 30)\@nil%
+  \extractkey/zx/wires definition/s.-=angle (default 30)\@nil%
+  \makeatother
+  \pgfmanualbody
+  |s| is used to create a s-like wire, to have nicer soften diagonal lines between nodes. Other versions are soften versions (the input and output angles are not as sharp, and the difference angle can be configured as an argument or globally using |\zxDefaultSoftAngleS|). Adding |'| or |.| specifies if the wire is going up-right or down-right.
+\begin{codeexample}[width=3cm]
+  \begin{ZX}
+    \zxX{\alpha} \ar[s,rd] \\
+                           & \zxZ{\beta}\\
+    \zxX{\alpha} \ar[s.,rd] \\
+                           & \zxZ{\beta}\\
+                           & \zxZ{\alpha}\\
+    \zxX{\beta} \ar[s,ru] \\
+                           & \zxZ{\alpha}\\
+    \zxX{\beta} \ar[s',ru] \\
+  \end{ZX}
+\end{codeexample}
+|-| forces the angle on the side of |-| to be horizontal.
+\begin{codeexample}[width=3cm]
+  \begin{ZX}
+    \zxX{\alpha} \ar[s.,rd] \\
+                           & \zxZ{\beta}\\
+    \zxX{\alpha} \ar[-s.,rd] \\
+                           & \zxZ{\beta}\\
+    \zxX{\alpha} \ar[s.-,rd] \\
+                           & \zxZ{\beta}\\
+  \end{ZX}
+\end{codeexample}
+\end{pgfmanualentry}
+
+\begin{pgfmanualentry}
+  \makeatletter
+  \def\extrakeytext{style, }
+  \extractkey/zx/wires definition/ss\@nil%
+  \extractkey/zx/wires definition/ss.=angle (default 30)\@nil%
+  \extractkey/zx/wires definition/.ss=angle (default 30)\@nil%
+  \extractkey/zx/wires definition/sIs.=angle (default 30)\@nil%
+  \extractkey/zx/wires definition/.sIs=angle (default 30)\@nil%
+  \extractkey/zx/wires definition/ss.I-=angle (default 30)\@nil%
+  \extractkey/zx/wires definition/I.ss-=angle (default 30)\@nil%
+  \makeatother
+  \pgfmanualbody
+  |ss| is similar to |s| except that we go from top to bottom instead of from left to right. The position of |.| says if the node is wire is going bottom right (|ss.|) or bottom left (|.ss|).
+\begin{codeexample}[width=3cm]
+  \begin{ZX}
+    \zxX{\alpha} \ar[ss,rd] \\
+                           & \zxZ{\beta}\\
+    \zxX{\alpha} \ar[ss.,rd] \\
+                           & \zxZ{\beta}\\
+                           & \zxX{\beta} \ar[.ss,dl] \\
+    \zxZ{\alpha}\\
+                           & \zxX{\beta} \ar[.ss=40,dl] \\
+    \zxZ{\alpha}\\
+  \end{ZX}
+\end{codeexample}
+|I| forces the angle above (if in between the two |s|) or below (if on the same side as |.|) to be vertical.
+\begin{codeexample}[width=3cm]
+  \begin{ZX}
+    \zxX{\alpha} \ar[ss,rd] \\
+                           & \zxZ{\beta}\\
+    \zxX{\alpha} \ar[sIs.,rd] \\
+                           & \zxZ{\beta}\\
+    \zxX{\alpha} \ar[ss.I,rd] \\
+                           & \zxZ{\beta}\\
+                           & \zxX{\beta} \ar[.sIs,dl] \\
+    \zxZ{\alpha}\\
+                           & \zxX{\beta} \ar[I.ss,dl] \\
+    \zxZ{\alpha}\\
+  \end{ZX}
+\end{codeexample}
+\end{pgfmanualentry}
+
+
+\begin{pgfmanualentry}
+  \makeatletter
+  \def\extrakeytext{style, }
+  \extractkey/zx/wires definition/<'=angle (default 60)\@nil%
+  \extractkey/zx/wires definition/<.=angle (default 60)\@nil%
+  %\extractkey/zx/wires definition/^.=angle (default 60)\@nil%
+  %\extractkey/zx/wires definition/.^=angle (default 60)\@nil%
+  \extractkey/zx/wires definition/'v=angle (default 60)\@nil%
+  \extractkey/zx/wires definition/v'=angle (default 60)\@nil%
+  \makeatother
+  \pgfmanualbody
+  These keys are a bit like |('| or |(.| but the arrival angle is vertical (or horizontal for the |^| (up-down) and |v| (down-up) versions). As before, the position of the decorator |.|,|'| denote the direction of the wire.
+\begin{codeexample}[width=0cm]
+\begin{ZX}
+  \zxN{}                         & & \zxZ{}\\
+  \zxX{} \ar[rru,<'] \ar[rrd,<.] & \\
+  \zxN{}                         & & \zxZ{}\\
+\end{ZX}
+\end{codeexample}
+\begin{codeexample}[width=0cm]
+\begin{ZX}
+  \zxN{} & \zxFracX{\pi}{2} \ar[ddl,.^] \ar[ddr,^.] & \\
+         &                                & \\
+  \zxZ{} &                                & \zxX{}
+\end{ZX}
+\end{codeexample}
+\begin{codeexample}[width=0cm]
+\begin{ZX}
+  \zxZ{} &                                & \zxX{}\\
+         &                                & \\
+  \zxN{} & \zxX{} \ar[uul,'v] \ar[uur,v'] &
+\end{ZX}
+\end{codeexample}
+\end{pgfmanualentry}
+
+\begin{pgfmanualentry}
+  \makeatletter
+  \def\extrakeytext{style, }
+  \extractkey/zx/wires definition/3 dots=text (default =)\@nil%
+  \extractkey/zx/wires definition/3 vdots=text (default =)\@nil%
+  \makeatother
+  \pgfmanualbody
+  The styles put in the middle of the wire (without drawing the wire) $\dots$ (for |3 dots|) or $\vdots$ (for |3 vdots|). The dots are scaled according to |\zxScaleDots| and the text \meta{text} is written on the left. Use |&[\zxDotsRow]| and |\\[\zxDotsRow]| to properly adapt the spacing of columns and rows.
+\begin{codeexample}[width=3cm]
+\begin{ZX}
+  \zxZ{\alpha} \ar[r,o'] \ar[r,o.]
+               \ar[r,3 dots]
+               \ar[d,3 vdots={$n$\,}] &[\zxDotsCol] \zxFracX{\pi}{2}\\[\zxDotsRow]
+  \zxZ{\alpha} \rar             & \zxFracX{\pi}{2}
+\end{ZX}
+\end{codeexample}
+\end{pgfmanualentry}
+
+\begin{pgfmanualentry}
+  \makeatletter
+  \def\extrakeytext{style, }
+  \extractkey/zx/wires definition/H\@nil%
+  \extractkey/zx/wires definition/Z\@nil%
+  \extractkey/zx/wires definition/X\@nil%
+  \makeatother
+  \pgfmanualbody
+  Adds a |H| (Hadamard), |Z| or |X| node (without phase) in the middle of the wire. Width of column or rows should be adapted accordingly using |\zxNameRowcolFlatnot| where |Name| is replaced by |H|, |S| (for ``spiders'', i.e.\ |X| or |Z|), |HS| (for both |H| and |S|) or |W|, |Rowcol| is either |Row| (for changing row sep) or |Col| (for changing column sep) and |Flatnot| is empty or |Flat| (if the wire is supposed to be a straight line as it requires more space). For instance:
+\begin{codeexample}[width=3cm]
+\begin{ZX}
+  \zxZ{\alpha} \ar[d] \ar[r,o',H] \ar[r,o.,H] &[\zxHCol] \zxX{\beta}\\
+  \zxZ{\alpha}  \ar[d,-o,X] \ar[d,o-,Z]                        \\[\zxHSRow]
+  \zxX{\gamma}
+\end{ZX}
+\end{codeexample}
+\end{pgfmanualentry}
+
+\begin{pgfmanualentry}
+  \makeatletter
+  \def\extrakeytext{style, }
+  \extractkey/zx/wires definition/wire centered\@nil%
+  \extractkey/zx/wires definition/wc\@nil%
+  \extractkey/zx/wires definition/wire centered start\@nil%
+  \extractkey/zx/wires definition/wcs\@nil%
+  \extractkey/zx/wires definition/wire centered end\@nil%
+  \extractkey/zx/wires definition/wce\@nil%
+  \makeatother
+  \pgfmanualbody
+  When the wires are drawn, they start from the border of the node. However, it can make strange results if nodes do not have the same size, or if we connect none nodes (we will get holes). It is therefore possible to force the wire to start at the center of the node (|wire centered start|, alias |wcs|), to end at the center of the node -|wire centered end|, alias |wce|) or both (|wire centered|, alias |wc|). See also |between node| to also increase looseness when connecting only wires.
+\begin{codeexample}[width=3cm]
+\begin{ZX}
+  \zxZ{} \ar[o',r] \ar[o.,r]       & \zxX{\alpha}\\
+  \zxZ{} \ar[o',r,wc] \ar[o.,r,wc] & \zxX{\alpha}
+\end{ZX}
+\end{codeexample}
+Without |wc| (note that because there is no node, we need to use |&[\zxWCol]| (for columns) and |\\[\zxWRow]| (for rows) to get nicer spacing):
+\begin{codeexample}[width=3cm]
+\zx{\zxNone{} \rar &[\zxWCol] \zxNone{} \rar &[\zxWCol] \zxNone{} }
+\end{codeexample}
+With |wc|:
+\begin{codeexample}[width=3cm]
+\zx{\zxNone{} \rar[wc] &[\zxWCol] \zxNone{} \rar[wc] &[\zxWCol] \zxNone{}}
+\end{codeexample}
+\end{pgfmanualentry}
+
+\begin{stylekey}{/zx/wires definition/ls=looseness}
+  Shortcut for |looseness|, allows to quickly redefine looseness. Use with care (or redefine style directly). Note that you can also change yourself other values, like |in|, |out|\dots
+\begin{codeexample}[]
+\begin{ZX}
+  \zxZ{} \ar[rd,s] \\
+                   & \zxX{}\\
+  \zxZ{} \ar[rd,s,ls=3] \\
+                   & \zxX{}
+\end{ZX}
+\end{codeexample}
+\end{stylekey}
+
+\begin{pgfmanualentry}
+  \makeatletter
+  \def\extrakeytext{style, }
+  \extractkey/zx/wires definition/between none\@nil%
+  \extractkey/zx/wires definition/bn\@nil%
+  \makeatother
+  \pgfmanualbody
+  When drawing wires only, the default looseness may not be good looking and holes may appear in the line. This style (whose alias is |bn|) should therefore be used when curved wires (except |C| which already has a good looseness, use |wire centered| instead) are connected together. In that case, also make sure to separate columns using |&[\zxWCol]| and row using |\\[\zxWRow]|.
+\begin{codeexample}[width=3cm]
+A swapped Bell pair is %
+\begin{ZX}
+  \zxNone{} \ar[C,d,wc] \ar[rd,s,bn] &[\zxWCol] \zxNone{} \\[\zxWRow]
+  \zxNone{}             \ar[ru,s,bn] &          \zxNone{}
+\end{ZX}
+\end{codeexample}
+\end{pgfmanualentry}
+
+\section{Advanced styling}
+
+\subsection{Overlaying or creating styles}
+
+It is possible to arbitrarily customize the styling, create or update ZX or tikz styles\dots{} First, any option that can be given to a |tikz-cd| matrix can also be given to a |ZX| environment (we refer to the manual of |tikz-cd| for more details). We also provide overlays to quickly modify the ZX style.
+
+\begin{stylekey}{/zx/default style nodes}
+  This is where the default style must be loaded. By default, it simply loads the (nested) style packed with this library, |/zx/styles/rounded style|. You can change the style here if you would like to globally change a style.
+
+  Note that a style must typically define at least |zxZ2|, |zxX2|, |zxFracZ6|, |zxFracX6|, |\zxH|, |zxHSmall|, |zxNoPhaseSmallZ|, |zxNoPhaseSmallX|, |zxNone{,+,-,I}|, |zxNoneDouble{,+,-,I}| and all the |phase in label*|, |pil*| styles (see code on how to define them). Because the above styles (notably |zxZ*| and |zxFrac*|) are slightly complex to define (this is needed in order to implement |phase in label|), it may be quite long to implement them all properly by yourself.
+
+  For that reason, it may be easier to load our default style and overlay only some of the styles we use (see example in |/zx/user overlay nodes| right after). You can check our code in |/zx/styles/rounded style| to see what you can redefine (intuitively, the styles like |my style name| should be callable by the end user, |myStyleName| may be redefined by users or used in tikzit, and |my at style@name| are styles that should not be touched by the user). The styles that have most interests are |zxNoPhase| (for Z and X nodes without any phase inside), |zxShort| (for Z and X nodes for fractions typically), |zxLong| (for other Z and X nodes) and |stylePhaseInLabel| (for labels when using |phase in label|). These basic styles are extended to add colors (just add |Z|/|X| after the name) like |zxNoPhaseZ|\dots{} You can change them, but if you just want to change the color, prefer to redefine |colorZxZ|/|colorZxZ| instead (note that this color does not change |stylePhaseInLabelZ/X|, so you are free to redefine these styles as well). All the above styles can however be called from inside a tikzit style, if you want to use tikzit internally (make sure to load this library then in |*.tikzdefs|).
+
+  Note however that you should avoid to call these styles from inside |\zx{...}| since |\zx*| and |\zxFrac*| are supposed to choose automatically the good style for you depending on the mode (fractions, labels in phase\dots{}). For more details, we encourage the advanced users too look at the code of the library, and examples for simple changes will be presented now.
+\end{stylekey}
+
+\begin{stylekey}{/zx/user overlay nodes}
+  If a user just wants to overlay some parts of the node styles, add your changes here.
+\begin{codeexample}[]
+  {\tikzset{
+      /zx/user overlay nodes/.style={
+        zxH/.append style={dashed,inner sep=2mm}
+      }}
+    \zx{\zxNone{} \rar & \zxH{} \rar & \zxNone{}}
+  }
+\end{codeexample}
+You can also change it on a per-diagram basis:
+\begin{codeexample}[]
+  \zx[text=yellow,/zx/user overlay nodes/.style={
+    zxSpiders/.append style={thick,draw=purple}}
+  ]{\zxX{} \rar & \zxX{\alpha} \rar & \zxFracZ-{\pi}{2}}
+\end{codeexample}
+The list of keys that can be changed will be given below in |/zx/styles/rounded style/*|.
+\end{stylekey}
+
+\begin{stylekey}{/zx/default style wires}
+  Default style for wires. Note that |/zx/wires definition/| is always loaded by default, and we don't add any other style for wires by default. But additional styles may use this functionality.
+\end{stylekey}
+
+\begin{stylekey}{/zx/user overlay wires}
+  The user can add here additional styles for wires.
+\begin{codeexample}[]
+\begin{ZX}[/zx/user overlay wires/.style={thick,->,C/.append style={dashed}}]
+  \zxNone{} \ar[d,C] \rar[] &[\zxWCol] \zxNone{}\\[\zxWRow]
+  \zxNone{} \rar[] & \zxNone{}
+\end{ZX}
+\end{codeexample}
+\end{stylekey}
+
+\begin{stylekey}{/zx/styles/rounded style}
+  This is the style loaded by default. It contains internally other (nested) styles that must be defined for any custom style.
+\end{stylekey}
+
+We present now all the properties that a new node style must have (and that can overlayed as explained above).
+\begin{stylekey}{/zx/styles/rounded style/zxAllNodes}
+  Style applied to all nodes.
+\end{stylekey}
+
+\begin{stylekey}{/zx/styles/rounded style/zxEmptyDiagram}
+  Style to draw an empty diagram.
+\end{stylekey}
+
+\begin{pgfmanualentry}
+  \makeatletter
+  \def\extrakeytext{style, }
+  \extractkey/zx/styles/rounded style/zxNone\@nil%
+  \extractkey/zx/styles/rounded style/zxNone+\@nil%
+  \extractkey/zx/styles/rounded style/zxNone-\@nil%
+  \extractkey/zx/styles/rounded style/zxNoneI\@nil%
+  \makeatother
+  \pgfmanualbody
+  Styles for None wires (no inner sep, useful to connect to wires). The |-|,|I|,|+| have additional horizontal, vertical, both spaces.
+\end{pgfmanualentry}
+
+\begin{pgfmanualentry}
+  \makeatletter
+  \def\extrakeytext{style, }
+  \extractkey/zx/styles/rounded style/zxNoneDouble\@nil%
+  \extractkey/zx/styles/rounded style/zxNoneDouble+\@nil%
+  \extractkey/zx/styles/rounded style/zxNoneDouble-\@nil%
+  \extractkey/zx/styles/rounded style/zxNoneDoubleI\@nil%
+  \makeatother
+  \pgfmanualbody
+  Like |zxNone|, but with more space to fake two nodes on a single line (not very used).
+\end{pgfmanualentry}
+
+\begin{stylekey}{/zx/styles/rounded style/zxSpiders}
+  Style that apply to all circle spiders.
+\end{stylekey}
+
+\begin{stylekey}{/zx/styles/rounded style/zxNoPhase}
+  Style that apply to spiders without any angle inside. Used by |\zxX{}| when the argument is empty.
+\end{stylekey}
+
+\begin{stylekey}{/zx/styles/rounded style/zxNoPhaseSmall}
+  Like |zxNoPhase| but for spiders drawn in between wires.
+\end{stylekey}
+
+\begin{stylekey}{/zx/styles/rounded style/zxShort}
+  Spider with text but no inner space. Used notably to obtain nice fractions.
+\end{stylekey}
+
+\begin{stylekey}{/zx/styles/rounded style/zxLong}
+  Spider with potentially large text. Used by |\zxX{\alpha}| when the argument is not empty.
+\end{stylekey}
+
+\begin{pgfmanualentry}
+  \makeatletter
+  \def\extrakeytext{style, }
+  \extractkey/zx/styles/rounded style/zxNoPhaseZ\@nil%
+  \extractkey/zx/styles/rounded style/zxNoPhaseX\@nil%
+  \extractkey/zx/styles/rounded style/zxNoPhaseSmallZ\@nil%
+  \extractkey/zx/styles/rounded style/zxNoPhaseSmallX\@nil%
+  \extractkey/zx/styles/rounded style/zxShortZ\@nil%
+  \extractkey/zx/styles/rounded style/zxShortX\@nil%
+  \extractkey/zx/styles/rounded style/zxLongZ\@nil%
+  \extractkey/zx/styles/rounded style/zxLongX\@nil%
+  \makeatother
+  \pgfmanualbody
+  Like above styles, but with colors of |X| and |Z| spider added. The color can be changed globally by updating the |colorZxX| color. By default we use:
+  \begin{verse}
+    |\definecolor{colorZxZ}{RGB}{204,255,204}|\\
+    |\definecolor{colorZxX}{RGB}{255,136,136}|\\
+    |\definecolor{colorZxH}{RGB}{255,255,0}|
+  \end{verse}
+  as the second recommendation in \href{https://zxcalculus.com/accessibility.html}{\texttt{zxcalculus.com/accessibility.html}}.
+\end{pgfmanualentry}
+
+\begin{stylekey}{/zx/styles/rounded style/zxH}
+  Style for Hadamard spiders, used by |\zxH{}| and uses the color |colorZxH|.
+\end{stylekey}
+
+\begin{stylekey}{/zx/styles/rounded style/zxHSmall}
+  Like |zxH| but for Hadamard on wires, (see |H| style).
+\end{stylekey}
+
+\begin{pgfmanualentry}
+  \extractcommand\zxConvertToFracInContent\marg{sign}\marg{num no parens}\marg{denom no parens}\marg{nom parens}\marg{denom parens}\@@
+  \extractcommand\zxConvertToFracInLabel\@@
+  \pgfmanualbody
+  These functions are not meant to be used, but redefined using something like (we use |\zxMinus| as a shorter minus compared to $-$):
+\begin{verse}
+  |\RenewExpandableDocumentCommand{\zxConvertToFracInLabel}{mmmmm}{%|\\
+  |  \ifthenelse{\equal{#1}{-}}{\zxMinus}{#1}\frac{#2}{#3}%|\\
+  |}|
+\end{verse}
+This is used to change how the library does the conversion between |\zxFrac| and the actual written text (either in the node content or in the label depending on the function). The first argument is the sign (string |-| for minus, anything else must be written in place of the minus), the second and third argument are the numerator and denominator of the fraction when used in |\frac{}{}| while the last two arguments are the same except that they include the parens which should be added when using an inline version. For instance, one could get a call |\zxConvertToFracInLabel{-}{a+b}{c+d}{(a+b)}{(c+d)}|. See part on labels to see an example of use.
+\end{pgfmanualentry}
+
+\noindent We also define several spacing commands that can be redefined to your needs:
+\begin{pgfmanualentry}
+  \extractcommand\zxHCol{}\@@
+  \extractcommand\zxHRow{}\@@
+  \extractcommand\zxHColFlat{}\@@
+  \extractcommand\zxHRowFlat{}\@@
+  \extractcommand\zxSCol{}\@@
+  \extractcommand\zxSRow{}\@@
+  \extractcommand\zxSColFlat{}\@@
+  \extractcommand\zxSRowFlat{}\@@
+  \extractcommand\zxHSCol{}\@@
+  \extractcommand\zxHSRow{}\@@
+  \extractcommand\zxHSColFlat{}\@@
+  \extractcommand\zxHSRowFlat{}\@@
+  \extractcommand\zxWCol{}\@@
+  \extractcommand\zxWRow{}\@@
+  \extractcommand\zxDotsCol{}\@@
+  \extractcommand\zxDotsRow{}\@@
+  \pgfmanualbody
+  These are spaces, to use like |&[\zxHCol]| or |\\[\zxHRow]| in order to increase the default spacing of rows and columns depending on the style of the wire. |H| stands for Hadamard, |S| for Spiders, |W| for Wires only, |HS| for both Spiders and Hadamard, |Dots| for the 3 dots styles. And of course |Col| for columns, |Row| for rows.
+\end{pgfmanualentry}
+
+
+\begin{pgfmanualentry}
+  \extractcommand\zxDefaultSoftAngleS{}\@@
+  \extractcommand\zxDefaultSoftAngleO{}\@@
+  \extractcommand\zxDefaultSoftAngleChevron{}\@@
+  \pgfmanualbody
+  Default opening angles of |S|, |o| and |v|/|<| wires. Defaults to respectively $30$, $40$ and $45$.
+\end{pgfmanualentry}
+
+\begin{command}{\zxMinus{}}
+  The minus sign used in fractions.
+\end{command}
+
+\subsection{Further customization}
+
+You can further customize your drawings using any functionality from \tikzname{} and |tikz-cd| (but it is of course at your own risk). For instance, we can change the separation between rows and/or columns for a whole picture using:
+\begin{codeexample}[width=0pt]
+  \begin{ZX}[row sep=1mm]
+                &                                         &                        & & \zxZ{\pi} \\
+    \zxN{} \rar & \zxX{} \ar[rd,(.] \ar[urrr,(',H]        &                        & &  & \zxN{} \\
+                &                                         & \zxZ{} \ar[rd,s.] \rar &
+       \zxFracX{\pi}{2} \ar[uur,('] \ar[rru,<'] \ar[rr] &  & \zxN{} \\
+    \zxN{} \rar & \zxFracZ-{\pi}{4} \ar[ru,('] \ar[rr,o.] &            & \zxX{} \ar[rr] &  & \zxN{}
+  \end{ZX}
+\end{codeexample}
+Or we can define our own style to create blocks:
+{\catcode`\|=12 % Ensures | is not anymore \verb|...|
+\begin{codeexample}[width=0pt]
+{ % \usetikzlibrary{shadows}
+  \tikzset{
+    my bloc/.style={
+      anchor=center,
+      inner sep=2pt,
+      inner xsep=.7em,
+      minimum height=3em,
+      draw,
+      thick,
+      fill=blue!10!white,
+      double copy shadow={opacity=.5},tape,
+    }
+  }
+  \zx{|[my bloc]| f \rar &[1mm] |[my bloc]| g \rar &[1mm] \zxZ{\alpha} \rar & \zxNone{}}
+}
+\end{codeexample}
+}
+We can also use for instance |fit|, |alias|, |execute at end picture| and layers (the user can use |background| for things behind the drawing, |box| for special nodes above the drawings (like multi-column nodes, see below), and |foreground| which is even higher) to do something like that:
+{\catcode`\|=12 % Ensures | is not anymore \verb|...|
+\begin{codeexample}[width=3cm]
+% \usetikzlibrary{fit}
+\begin{ZX}[
+  execute at end picture={
+    \node[
+      inner sep=2pt,
+      node on layer=background, %% Ensure the node is behind the drawing
+      rounded corners,
+      draw=blue,
+      dashed,
+      fill=blue!50!white,
+      opacity=.5,
+      fit=(cnot1)(cnot2), %% position of the node, thanks fit library
+      "\textsc{cnot}" above %% Adds label, thanks quote library
+    ] {};
+  }
+  ]
+  \zxNone{} \rar & \zxZ[alias=cnot1]{} \dar \rar & \zxNone{}\\
+  \zxNone{} \rar & \zxX[alias=cnot2]{} \rar      & \zxNone{}\\
+\end{ZX}
+\end{codeexample}
+}
+This can also be used to fake multi-columns nodes (I need to check later if I can facilitate this kind of operation from the library directly):
+{\catcode`\|=12 % Ensures | is not anymore \verb|...|
+\begin{codeexample}[width=3cm]
+% \usetikzlibrary{fit}
+\tikzset{
+  my box/.style={inner sep=4pt, draw, thick, fill=white,anchor=center},
+}
+\begin{ZX}[
+  execute at end picture={
+    \node[
+      my box,
+      node on layer=box, %% Ensure the node is above the wires
+      fit=(f1)(f2), %% position of the node, thanks fit library
+      label={[node on layer=box]center:$f$},
+    ] {};
+  }
+  ]
+  \zxNoneDouble+[alias=f1]{} \rar &[1mm] |[my box]| g \rar & \zxNone{}\\
+  \zxNoneDouble+[alias=f2]{} \rar &[1mm] \zxZ{} \rar       & \zxNone{}\\
+\end{ZX}
+\end{codeexample}
+}
+\section{Acknowledgement}
+
+I'm very grateful of course to everybody that worked on these amazing field which made diagramatic quantum computing possible, and to the many StackExchange users (sorry, I don't want to risk an incomplete list) that helped me to understand a bit more \LaTeX and \tikzname. I also thank Robert Booth for making me realize how my old style was bad, and for giving advices on how to improve it. Thanks to John van de Wetering, whose style has also been a source of inspiration.
+
+\printindex
+
+
+\end{document}


Property changes on: trunk/Master/texmf-dist/doc/latex/zx-calculus/zx-calculus.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/zx-calculus/tikzlibraryzx-calculus.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/zx-calculus/tikzlibraryzx-calculus.code.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/zx-calculus/tikzlibraryzx-calculus.code.tex	2021-10-15 22:13:43 UTC (rev 60768)
@@ -0,0 +1,945 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Version: 2021/10/15
+%%% License: MIT
+%%% Author: Léo Colisson
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% A tikzlibrary[libraryName].code.tex is loaded automatically by tikz when using
+% \usetikzlibrary{libraryName}. Therefore, you should just use
+% \usetikzlibrary{zx} to load this library. We also provide a package to
+% directly load this library using \usepackage{zx}.
+
+\RequirePackage{amssymb} % For short minus
+\RequirePackage{etoolbox}
+\RequirePackage{ifthen} % For conditions
+\RequirePackage{xparse} % For NewDocumentComments
+\RequirePackage{bm} % For bold math fonts
+
+\usetikzlibrary{cd,backgrounds,positioning,shapes,calc}
+% Declare layers.
+\pgfdeclarelayer{background} % Fox boxes using "fit" to group parts of the graph.
+\pgfdeclarelayer{edgelayer} % For edges that are explicitely defined "wc"
+\pgfdeclarelayer{nodelayer} % For nodes... in theory, this fails for now. https://tex.stackexchange.com/questions/618823/node-on-layer-style-in-tikz-matrix-tikzcd
+\pgfdeclarelayer{main}
+\pgfdeclarelayer{box} % For boxes using "fit" to fake multi-column boxes
+\pgfdeclarelayer{labellayer} % For labels... in theory, this fails for now. https://tex.stackexchange.com/questions/618823/node-on-layer-style-in-tikz-matrix-tikzcd
+\pgfdeclarelayer{foreground} % For the user, if they want to put anything really above everything.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%% User modifiable variables
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Define colors, can be redefine by user
+\definecolor{colorZxZ}{RGB}{204,255,204}
+\definecolor{colorZxX}{RGB}{255,136,136}
+\definecolor{colorZxH}{RGB}{255,255,0}
+
+%%% Some wires (the one having an intermediate H, X, or S gate) may need some additional space for
+%%% specific columns.
+%%% Use these spaces like &[\zxHCol] or \\[\zxHRow] in that case
+%% Defines the space to add for columns and rows containing a connection with Hadamard
+% This is for "curved" wires
+\newcommand{\zxHCol}{1mm}
+\newcommand{\zxHRow}{1mm}
+% This is for "flat" wires (usually takes more space)
+\newcommand{\zxHColFlat}{1.5mm}
+\newcommand{\zxHRowFlat}{1.5mm}
+%% Defines the space to add for columns and rows containing a connection with small X/Z
+\newcommand{\zxSCol}{1mm}
+\newcommand{\zxSRow}{1mm}
+\newcommand{\zxSColFlat}{1.5mm}
+\newcommand{\zxSRowFlat}{1.5mm}
+%% Defines the space to add for columns having both H and Spiders
+\newcommand{\zxHSCol}{1mm}
+\newcommand{\zxHSRow}{1mm}
+\newcommand{\zxHSColFlat}{1mm}
+\newcommand{\zxHSRowFlat}{1mm}
+%% Wires only: when adding only wires with empty nodes, the space between columns can be too small. Useful not to shrink swap gates...
+\newcommand{\zxWCol}{.55em}
+\newcommand{\zxWRow}{.55em}
+%% When vdots/dots are used in lines
+\newcommand{\zxDotsCol}{3mm}
+\newcommand{\zxDotsRow}{3mm}
+
+
+% Angles by default for s and o related arrows
+\def\zxDefaultSoftAngleS{30}
+\def\zxDefaultSoftAngleN{60}
+\def\zxDefaultSoftAngleO{40}
+\def\zxDefaultSoftAngleChevron{60}
+
+% Scale to use when scaling 3 dots
+\def\zxScaleDots{.7}
+
+% 0.4pt is default in tikz. Also used to ensure it has not been modified document wise by other libraries
+% (quantikz notably changes this parameter).
+\newcommand{\zxDefaultLineWidth}{0.4pt}
+
+% For phase in content: How to convert sign ("-" for minus, nothing for "+", anything else should be inserted directly),
+% above fraction (no parens), below fraction (no parens), above fraction (with parens), below fraction (with parens)
+\NewExpandableDocumentCommand{\zxConvertToFracInContent}{mmmmm}{%
+  \ifthenelse{\equal{#1}{-}}{\zxMinus}{#1}\frac{#2}{#3}%
+}
+
+% For phase in label: How to convert sign ("-" for minus, nothing for "+", anything else should be inserted directly),
+% above fraction (no parens), below fraction (no parens), above fraction (with parens), below fraction (with parens)
+\NewExpandableDocumentCommand{\zxConvertToFracInLabel}{mmmmm}{%
+  \ifthenelse{\equal{#1}{-}}{\zxMinus}{#1}#4/#5%
+}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%% Tikz styles
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Styles. User should not modify "wires definition", but is free to change:
+% - "/zx/default style nodes/" to change completely the node style
+% - "/zx/user overlay nodes" to add stuff on current node style
+% - "/zx/default style wires" to change the wire style
+% - "/zx/user overlay wires/" to add stuff on wire style
+% The user is not supposed to use node styles directly (use \zxZ{}, \zxZ{\alpha+\beta}, \zxFrac-{\pi}{4}...)
+% but is free (and encouraged) to use the styles in "wires definition" like \ar[r,o'].
+\tikzset{
+  /zx/wires definition/.style={
+    %%% Basic default properties
+    draw,
+    -,
+    line width=\zxDefaultLineWidth,
+    %%% Useful shortcut (shorter lines means easy "align" of & symbols. Love M-x align in emacs btw.)
+    ls/.style={looseness=##1},
+    looseness wires only/.style={% Looseness used for wires only.
+      looseness=1.2,
+    },
+    lw/.style={looseness wires only},
+    % Use this when you are drawing lines between none nodes only (like swap gates...)
+    between none/.style={
+      looseness wires only,
+      wire centered
+    },
+    bn/.style={
+      between none
+    },
+    % ------------------------------
+    % Practical stuff to draw lines easily:
+    % Prefer to use these are they can be easily customized for each style and shorter to type.
+    % Note that the letter is supposed to represent the shape of the link
+    % dots/dashes are used to specify the position of the arrow.
+    % Typically ' means top, . bottom, X- is right to X (or should arrive with angle 0),
+    % -X is left to X (or should leave with angle zero). These shapes are usually designed to
+    % work when the starting node is left most (or above of both nodes have the same column).
+    % But they may work both way for some of them.
+    % ------------------------------
+    %%% Cup/Cap
+    % Like a C shape (with without a perfect half circle). Useful maybe when perfect circles are too big.
+    % If only tex was a functional language... https://tex.stackexchange.com/questions/618955
+    C at generic/.style n args={8}{ % min/max, angle1, angle2, anchor, \x or \y, \y or \x, where to move,radius code (for circle should be "radius=\n3")
+      to path={
+        \pgfextra{ %% <- we will use def... so need to "exit" a few seconds pgf
+          % Test if tikztostart is a point or a node, and define StartPoint accordingly.
+          \ifPgfpointOrNode{\tikztostart}{%
+            \def\StartPoint{\tikztostart}%
+          }{%
+            \def\StartPoint{\tikztostart.##4}%
+          }%
+          % Test if tikztostart is a point or a node, and define StartPoint accordingly.
+          \ifPgfpointOrNode{\tikztotarget}{%
+            \def\TargetPoint{\tikztotarget}%
+          }{%
+            \def\TargetPoint{\tikztotarget.##4}%
+          }%
+        }%
+        (\StartPoint) % <- the path starts at StartPoint
+        %%% Get x coordinate of left-most point
+        let \p1=(\StartPoint),
+        \p2=(\TargetPoint),
+        \n1={##1(##51,##52)}, % coordinate of the most left part (when ##1=min and ##5=\x: ##52 goes to \x2)
+        \n3={abs(##61-##62)/2} % Radius of circle
+        in % Warning: no comma after last line before in
+        %%%% We go on the left if needed (we check that we do move, otherwise we break the arrows tip if
+        %%%% we stay on place
+        %%%% First go to the left if needed
+        \pgfextra{%
+          %% We check if we are moving or not (required to preserve arrow tip direction)
+          \pgfmathapproxequalto{##51}{\n1}%
+        }%
+        \ifpgfmathcomparison\else -- ##7\fi
+        %%%% Version 1:
+        \pgfextra{
+          \pgfmathparse{
+            ifthenelse(##61<##62, % if end angle < angle, draw clockwis
+            "arc[start angle=##3,end angle=##2,##8]",%
+            "arc[start angle=##2,end angle=##3,##8]"%
+            )%
+          }
+        }
+        \pgfmathresult
+        \pgfextra{%
+          %% We check if we are moving or not (required to preserve arrow tip direction)
+          \pgfmathapproxequalto{##52}{\n1}%
+        }%
+        \ifpgfmathcomparison\else -- (\TargetPoint)\fi
+        \tikztonodes % All to path finishes with that to deal with futur nodes I think
+      }
+    },
+    %%
+    C/.style={C at generic={min}{90}{180+90}{west}{\x}{\y}{(\n1,\y1)}{y radius=\n3, x radius=##1*\n3}},
+    C/.default=1,
+    % Like C, but rotated
+    C-/.style={C at generic={max}{90}{-90}{east}{\x}{\y}{(\n1,\y1)}{y radius=\n3, x radius=##1*\n3}},
+    C-/.default=1,
+    C'/.style={C at generic={max}{0}{180}{north}{\y}{\x}{(\x1,\n1)}{x radius=\n3, y radius=##1*\n3}},
+    C'/.default=1,
+    C./.style={C at generic={min}{0}{-180}{south}{\y}{\x}{(\x1,\n1)}{x radius=\n3, y radius=##1*\n3}},
+    C./.default=1,
+    % Like a C shape (with without a perfect half circle). This was the old definition of C...
+    % Hopefully not useful anymore.
+    c/.style={/tikz/in=180,/tikz/out=180,looseness=2},
+    % Like C, but symetric
+    c-/.style={/tikz/in=0,/tikz/out=0,looseness=2},
+    c'/.style={/tikz/in=90,/tikz/out=90,looseness=2},
+    c./.style={/tikz/in=-90,/tikz/out=-90,looseness=2},
+    % Similar to C, but with a softer angle. The '.- marker represents the portion of
+    % the circle (hence the o) to keep (top, bottom,left/right).
+    % Angle is customizable, for instance o'=50.
+    o'/.style={/tikz/out=##1,/tikz/in=180-##1},
+    o'/.default=\zxDefaultSoftAngleO,
+    o./.style={/tikz/out=-##1,/tikz/in=180+##1},
+    o./.default=\zxDefaultSoftAngleO,
+    -o/.style={/tikz/out=-90-##1,/tikz/in=90+##1},
+    -o/.default=\zxDefaultSoftAngleO,
+    o-/.style={/tikz/out=-90+##1,/tikz/in=90-##1},
+    o-/.default=\zxDefaultSoftAngleO,
+    % Similar to o, but can be used also for diagonal items.
+    % Why ()? Visualize fixing the top part and moving the bottom part.
+    (/.style={bend right=##1},
+    (/.default=30,
+    )/.style={bend left=##1},
+    )/.default=30,
+    ('/.style={bend left=##1},
+    ('/.default=30,
+    (./.style={bend right=##1},
+    (./.default=30,
+    <'/.style={out=##1,in=180,looseness=0.65},
+    <'/.default=\zxDefaultSoftAngleChevron,
+    <./.style={out=-##1,in=180,looseness=0.65},
+    <./.default=\zxDefaultSoftAngleChevron,
+    '>/.style={out=0,in=180-##1,looseness=0.65},
+    '>/.default=\zxDefaultSoftAngleChevron,
+    .>/.style={out=0,in=180+##1,looseness=0.65},
+    .>/.default=\zxDefaultSoftAngleChevron,
+    ^./.style={out=-90+##1,in=90,looseness=0.65},
+    ^./.default=\zxDefaultSoftAngleChevron,
+    .^/.style={out=-90-##1,in=90,looseness=0.65},
+    .^/.default=\zxDefaultSoftAngleChevron,
+    'v/.style={out=90+##1,in=-90,looseness=0.65},
+    'v/.default=\zxDefaultSoftAngleChevron,
+    v'/.style={out=90-##1,in=-90,looseness=0.65},
+    v'/.default=\zxDefaultSoftAngleChevron,
+    % Links with a s-like shape.
+    s/.style={/tikz/out=0,/tikz/in=180,looseness=0.6},
+    % -s'.- shapes are like s, but with a soften (customizable like o) angle.
+    % The '. say if you are going up or down, and - forces a sharp angle (- is flat) on the side of the -
+    s'/.style={/tikz/out=##1,/tikz/in=180+##1},
+    s'/.default=\zxDefaultSoftAngleS,
+    s./.style={/tikz/out=-##1,/tikz/in=180-##1},
+    s./.default=\zxDefaultSoftAngleS,
+    -s'/.style={/tikz/out=0,/tikz/in=180+##1},
+    -s'/.default=\zxDefaultSoftAngleS,
+    -s./.style={/tikz/out=0,/tikz/in=180-##1},
+    -s./.default=\zxDefaultSoftAngleS,
+    s'-/.style={/tikz/out=##1,/tikz/in=180},
+    s'-/.default=\zxDefaultSoftAngleS,
+    s.-/.style={/tikz/out=-##1,/tikz/in=180},
+    s.-/.default=\zxDefaultSoftAngleS,
+    % Links with a s-like shape... but read from top to bottom
+    ss/.style={/tikz/out=0-90,/tikz/in=180-90,looseness=0.6},
+    % -s'.- shapes are like s, but with a soften (customizable like o) angle.
+    % The '. say if you are going up or down, and - forces a sharp angle (- is flat) on the side of the -
+    ss./.style={/tikz/out=##1-90,/tikz/in=180-90+##1},
+    ss./.default=\zxDefaultSoftAngleS,
+    .ss/.style={/tikz/out=-##1-90,/tikz/in=180-90-##1},
+    .ss/.default=\zxDefaultSoftAngleS,
+    sIs./.style={/tikz/out=0-90,/tikz/in=180-90+##1},
+    sIs./.default=\zxDefaultSoftAngleS,
+    .sIs/.style={/tikz/out=0-90,/tikz/in=180-90-##1},
+    .sIs/.default=\zxDefaultSoftAngleS,
+    ss.I/.style={/tikz/out=##1-90,/tikz/in=180-90},
+    ss.I/.default=\zxDefaultSoftAngleS,
+    I.ss/.style={/tikz/out=-##1-90,/tikz/in=180-90},
+    I.ss/.default=\zxDefaultSoftAngleS,
+    %%%% Links with a N-shape, i.e. like s shape, but symetric against the diagonal. Equivalently, it's a soft 's' shape with a much wider angle (>45).
+    N'/.style={/tikz/out=##1,/tikz/in=180+##1},
+    N'/.default=\zxDefaultSoftAngleN,
+    N./.style={/tikz/out=-##1,/tikz/in=180-##1},
+    N./.default=\zxDefaultSoftAngleN,
+    -N'/.style={/tikz/out=0,/tikz/in=180+##1},
+    -N'/.default=\zxDefaultSoftAngleN,
+    -N./.style={/tikz/out=0,/tikz/in=180-##1},
+    -N./.default=\zxDefaultSoftAngleN,
+    N'-/.style={/tikz/out=##1,/tikz/in=180},
+    N'-/.default=\zxDefaultSoftAngleN,
+    N.-/.style={/tikz/out=-##1,/tikz/in=180},
+    N.-/.default=\zxDefaultSoftAngleN,
+    % No line but vdots/dots in between.
+    3 vdots/.style={draw=none, "\makebox[0pt][r]{##1}\scalebox{\zxScaleDots}{$\cvdots$}" anchor=center},
+    3 vdots/.default={},
+    3 dots/.style={draw=none, "\makebox[0pt][r]{##1}\scalebox{\zxScaleDots}{$\chdots$}" anchor=center},
+    3 dots/.default={},
+    % Add a Hadmard/Z/X (no phase) in the middle of the line. Practical to add small nodes without creating
+    % a new column/row. However, make sure the corresponding row/column is larger, using &[\zxHCol]
+    % for columns and \\[\zxHRow] for rows (for Z/X style, use zxSCol and sxSRow), if you have both spiders
+    % and Hadamard, use \zxHSCol and \zxHSRow.
+    H/.style={"" {zxHSmall,anchor=center}},
+    Z/.style={"" {zxNoPhaseSmallZ,anchor=center}},
+    X/.style={"" {zxNoPhaseSmallX,anchor=center}},
+    % Arrow will go out from the center of the shape instead of from the border. Useful
+    % when connecting nodes with different shapes, it will give back a symetric connection.
+    wire centered/.style={
+      on layer=edgelayer,
+      /tikz/commutative diagrams/start anchor=center,
+      /tikz/commutative diagrams/end anchor=center,
+    },
+    wire centered start/.style={
+      on layer=edgelayer,
+      /tikz/commutative diagrams/start anchor=center,
+    },
+    wire centered end/.style={
+      on layer=edgelayer,
+      /tikz/commutative diagrams/end anchor=center,
+    },
+    wc/.style={wire centered},
+    wcs/.style={wire centered start},
+    wce/.style={wire centered end},
+    wire not centered/.style={
+      /tikz/commutative diagrams/start anchor=,
+      /tikz/commutative diagrams/end anchor=,
+    },
+  },
+  /zx/styles/rounded style/.style={
+    %% Can be redefined by user
+    % Style for empty nodes
+    zxAllNodes/.style={
+      shape=rectangle, % Otherwise nodes are asymetrical rectangle, which is not practical in our case. Gives notably anchor "center" which is really centered compared to asymatrical rectangles
+      anchor=center,   % Center cells
+      line width=\zxDefaultLineWidth,
+      execute at begin node={\thinmuskip=0mu\medmuskip=0mu\thickmuskip=0mu}, % Reduce space around +/-...
+    },
+    % Use this to denote an empty diagram
+    zxEmptyDiagram/.style={
+      zxAllNodes,
+      draw,
+      dashed,
+      minimum size=4mm,
+    },
+    % Style to use when no node is drawn
+    zxNone/.style={
+      zxAllNodes,
+      shape=coordinate, % A coordinate has just a center. Nothing more.
+    },
+    % Style to use when no node is drawn, but a bit of space is required not to make the diagram too small
+    zxNone+/.style={
+      zxAllNodes,
+      inner sep=1mm,
+      outer sep=0mm
+    },
+    % Like zxNone+, but without width (wold prefer |, but special car in |[]|...
+    zxNoneI/.style={
+      zxNone+,
+      inner xsep=0mm,
+    },
+    % Like zxNone+, but without height
+    zxNone-/.style={
+      zxNone+,
+      inner ysep=0mm,
+    },
+    % Style to use when no node is drawn, but a large space must be reserved (typically used to fake two
+    % nodes on a single line) (for +I- versions)
+    zxNoneDouble/.style={
+      shape=coordinate
+    },
+    % Style to use when no node is drawn, but a bit of space is required not to make the diagram too small
+    zxNoneDouble+/.style={
+      zxAllNodes,
+      inner sep=.6em,
+      outer sep=0mm
+    },
+    % Like zxNoneDouble+, but without width (wold prefer |, but special car in |[]|...
+    zxNoneDoubleI/.style={
+      zxNoneDouble+,
+      inner xsep=0mm,
+    },
+    % Like zxNoneDouble+, but without height
+    zxNoneDouble-/.style={
+      zxNoneDouble+,
+      inner ysep=0mm,
+    },
+    % Will be specific to all spiders
+    zxSpiders/.style={
+      draw=black,
+    },
+    % Will use this style when drawing a X/Z node without phase (not for end user directly)
+    zxNoPhase/.style={
+      zxAllNodes,
+      zxSpiders,
+      inner sep=0mm,
+      minimum size=2mm,
+      shape=circle,
+    },
+    % Used only in decoration of wires, to add small empty X/Z nodes.
+    zxNoPhaseSmall/.style={
+      zxNoPhase
+    },
+    % Style for nodes that are small enough to fit in a circle, like $\zxMinus \frac{\pi}{4}$
+    zxShort/.style={
+      zxAllNodes,
+      zxSpiders,
+      minimum size=5mm,
+      font={\fontsize{8}{10}\selectfont\boldmath},
+      rounded rectangle,
+      inner sep=0.0mm,
+      scale=0.8,
+    }, % negative outer sep would draw lines from inside...
+    % Style for nodes that are bigger, like $\alpha+\beta$ or $(a\oplus b)\pi$
+    zxLong/.style={zxShort, inner xsep=1.2mm},
+    %%% Styles of the label when |phase in label| is used
+    stylePhaseInLabel/.style={
+      font={\fontsize{8}{10}\selectfont\boldmath},
+      inner sep=2pt,
+      outer sep=0pt,
+      rounded rectangle,
+      % node on layer=labellayer, %% Fails in tikzcd: https://tex.stackexchange.com/questions/618823/node-on-layer-style-in-tikz-matrix-tikzcd
+    },
+    stylePhaseInLabelZ/.style={
+      stylePhaseInLabel,
+      fill=green!20!white
+    },
+    stylePhaseInLabelX/.style={
+      stylePhaseInLabel,
+      fill=red!20!white
+    },
+    %%%%%%%%%%% Style defined depending on above ones. Feel free to redefine.
+    zxNoPhaseZ/.style={zxNoPhase,fill=colorZxZ},
+    zxNoPhaseX/.style={zxNoPhase,fill=colorZxX},
+    zxNoPhaseSmallZ/.style={zxNoPhaseSmall,fill=colorZxZ},
+    zxNoPhaseSmallX/.style={zxNoPhaseSmall,fill=colorZxX},
+    zxShortZ/.style={zxShort,fill=colorZxZ},
+    zxShortX/.style={zxShort,fill=colorZxX},
+    zxLongZ/.style={zxLong,fill=colorZxZ},
+    zxLongX/.style={zxLong,fill=colorZxX},
+    %%%%%%%%%%%
+    %%% Instead of adding directly the style as the node's content (which would make
+    %%% impossible styles that adds the phase in a label outside of the node)
+    %%% add at Phase@Spider{,Z,X}={phase of the node} will be in charge of adding it.
+    add at Phase@Spider/.style n args={4}{ % add at Phase@Spider{emptyStyle}{NotEmptyStyle}{node content}
+      zx at emptyStyle/.style={##1},
+      zx at notEmptyStyle/.style={##2},
+      zx at labelStyle/.style={##3},
+      /zx/zx at content/.initial={##4},
+      phase in content,
+    },
+    add at Phase@Spider at Frac/.style n args={8}{ % add at Phase@Spider{emptyStyle}{NotEmptyStyle}{labelstyle}{sign}{above fraction (no parens)}{below fraction (no parens)}{above fraction (parens)}{below fraction (parens)}
+      zx at emptyStyle/.style={##1},
+      zx at notEmptyStyle/.style={##2},
+      zx at labelStyle/.style={##3},
+      % Useful to help "phase in content" to know if we are in Frac or not.
+      /zx/zx at isInFrac/.initial={true},
+      phase in content,
+    },
+    % #1 is the node content. Seems that storing it in /zx/zx at content is not enough because keys
+    % seems to be local to nodes and are not transfered to label.
+    zx at Execute@Very at End/.style n args={4}{
+      zx at commandToExecuteVeryEnd/.try={##1}{##2}{##3}{##4},
+    },
+    zx at Execute@Very at End/.default={}{}{}{},
+    %% zx at Execute@Very at End@Frac={emptystyle}{contentstyle}{labelstyle}{sign}{above frac (no parens)}{below frac (no parens)}{above frac (parens)}{below frac (parens)}
+    zx at Execute@Very at End@Frac/.style n args={8}{
+      zx at commandToExecuteVeryEndFrac/.try={##1}{##2}{##3}{##4}{##5}{##6}{##7}{##8},
+    },
+    zx at Execute@Very at End@Frac/.default={}{}{}{}{}{}{}{},
+    %% /!\ WARNING: the following styles "phase..." must be loaded by or *after* add at Phase@Spider...
+    %% To load it on the whole picture, prefer to do:
+    %% \zx[/zx/user post preparation labels/.style={phase in label}]{
+    %%   \zxZ{\alpha}
+    %% }
+    phase in content/.code={%
+      % Check if we are in a Frac or not
+      \ifthenelse{\equal{\pgfkeysvalueof{/zx/zx at isInFrac}}{true}}{%
+        %%% ### We are in a fraction node!
+        %% Modifies zx at commandToExecuteVeryEnd (which is executed at the very end by zx at Execute@Very at End)
+        %% in order to add the good style
+        \pgfkeysalso{
+          % zx at commandToExecuteVeryEndFrac{emptystyle}{contentstyle}{labelstyle}{sign}{above frac (no parens)}{below frac (no parens)}{above frac (parens)}{below frac (parens)}
+          zx at commandToExecuteVeryEndFrac/.style n args={8}{%
+            execute at begin node={\zxConvertToFracInContent{####4}{####5}{####6}{####7}{####8}},%
+          },%
+          % Adds the style:
+          zx at notEmptyStyle,
+        }%
+      }{ %%% ### We are NOT in a fraction node.
+        %% Modifies zx at commandToExecuteVeryEnd (which is executed at the very end by zx at Execute@Very at End)
+        %% in order to add the good style
+        \pgfkeysalso{
+          zx at commandToExecuteVeryEnd/.style n args={4}{%
+            execute at begin node={####4},% ####4 = content
+          }%
+        }%
+        % Checks if the content (stored by add at Phase@Spider in /zx/zx at content) is empty or not
+        \ifthenelse{\equal{\pgfkeysvalueof{/zx/zx at content}}{}}{%
+          \pgfkeysalso{%
+            zx at emptyStyle,%
+          }%
+        }{%
+          \pgfkeysalso{%
+            zx at notEmptyStyle,%
+          }%
+        }%
+      }%
+    },
+    phase in label/.code={
+      % Check if we are in a Frac or not
+      \ifthenelse{\equal{\pgfkeysvalueof{/zx/zx at isInFrac}}{true}}{%
+        %%% ### We are in a fraction node!
+        \pgfkeysalso{%
+          % zx at commandToExecuteVeryEndFrac{emptystyle}{contentstyle}{labelstyle}{sign}{above frac (no parens)}{below frac (no parens)}{above frac (parens)}{below frac (parens)}
+          zx at commandToExecuteVeryEndFrac/.code n args={8}{%
+            \pgfkeysalso{
+              label={[####3,##1] \zxConvertToFracInLabel{####4}{####5}{####6}{####7}{####8}},%
+            }%
+          },%
+          zx at emptyStyle,
+        }%
+      }{%
+        \pgfkeysalso{%
+          % ##1 is the argument of "phase in label", i.e. the style of the label
+          zx at commandToExecuteVeryEnd/.code n args={4}{% ####3: label style, ####4: content
+            % Checks if the content (stored by add at Phase@Spider in /zx/zx at content) is empty or not
+            \ifthenelse{\equal{####4}{}}{% Content is empty
+            }{% Content is not empty
+              \pgfkeysalso{
+                label={[####3,##1] ####4},%
+              }%
+            }%
+          },%
+          zx at emptyStyle,
+        }%
+      }%
+    },
+    pil/.style={phase in label=##1},
+    phase in label below/.style={
+      phase in label={label position=below,##1}
+    },
+    pilb/.style={phase in label below=##1},
+    phase in label above/.style={
+      phase in label={label position=above,##1}
+    },
+    pila/.style={phase in label above=##1},
+    phase in label right/.style={
+      phase in label={label position=right,##1}
+    },
+    pilr/.style={phase in label right=##1},
+    phase in label left/.style={
+      phase in label={label position=left,##1}
+    },
+    pill/.style={phase in label left=##1},
+    %%% Was supposed to automatically find the good style depending on content... Can't find how to do.
+    % Styles zxLong{X/Z} zxNoPhase{X/Z} are automatically selected by \zxZ2{...} and \zxX2{...} commands
+    % and zxShort is selected for fractions only like in \zxFracZ-{\pi}{4}
+    % zxZ/.style={zxChoose={##1},fill=colorZxZ},
+    % zxX/.style={zxChoose={##1},fill=colorZxX},
+    %%% First argument is additional style. Second argument is content of node.
+    zxZ2/.style 2 args={
+      add at Phase@Spider={zxNoPhaseZ}{zxLongZ}{stylePhaseInLabelZ}{##2},
+      /zx/post preparation labels,
+      /zx/user post preparation labels,
+      %/zx/user overlay nodes,
+      ##1,
+      zx at Execute@Very at End={zxNoPhaseZ}{zxLongZ}{stylePhaseInLabelZ}{##2},
+    },
+    %% ##1: other styles, ##2: content
+    zxX2/.style 2 args={
+      add at Phase@Spider={zxNoPhaseX}{zxLongX}{stylePhaseInLabelX}{##2},
+      /zx/post preparation labels,
+      /zx/user post preparation labels,
+      ##1,
+      zx at Execute@Very at End={zxNoPhaseX}{zxLongX}{stylePhaseInLabelX}{##2},
+    },
+    %% These take 6 arguments: additional style, sign (string "-" for minus, nothing for "+",
+    %% otherwise inserted directly), above fraction (no parens), below fraction (no parens), above fraction (parens), below fraction (parens).
+    zxFracZ6/.style n args={6}{
+      add at Phase@Spider at Frac={zxNoPhaseZ}{zxShortZ}{stylePhaseInLabelZ}{##2}{##3}{##4}{##5}{##6},
+      /zx/post preparation labels,
+      /zx/user post preparation labels,
+      ##1,
+      zx at Execute@Very at End@Frac={zxNoPhaseZ}{zxShortZ}{stylePhaseInLabelZ}{##2}{##3}{##4}{##5}{##6},
+    },
+    zxFracX6/.style n args={6}{
+      add at Phase@Spider at Frac={zxNoPhaseX}{zxShortX}{stylePhaseInLabelX}{##2}{##3}{##4}{##5}{##6},
+      /zx/post preparation labels,
+      /zx/user post preparation labels,
+      ##1,
+      zx at Execute@Very at End@Frac={zxNoPhaseX}{zxShortX}{stylePhaseInLabelX}{##2}{##3}{##4}{##5}{##6},
+    },
+    % For Hadamard
+    zxH/.style={
+      zxAllNodes,
+      outer sep=0pt,
+      fill=colorZxH,
+      draw,
+      inner sep=0.6mm,
+      minimum height=1.5mm,
+      minimum width=1.5mm,
+      shape=rectangle},
+    zxHSmall/.style={zxH},
+  },
+  % Default style. Can be changed by user
+  /zx/default style nodes/.style={
+    /zx/styles/rounded style
+  },
+  % User can put here any additional property
+  /zx/user overlay nodes/.style={
+  },
+  % Any additional property that needs to be loaded after add at Phase@Spider (by script, not by user).
+  /zx/post preparation labels/.style={
+  },
+  % User can put here any additional property that needs to be loaded after add at Phase@Spider
+  /zx/user post preparation labels/.style={
+  },
+  % Default wire style. Can be changed by user.
+  /zx/default style wires/.style={
+  },
+  % User can add stuff in this style to improve wire styles
+  /zx/user overlay wires/.style={
+  },
+  /zx/defaultEnv/.style={
+    column sep=tiny,
+    row sep=tiny,
+    % center on the math axis
+    baseline={([yshift=-axis_height]current bounding box.center)},
+    % Fix 1-row diagram baseline
+    1-row diagram/.style={%
+      /tikz/baseline={([yshift=-axis_height]current bounding box.center)}%
+    },
+    % Load (thanks ".search also") our own style
+    /tikz/every node/.style={%
+      % For quickly adding alias, and displaying this alias in debug mode.
+      a/.code={%
+        \pgfkeysalso{%
+          alias=####1,%
+        }%
+        \ifdefined\zxDebugMode%
+          \pgfkeysalso{%
+            label={[inner sep=0pt,overlay,red,font={\fontsize{5}{6}}]-45:\scalebox{.5}{####1}}
+          }%
+        \fi%
+      },
+      /zx/default style nodes,
+      /zx/user overlay nodes,
+    },
+    every arrow/.style={%
+      /zx/wires definition,
+      /zx/default style wires,
+      /zx/user overlay wires,
+    },
+    %%% To be used only in \zx{...} environment.
+    %%% Exemple:
+    phase in content/.style={
+      /zx/post preparation labels/.append style={
+        phase in content,
+      }
+    },
+    phase in label/.style={
+      /zx/post preparation labels/.append style={
+        phase in label=##1,
+      }
+    },
+    phase in label above/.style={
+      /zx/post preparation labels/.append style={
+        phase in label above=##1,
+      }
+    },
+    phase in label below/.style={
+      /zx/post preparation labels/.append style={
+        phase in label below=##1,
+      }
+    },
+    phase in label right/.style={
+      /zx/post preparation labels/.append style={
+        phase in label right=##1,
+      }
+    },
+    phase in label left/.style={
+      /zx/post preparation labels/.append style={
+        phase in label left=##1,
+      }
+    },
+    % for "Phase In Label"
+    pil/.style={phase in label=##1},
+    pilb/.style={phase in label below=##1},
+    pila/.style={phase in label above=##1},
+    pilr/.style={phase in label right=##1},
+    pill/.style={phase in label left=##1},
+  },
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%% Helper functions
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+% Defines a "on layer=nameoflayer" style. TODO: check if better to move it in /zx/
+% https://tex.stackexchange.com/questions/20425/z-level-in-tikz/20426#20426
+% For path: on layer=namelayer, for nodes "node on layer=..."
+% /!\ node on layer fails in tikzcd: https://tex.stackexchange.com/questions/618823/node-on-layer-style-in-tikz-matrix-tikzcd
+\pgfkeys{%
+  /tikz/on layer/.code={
+    \pgfonlayer{#1}\begingroup
+    \aftergroup\endpgfonlayer
+    \aftergroup\endgroup
+  },
+  /tikz/node on layer/.code={
+    \gdef\node@@on at layer{%
+      \setbox\tikz at tempbox=\hbox\bgroup\pgfonlayer{#1}\unhbox\tikz at tempbox\endpgfonlayer\egroup}
+    \aftergroup\node at on@layer
+  },
+  /tikz/end node on layer/.code={
+    \endpgfonlayer\endgroup\endgroup
+  }
+}
+\def\node at on@layer{\aftergroup\node@@on at layer}
+
+%%% Declare a symbol for a short minus (useful in fractions)
+\DeclareMathSymbol{\zxMinus}{\mathbin}{AMSa}{"39} % Requires amssymb
+
+%%% Checks if a function is a point or a node.
+%%% Not sure if best solution (needed to dig into source of TeX), but can't find anything better in manual
+%%% https://tex.stackexchange.com/questions/6189553
+\def\ifPgfpointOrNode#1#2#3{%
+  \pgfutil at ifundefined{pgf at sh@ns@#1}{%
+    #2%
+  }{%
+    #3%
+  }%
+}
+
+
+%%% Create different kinds of dots...
+%% https://tex.stackexchange.com/questions/617959
+%% https://tex.stackexchange.com/questions/528774/excess-vertical-space-in-vdots/528775#528775
+\DeclareRobustCommand\cvdotsAboveBaseline{%
+  \vbox{\baselineskip4\p@ \lineskiplimit\z@%
+    \hbox{.}\hbox{.}\hbox{.}}
+}
+
+\DeclareRobustCommand{\cvdotsCenterMathline}{%
+  % vcenter is used to center the argument on the 'math axis', which is at half the height of an 'x', or about the position of a minus sign.
+  \vcenter{\cvdotsAboveBaseline}%
+}
+
+\DeclareRobustCommand{\cvdotsCenterBaseline}{%
+  \raisebox{-.5\height}{%
+    $\cvdotsAboveBaseline$%
+  }%
+}
+
+\DeclareRobustCommand{\chdots}{%
+  \raisebox{-.5\height}{%
+    \rotatebox{90}{% Maybe better options than rotatebox...
+      $\cvdotsAboveBaseline$%
+    }%
+  }%
+}
+
+\DeclareRobustCommand{\cvdots}{\cvdotsCenterMathline}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Practical macros to automatically choose appropriate style and arrows
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% /!\ Warning: you should add {} at the end of all macros (except arrows)!
+% Not using that may work for now, but it may break later...
+% TODO: define them only in \zx environment.
+
+% % Example: \leftManyDots{n}
+% Useful to put on the left of a node like "n \vdots", linked to the next node.  Example: \leftManyDots{n}.
+% First optional argument is scale of text, second is scale of =.
+\NewExpandableDocumentCommand{\leftManyDots}{O{1}O{\zxScaleDots}m}{%
+  |[zxNone+,inner xsep=0pt]| \scalebox{#1}{$#3$\,}\makebox[0pt][l]{\scalebox{#2}{$\cvdots$}} \ar[r,-s.,start anchor=north east] \ar[r,-s',start anchor=south east] \pgfmatrixnextcell%
+}
+
+% Useful to link two nodes and put a vdots in between.
+\NewExpandableDocumentCommand{\middleManyDots}{}{%
+  \ar[r,3 vdots] \ar[o',r] \ar[o.,r]%
+}
+
+% Like \leftManyDots but on the right. Do *not* create a new node, like in |[zxShortZ]| \alpha \rightManyDots{m}
+\NewExpandableDocumentCommand{\rightManyDots}{O{1}O{\zxScaleDots}m}{%
+  \ar[r,s'-,end anchor=north west] \ar[r,s.-,end anchor=south west] \pgfmatrixnextcell |[zxNone+,inner xsep=0pt]| \makebox[0pt][r]{\scalebox{#2}{$\cvdots$}}\scalebox{#1}{\,$#3$}
+}
+
+% A swap on one line... Practical mostly to gain space. Must be used with large nodes tough...
+% \NewExpandableDocumentCommand{\OneLineSwap}{}{%
+%   \ar[r,s,start anchor=south,end anchor=north] \ar[r,s,start anchor=north,end anchor=south]
+% }
+
+
+\NewExpandableDocumentCommand{\zxLoop}{O{90}O{20}O{}m}{%
+  \ar[loop,in=#1-#2,out=#1+#2,looseness=8,min distance=3mm,#3]
+}
+
+\NewExpandableDocumentCommand{\zxLoopAboveDots}{O{20}O{}m}{%
+  \ar[loop,in=90-#1,out=90+#1,looseness=8,min distance=3mm,"\cvdots" {scale=.6,anchor=north,yshift=-0.4mm},#2]
+}
+
+% Usage: node without any style, but may have space. Default is no space, \zxNone+{} is both horizontal
+% and vertical, \zxNone-{} is only horizontal space, \zxNone|{} is only vertical space.
+\NewExpandableDocumentCommand{\zxNone}{t+t-t|O{}m}{
+  \IfBooleanTF{#1}{ % \zxNone+
+    |[zxNone+,#4]| #5%
+  }{
+    \IfBooleanTF{#2}{ % \zxNone-
+      |[zxNone-,#4]| #5%
+    }{
+      \IfBooleanTF{#3}{ % \zxNone
+        |[zxNoneI,#4]| #5%
+      }{% \zxNone
+        |[zxNone,#4]| #5%
+      }
+    }
+  }
+}
+
+% Usage: alias of \zxNone... To bad token can't be easily forwarded to another function.
+\NewExpandableDocumentCommand{\zxN}{t+t-t|O{}m}{
+  \IfBooleanTF{#1}{ % \zxNone+
+    |[zxNone+,#4]| #5%
+  }{
+    \IfBooleanTF{#2}{ % \zxNone-
+      |[zxNone-,#4]| #5%
+    }{
+      \IfBooleanTF{#3}{ % \zxNone
+        |[zxNoneI,#4]| #5%
+      }{% \zxNone
+        |[zxNone,#4]| #5%
+      }
+    }
+  }
+}
+
+% Cf \zxNone, but with larger space.
+\NewExpandableDocumentCommand{\zxNoneDouble}{t+t-t|O{}m}{
+  \IfBooleanTF{#1}{ % \zxNoneDouble+
+    |[zxNoneDouble+,#4]| #5%
+  }{
+    \IfBooleanTF{#2}{ % \zxNoneDouble-
+      |[zxNoneDouble-,#4]| #5%
+    }{
+      \IfBooleanTF{#3}{ % \zxNoneDouble
+        |[zxNoneDoubleI,#4]| #5%
+      }{% \zxNoneDouble
+        |[zxNoneDouble,#4]| #5%
+      }
+    }
+  }
+}
+
+%% For maximum styling liberty, the content is given directly to the style.
+% It allows the style to put the phase in a label.
+\NewExpandableDocumentCommand{\zxZ}{O{}m}{
+  |[zxZ2={#1}{#2}]| %
+}
+
+%% For maximum styling liberty, the content is given directly to the style.
+%% It allows the style to put the phase in a label.
+\NewExpandableDocumentCommand{\zxX}{O{}m}{
+  |[zxX2={#1}{#2}]| %
+}
+
+\NewExpandableDocumentCommand{\zxH}{O{}m}{
+  |[zxH,#1]| {}%
+}
+
+% Use like: \zxFracX{\pi}{4} for positive values or for negative \zxFracX-{\pi}{4}
+\NewExpandableDocumentCommand{\zxFracZ}{O{}t-moom}{%
+  \IfNoValueTF{#5}{% 2 arguments like: \zxFracZ{\pi}{2}
+    |[zxFracZ6={#1}{\IfBooleanTF{#2}{\zxMinus}{}}{#3}{#6}{#3}{#6}]| %
+  }{% 4 arguments like \zxFracZ{a+b}[(a+b)][(c+d)]{c+d}
+    |[zxFracZ6={#1}{\IfBooleanTF{#2}{\zxMinus}{}}{#3}{#6}{#4}{#5}]| %
+  }%
+}
+
+% Use like: \zxFracX{\pi}{4} for positive values or for negative \zxFracX-{\pi}{4}
+\NewExpandableDocumentCommand{\zxFracX}{O{}t-moom}{%
+  \IfNoValueTF{#5}{% 2 arguments like: \zxFracZ{\pi}{2}
+    |[zxFracX6={#1}{\IfBooleanTF{#2}{\zxMinus}{}}{#3}{#6}{#3}{#6}]| %
+  }{% 4 arguments like \zxFracZ{a+b}[(a+b)][(c+d)]{c+d}
+    |[zxFracX6={#1}{\IfBooleanTF{#2}{\zxMinus}{}}{#3}{#6}{#4}{#5}]| %
+  }%
+}
+
+\NewExpandableDocumentCommand{\zxEmptyDiagram}{}{
+  |[zxEmptyDiagram]| {}%
+}
+
+% Quantikz has a bug which adds space automatically.
+% https://tex.stackexchange.com/questions/618330
+% Fixing that by copying the original (unpatched) functions, and reusing them later.
+% Warning: you must load this package **before** quantikz otherwise the fix will not work.
+\let\tikzcd@@originalCopyZx\tikzcd@
+\let\endtikzcd at originalCopyZx\endtikzcd
+
+%%%%% Main environment \begin{ZX}...\end{ZX}
+\NewDocumentEnvironment{ZX}{O{}}{%
+  \bgroup%
+  % Add a switch in case someone really wants the current tikzcd version:
+  \ifdefined\doNotPatchQuantikz% Do not patch tikzcd.
+  \else% Restore locally original tikzcd.
+    \let\tikzcd@\tikzcd@@originalCopyZx%
+    \let\endtikzcd\endtikzcd at originalCopyZx%
+  \fi%
+  \pgfsetlayers{background,edgelayer,nodelayer,main,box,labellayer,foreground} % Layers are defined locally to avoid to disturb other drawings
+  \begin{tikzcd}[%
+    /zx/defaultEnv,%
+    #1]%
+  }{\end{tikzcd}\egroup}
+
+%%%%% Shortcut macro \zx{...} equivalent to \begin{ZX}...\end{ZX}
+\newcommand\zx{%
+  \begingroup% To avoid ampersand issues https://tex.stackexchange.com/a/611535/116348
+  \NewDocumentCommand{\tmpZX}{O{}+m}{%
+    \endgroup%
+    \begin{ZX}[##1]%
+      ##2%
+    \end{ZX}%
+  }%
+  \catcode`&=13%
+  \tmpZX%
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Old code that tried to automatically find if zxShort or zxLong should be used...
+%%% Now using a special command for fractions (easier to code, and more customizable)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newsavebox\zx at box % Temporary box to compute height/width/depth
+
+\newlength{\zxMaxDepthPlusHeight}\setlength{\zxMaxDepthPlusHeight}{2em}
+\def\zxMaxRatio{1.3} % Ratio width/(height+depth)
+
+\NewExpandableDocumentCommand{\zxChooseStyle}{mmmm}{%
+  % #1=text,#2=empty style,#3=short style,#4=long style
+  \savebox\zx at box{#1}%
+  % Check if width is 0pt:
+  \ifdimcomp{\wd\zx at box}{=}{0pt}{% Return empty style if box is empty
+    #2%
+  }{% Else compute size of thext
+    % Check if height+depth < zxMaxDepthPlusHeight to see if short style applies
+    \ifdimcomp{\dimexpr\dp\zx at box+\ht\zx at box\relax}{<}{\zxMaxDepthPlusHeight}{%
+      % Check if width < ratio*(height+depth) to see if short style applies
+      \ifdimcomp{\wd\zx at box}{<}{\dimexpr \zxMaxRatio\ht\zx at box + \zxMaxRatio\dp\zx at box\relax}{%
+        #3% Short style is used
+      }{ % Else
+        #4% Long style is used
+      } %
+    }{
+      #4% Long style is used
+    }
+  }%
+}


Property changes on: trunk/Master/texmf-dist/tex/latex/zx-calculus/tikzlibraryzx-calculus.code.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/zx-calculus/zx-calculus.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/zx-calculus/zx-calculus.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/zx-calculus/zx-calculus.sty	2021-10-15 22:13:43 UTC (rev 60768)
@@ -0,0 +1,9 @@
+% This is a zx library to typeset ZX calculus directly in LaTeX.
+% Written by Léo Colisson. Report bugs on https://github.com/leo-colisson/zx-calculus/issues
+% Published under the MIT license.
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zx-calculus}[2021/10/15 A package to typeset ZX calculus in directly in LaTeX, based on tikz/tikzcd.]
+
+\RequirePackage{tikz}
+
+\usetikzlibrary{zx-calculus} % See library in "tikzlibraryzx.code.tex".


Property changes on: trunk/Master/texmf-dist/tex/latex/zx-calculus/zx-calculus.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check	2021-10-15 22:12:13 UTC (rev 60767)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2021-10-15 22:13:43 UTC (rev 60768)
@@ -867,7 +867,7 @@
     zhlineskip zhlipsum zhnumber zhmetrics zhmetrics-uptex zhspacing
     ziffer zitie zlmtt zootaxa-bst zref zref-check
     zwgetfdate zwpagelayout
-    zxjafbfont zxjafont zxjatype zztex
+    zx-calculus zxjafbfont zxjafont zxjatype zztex
 ); 
 
 


Modified: trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc	2021-10-15 22:12:13 UTC (rev 60767)
+++ trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc	2021-10-15 22:13:43 UTC (rev 60768)
@@ -228,3 +228,4 @@
 depend youngtab
 depend yquant
 depend ytableau
+depend zx-calculus

Added: trunk/Master/tlpkg/tlpsrc/zx-calculus.tlpsrc
===================================================================


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