texlive[67206] Master/texmf-dist: quantikz (25may23)

commits+karl at tug.org commits+karl at tug.org
Thu May 25 00:24:26 CEST 2023


Revision: 67206
          http://tug.org/svn/texlive?view=revision&revision=67206
Author:   karl
Date:     2023-05-25 00:24:25 +0200 (Thu, 25 May 2023)
Log Message:
-----------
quantikz (25may23)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/quantikz/README.md
    trunk/Master/texmf-dist/doc/latex/quantikz/quantikz.pdf
    trunk/Master/texmf-dist/doc/latex/quantikz/quantikz.tex
    trunk/Master/texmf-dist/tex/latex/quantikz/quantikz.sty
    trunk/Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz2.code.tex

Modified: trunk/Master/texmf-dist/doc/latex/quantikz/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/quantikz/README.md	2023-05-24 09:16:38 UTC (rev 67205)
+++ trunk/Master/texmf-dist/doc/latex/quantikz/README.md	2023-05-24 22:24:25 UTC (rev 67206)
@@ -4,4 +4,6 @@
 
 It is covered by a CC-BY 4.0 license.
 
-Please see the manual for detailed usage.
\ No newline at end of file
+Please see the manual for detailed usage.
+
+Two versions are provided: quantikz (v. 0.9.8) as for legacy purposes, and quantikz2, the current release.
\ No newline at end of file

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

Modified: trunk/Master/texmf-dist/doc/latex/quantikz/quantikz.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/quantikz/quantikz.tex	2023-05-24 09:16:38 UTC (rev 67205)
+++ trunk/Master/texmf-dist/doc/latex/quantikz/quantikz.tex	2023-05-24 22:24:25 UTC (rev 67206)
@@ -336,7 +336,7 @@
 If you need to adjust where the last slice is, use the optional parameter \verb!remove end slices!, which counts the number of columns fewer to add slices to. You can also change the title of each of the slices, by setting \verb!slice titles!. Include the macro \verb!\col! in your specification if you want to use the step number. Note, however, that the columns won't automatically space themselves out to accommodate a very wide label. You can style the slicing lines with the \verb!slice style! key, and the labels with \verb!slice label style!. These can be used to rotate the labels and create a bit more space!
 \begin{Code}
 \begin{quantikz}[slice all,remove end slices=1,slice titles=slice \col,slice style=blue,slice label style={inner sep=1pt,anchor=south west,rotate=40}]
-& \gate{H} & \ctrl{1} & \meter{} && \\
+& \gate{H} & \ctrl{1} & \meter{} &\setwiretype{n}& \\
 &       & \targ{} & \ctrl{1} & \gate{H} & \\
 & & & \targ{} & &
 \end{quantikz}
@@ -465,6 +465,19 @@
 \end{quantikz}
 \end{Code}
 
+\item [\textbackslash ghost{[w][h]}\{l\}]
+Creates an invisible quantum gate that has the same height as \verb!\gate[][w][h]{l}!. Just like any other gate command, this should come before any other commands in a cell, and cannot be in the same cell as another gate command.
+\begin{Code}
+\begin{quantikz}
+%give the wires the same vertical space as if they had H gates on them
+&&\ghost{H} \\
+&& \ghost{H}
+\end{quantikz}=\begin{quantikz}
+ & \gate{H} & \\
+ & \gate{H} &
+\end{quantikz}
+\end{Code}
+
 \item [\textbackslash phase{[s]}\{l\}]
 Creates a phase gate (black circle) with label \texttt{l}. The optional parameter \texttt{s} controls the styling via the parameters
 
@@ -696,7 +709,7 @@
 Present the text in label \texttt{l} as vertically stacked. Can be helpful for slices.
 
 \item [\textbackslash ket\{l\}, \textbackslash bra\{l\}, \textbackslash proj\{l\}, \textbackslash braket\{l\}\{m\}]
-Typeset Dirac notation $\ket{l}$, $\bra{l}$, $\proj{l}$ and $\braket{l}{m}$ respectively. These commands do not require math mode, and the braces will automatically resize to the argument. They are defined to behave well with other packages (e.g.\ physics) that may define the same commands. If you wish to ensure that you are using the version that this package defines, run \textbackslash forceredefine at the end of your preamble (after all packages have loaded). You may also need to be careful of the order in which you load those packages.
+Typeset Dirac notation $\ket{l}$, $\bra{l}$, $\proj{l}$ and $\braket{l}{m}$ respectively. These commands do not require math mode, and the braces will automatically resize to the argument. They are defined to behave well with other packages (e.g.\ physics) that may define the same commands. You may need to be careful of the order in which you load those packages: load quantikz \emph{after} the other package --- if quantikz sees that those commands are already defined, it does not redefine them. If you wish to ensure that you are using the version that this package defines, run \textbackslash forceredefine at the end of your preamble (after all packages have loaded). 
 
 % % \item [\textbackslash alias\{n\}]
 % % Used in an otherwise empty cell, that gives the current row a name \texttt{n}. This is useful for referring to it for the purposes of vertical positioning.

Modified: trunk/Master/texmf-dist/tex/latex/quantikz/quantikz.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/quantikz/quantikz.sty	2023-05-24 09:16:38 UTC (rev 67205)
+++ trunk/Master/texmf-dist/tex/latex/quantikz/quantikz.sty	2023-05-24 22:24:25 UTC (rev 67206)
@@ -1,10 +1,10 @@
-%This is the quantikz library for typesetting quantum circuits using LaTeX/Tikz. version 0.9.6
+%This is the quantikz library for typesetting quantum circuits using LaTeX/Tikz. version 1.0.1
 % Written by Alastair Kay, 2018. Published under a CC-BY-4.0 licence
 % Please email me (alastair.kay at rhul.ac.uk) with any bug reports or feature requests.
 % If you find this library useful, please cite its usage in your work, using arXiv:1809.03842, and possibly the DOI: 10.17637/rh.7000520.
 % Usage is at your own risk.
 
-\ProvidesPackage{quantikz}[2023/04/03 typeset quantum circuit diagrams]
+\ProvidesPackage{quantikz}[2023/05/24 typeset quantum circuit diagrams]
 \RequirePackage{tikz}[2013/12/13] % pgf version 3.0.0 required
 \usetikzlibrary{quantikz2}
 

Modified: trunk/Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz2.code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz2.code.tex	2023-05-24 09:16:38 UTC (rev 67205)
+++ trunk/Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz2.code.tex	2023-05-24 22:24:25 UTC (rev 67206)
@@ -1,9 +1,12 @@
-%This is the quantikz library for typesetting quantum circuits using LaTeX/Tikz. version 1.0.0
+%This is the quantikz library for typesetting quantum circuits using LaTeX/Tikz. version 1.0.1
 % Written by Alastair Kay, 2018. Published under a CC-BY-4.0 licence
 % Please email me (alastair.kay at rhul.ac.uk) with any bug reports or feature requests.
 % If you find this library useful, please cite its usage in your work, using arXiv:1809.03842, and possibly the DOI: 10.17637/rh.7000520.
 % Usage is at your own risk.
 
+%version 1.0.1
+% the lstick/midstick/rstick commands now correctly resize braces if you're using classical wires based on wire types at the *end* of each wire (so rstick more likely to look good than lstick/midstick!.
+% fixed incompatibility if physics2 package (turned out we both used the same variable name somewhere)
 %version 1.0.0
 %major new revision with massive under-the-hood changes in how wires work.
 %aiming to reduce technical debt in the code as well.
@@ -13,14 +16,8 @@
 %some minor changes in optional parameters (e.g. \meter). In practice, these are rarely used, and unlikely to be an issue.
 %should always use quantikz and not tikzcd environment
 
+%\ProvidesPackage{quantikz}[2023/05/24 typeset quantum circuit diagrams]
 
-%to-do
-%complete rewrite of manual
-%add isosceles triangle example to manual
-%fix ampersand replacement (is it even necessary any more?). Check beamer.
-
-%\ProvidesPackage{quantikz}[2023/04/03 typeset quantum circuit diagrams]
-
 % Package(s) to include
 \RequirePackage{xargs,ifthen,xstring,xparse,etoolbox,mathtools,pgfmath}
 \RequirePackage{environ} %in an attempt to help with compatibility with the external library of tikz.
@@ -52,7 +49,7 @@
 %full solution suggested here https://tex.stackexchange.com/a/682872/148934
 \ExplSyntaxOn
 \NewDocumentEnvironment{quantikz}{O{}+b}{
-\gdef\toslice{0}\def\vert{0}%
+\gdef\toslice at qtkz{0}\def\vert at qtkz{0}%
   \begin{tikzpicture}[/tikz/commutative~diagrams/.cd, every~diagram,baseline={([yshift=-axis_height]\tikzcdmatrixname)}, #1]
   \pgfsetlayers{background,quantback,main}
     \tl_set:Nn \l_tmpa_tl { #2 }
@@ -102,7 +99,7 @@
 
 %patch tikzcd to allow for multiple layers of commands that get deferred until later
 % \patchcmd\tikzcd@{\tikzpicture}{%
-%   \def\toslice{0}\def\vert{0}%
+%   \def\toslice{0}\def\vert at qtkz{0}%
 %  \begin{tikzpicture}}{}{}
 %\patchcmd\tikzcd@{\tikzpicture[/tikz/commutative diagrams/.cd,every diagram,#1]}{%
 %}{}{}
@@ -123,8 +120,8 @@
       \csgundef{cell at width@\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn}
       \csgundef{cell at height@\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn}}
     %\pgfmathsetmacro{\mname}{random(100000)}
-    \ifcsstring{toslice}{1}{\ifcsstring{vert}{0}{\pgfutil at g@addto at macro\tikzcd at atendslices\sliceallr}{\pgfutil at g@addto at macro\tikzcd at atendslices\sliceallvr}}{}
-    %\ifthenelse{\toslice=1}{\ifthenelse{\vert=0}{\PackageWarning{quantikz}{We are slicing}\pgfutil at g@addto at macro\tikzcd at atendslices\sliceallr}{\pgfutil at g@addto at macro\tikzcd at atendslices\sliceallvr}}{}
+    \ifcsstring{toslice at qtkz}{1}{\ifcsstring{vert at qtkz}{0}{\pgfutil at g@addto at macro\tikzcd at atendslices\sliceallr}{\pgfutil at g@addto at macro\tikzcd at atendslices\sliceallvr}}{}
+    %\ifthenelse{\toslice=1}{\ifthenelse{\vert at qtkz=0}{\PackageWarning{quantikz}{We are slicing}\pgfutil at g@addto at macro\tikzcd at atendslices\sliceallr}{\pgfutil at g@addto at macro\tikzcd at atendslices\sliceallvr}}{}
     }{}{}
 
 %this patching works on modern systems, but I believe is incompatible with the old version that arXiv is running
@@ -147,8 +144,12 @@
         I think the culprit is a tikzcd arrow in cell \tikzcd at currentrow-\tikzcd at currentcolumn}}%
     \tikzcd at before@paths at hook%
     \begin{pgfonlayer}{quantback}
+    \begingroup
+    \tikzcdset{wire types/.code={}}%prevent setting of wire types, which wipes all the work we've done!
+    %\begin{scope} already included in tikzcd at savedpaths so that it has right options
       \tikzcd at savedpaths
     \end{scope}
+    \endgroup
     \end{pgfonlayer}
     \tikzcd at atendsavedpaths\tikzcd at atendlabels\tikzcd at atendslices%I just added stuff here instead
     \resetwiretypes%reset wire types
@@ -1193,8 +1194,8 @@
 }
 
 %ghost will get height correct if can't be automatically assigned.
-\DeclareExpandableDocumentCommand{\ghost}{O{}O{0pt}O{1.5pt}m}{%optional parameter contains styling info. compulsory is gate text.
-	|[inner ysep=4pt,minimum width=#2,minimum height=#3]| \vphantom{#4}
+\DeclareExpandableDocumentCommand{\ghost}{O{0pt}O{1.5pt}m}{%optional parameter contains styling info. compulsory is gate text.
+	|[inner ysep=4pt,minimum width=#1,minimum height=#2]| \vphantom{#3}
 }
 
 %%%
@@ -1321,8 +1322,11 @@
 		\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\groupoutput at mid\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter\newoptions\expandafter\expandafter\expandafter}\expandafter\expandafter\expandafter{\expandafter\options\expandafter}\expandafter{\opts}{#2}%
 	}
 }
+\newcommand{\ifcsstringeitheror}[4]{%
+\ifcsstring{#1}{#2}{#4}{\ifcsstring{#1}{#3}{#4}{}}
+}
 %deferred labelling of inputs
-\newcommand{\groupinput at end}[4]{%basic data as keys, lable options, brace options, text
+\newcommand{\groupinput at end}[4]{%basic data as keys, label options, brace options, text
 	\pgfkeys{/quantikz/gates/.cd,wires=1}
 	\def\rightbrace{1}
  	\pgfkeys{/quantikz/gates/.cd,#1}%
@@ -1330,6 +1334,12 @@
 	\pgfkeysgetvalue{/quantikz/gates/row}{\row}
 	\pgfkeysgetvalue{/quantikz/gates/col}{\col}
 	\xdef\LoopGI{}
+  \ifcsstringeitheror{wire at type@\row}{c}{b}{%is the first wire classical? (should include bundle as well)
+\xdef\LoopGI{\LoopGI($(\tikzcdmatrixname-\row-\col.center)+(0,\pgfkeysvalueof{/tikz/commutative diagrams/classical gap})$)}
+  }
+   \ifcsstringeitheror{wire at type@\the\numexpr\row+\quantwires-1\relax}{c}{b}{%is the last wire classical? (should include bundle as well)
+\xdef\LoopGI{\LoopGI($(\tikzcdmatrixname-\the\numexpr\row+\quantwires-1\relax-\col.center)+(0,-\pgfkeysvalueof{/tikz/commutative diagrams/classical gap})$)}
+  }
 	\foreach \n in  {\row,...,\the\numexpr\row+\quantwires-1\relax} {
 	\ifnodedefined{\tikzcdmatrixname-\n-\col}{
 		\xdef\LoopGI{\LoopGI(\tikzcdmatrixname-\n-\col)} 
@@ -1353,6 +1363,12 @@
 	\pgfkeysgetvalue{/quantikz/gates/row}{\row}
 	\pgfkeysgetvalue{/quantikz/gates/col}{\col}
 	\xdef\LoopGO{}
+    \ifcsstringeitheror{wire at type@\row}{c}{b}{%is the first wire classical? (should include bundle as well)
+\xdef\LoopGO{\LoopGO($(\tikzcdmatrixname-\row-\col.center)+(0,\pgfkeysvalueof{/tikz/commutative diagrams/classical gap})$)}
+  }
+   \ifcsstringeitheror{wire at type@\the\numexpr\row+\quantwires-1\relax}{c}{b}{%is the last wire classical? (should include bundle as well)
+\xdef\LoopGO{\LoopGO($(\tikzcdmatrixname-\the\numexpr\row+\quantwires-1\relax-\col.center)+(0,-\pgfkeysvalueof{/tikz/commutative diagrams/classical gap})$)}
+  }
 	\foreach \n in  {\row,...,\the\numexpr\row+\quantwires-1\relax} {
 		\ifnodedefined{\tikzcdmatrixname-\n-\col}{
 			\xdef\LoopGO{\LoopGO(\tikzcdmatrixname-\n-\col)} 
@@ -1375,6 +1391,12 @@
 	\pgfkeysgetvalue{/quantikz/gates/row}{\row}
 	\pgfkeysgetvalue{/quantikz/gates/col}{\col}
 	\xdef\LoopGO{}
+    \ifcsstringeitheror{wire at type@\row}{c}{b}{%is the first wire classical? (should include bundle as well)
+\xdef\LoopGO{\LoopGO($(\tikzcdmatrixname-\row-\col.center)+(0,\pgfkeysvalueof{/tikz/commutative diagrams/classical gap})$)}
+  }
+   \ifcsstringeitheror{wire at type@\the\numexpr\row+\quantwires-1\relax}{c}{b}{%is the first wire classical? (should include bundle as well)
+\xdef\LoopGO{\LoopGO($(\tikzcdmatrixname-\the\numexpr\row+\quantwires-1\relax-\col.center)+(0,-\pgfkeysvalueof{/tikz/commutative diagrams/classical gap})$)}
+  }
 	\foreach \n in  {\row,...,\the\numexpr\row+\quantwires-1\relax} {
 		\ifnodedefined{\tikzcdmatrixname-\n-\col}{
 			\xdef\LoopGO{\LoopGO(\tikzcdmatrixname-\n-\col)} 
@@ -1625,7 +1647,7 @@
 
 %initialise all the pgfkeys for key=value parameter passing in macro options
 \tikzcdset{%
-	slice all/.code={\gdef\toslice{1}},
+	slice all/.code={\gdef\toslice at qtkz{1}},
 	remove end slices/.initial=0,
 	slice titles/.initial={\col},
 	slice style/.initial={},
@@ -1632,7 +1654,7 @@
 	slice label style/.initial={},
 	thin lines/.code={\resetstyles},
 	transparent/.code={\maketransparent},
-	vertical slice labels/.code={\def\vert{1}},
+	vertical slice labels/.code={\def\vert at qtkz{1}},
 	align equals at/.code={\setmiddle{#1}},
   wire types/.code={\importwiretypes{#1}},
   classical gap/.initial=0.03cm, % define separation of classical wires (can override)



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