From c120c202572ae8fa00fd883567ae1b5a8b4d4c14 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 24 May 2023 22:24:25 +0000 Subject: quantikz (25may23) git-svn-id: svn://tug.org/texlive/trunk@67206 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/quantikz/quantikz.sty | 4 +- .../latex/quantikz/tikzlibraryquantikz2.code.tex | 56 +++++++++++++++------- 2 files changed, 41 insertions(+), 19 deletions(-) (limited to 'Master/texmf-dist/tex') diff --git a/Master/texmf-dist/tex/latex/quantikz/quantikz.sty b/Master/texmf-dist/tex/latex/quantikz/quantikz.sty index f0400333379..f1ecfaa75fb 100644 --- a/Master/texmf-dist/tex/latex/quantikz/quantikz.sty +++ b/Master/texmf-dist/tex/latex/quantikz/quantikz.sty @@ -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@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} diff --git a/Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz2.code.tex b/Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz2.code.tex index ac1c7ef8315..90a54a257d4 100644 --- a/Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz2.code.tex +++ b/Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz2.code.tex @@ -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@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,13 +16,7 @@ %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 - -%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] +%\ProvidesPackage{quantikz}[2023/05/24 typeset quantum circuit diagrams] % Package(s) to include \RequirePackage{xargs,ifthen,xstring,xparse,etoolbox,mathtools,pgfmath} @@ -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@qtkz{0}\def\vert@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@qtkz{0}% % \begin{tikzpicture}}{}{} %\patchcmd\tikzcd@{\tikzpicture[/tikz/commutative diagrams/.cd,every diagram,#1]}{% %}{}{} @@ -123,8 +120,8 @@ \csgundef{cell@width@\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn} \csgundef{cell@height@\the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn}} %\pgfmathsetmacro{\mname}{random(100000)} - \ifcsstring{toslice}{1}{\ifcsstring{vert}{0}{\pgfutil@g@addto@macro\tikzcd@atendslices\sliceallr}{\pgfutil@g@addto@macro\tikzcd@atendslices\sliceallvr}}{} - %\ifthenelse{\toslice=1}{\ifthenelse{\vert=0}{\PackageWarning{quantikz}{We are slicing}\pgfutil@g@addto@macro\tikzcd@atendslices\sliceallr}{\pgfutil@g@addto@macro\tikzcd@atendslices\sliceallvr}}{} + \ifcsstring{toslice@qtkz}{1}{\ifcsstring{vert@qtkz}{0}{\pgfutil@g@addto@macro\tikzcd@atendslices\sliceallr}{\pgfutil@g@addto@macro\tikzcd@atendslices\sliceallvr}}{} + %\ifthenelse{\toslice=1}{\ifthenelse{\vert@qtkz=0}{\PackageWarning{quantikz}{We are slicing}\pgfutil@g@addto@macro\tikzcd@atendslices\sliceallr}{\pgfutil@g@addto@macro\tikzcd@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@currentrow-\tikzcd@currentcolumn}}% \tikzcd@before@paths@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@savedpaths so that it has right options \tikzcd@savedpaths \end{scope} + \endgroup \end{pgfonlayer} \tikzcd@atendsavedpaths\tikzcd@atendlabels\tikzcd@atendslices%I just added stuff here instead \resetwiretypes%reset wire types @@ -1193,8 +1194,8 @@ phase label/.code={\tikzset{label distance=2mm,anchor=mid,label position=45} } %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 @@ phase label/.code={\tikzset{label distance=2mm,anchor=mid,label position=45} \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\groupoutput@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@end}[4]{%basic data as keys, lable options, brace options, text +\newcommand{\groupinput@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 @@ phase label/.code={\tikzset{label distance=2mm,anchor=mid,label position=45} \pgfkeysgetvalue{/quantikz/gates/row}{\row} \pgfkeysgetvalue{/quantikz/gates/col}{\col} \xdef\LoopGI{} + \ifcsstringeitheror{wire@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@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 @@ phase label/.code={\tikzset{label distance=2mm,anchor=mid,label position=45} \pgfkeysgetvalue{/quantikz/gates/row}{\row} \pgfkeysgetvalue{/quantikz/gates/col}{\col} \xdef\LoopGO{} + \ifcsstringeitheror{wire@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@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 @@ phase label/.code={\tikzset{label distance=2mm,anchor=mid,label position=45} \pgfkeysgetvalue{/quantikz/gates/row}{\row} \pgfkeysgetvalue{/quantikz/gates/col}{\col} \xdef\LoopGO{} + \ifcsstringeitheror{wire@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@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,14 +1647,14 @@ phase label/.code={\tikzset{label distance=2mm,anchor=mid,label position=45} %initialise all the pgfkeys for key=value parameter passing in macro options \tikzcdset{% - slice all/.code={\gdef\toslice{1}}, + slice all/.code={\gdef\toslice@qtkz{1}}, remove end slices/.initial=0, slice titles/.initial={\col}, slice style/.initial={}, slice label style/.initial={}, thin lines/.code={\resetstyles}, transparent/.code={\maketransparent}, - vertical slice labels/.code={\def\vert{1}}, + vertical slice labels/.code={\def\vert@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) -- cgit v1.2.3