diff options
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz.code.tex | 124 |
1 files changed, 63 insertions, 61 deletions
diff --git a/Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz.code.tex b/Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz.code.tex index f2c15ced5be..3c67e016daf 100644 --- a/Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz.code.tex +++ b/Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz.code.tex @@ -4,6 +4,8 @@ % 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 0.9.5: +% fixed bug which meant multi-wire gates didn't work outside of an environment such as center. %version 0.9.4: % added nwires and cwires options to gate command to simulate qcircuit's nphantom and cphantom % vertical text options for slice labels. @@ -30,7 +32,7 @@ %version 0.9.0: %original release. -\ProvidesPackage{quantikz}[2019/03/18 typeset quantum circuit diagrams] +\ProvidesPackage{quantikz}[2019/04/24 typeset quantum circuit diagrams] % Package(s) to include \RequirePackage{xargs,ifthen,xstring,xparse,etoolbox,mathtools} @@ -97,12 +99,12 @@ \expandafter\@temp\endtikzcd } \def\temp{&} \catcode`&=\active \let&=\temp - +% %commands for putting in text vertically \protected\def\vvv#1{\leavevmode\bgroup\vbox\bgroup\xvvv#1\relax} - +% \def\xvvv{\afterassignment\xxvvv\let\tmp= } - +% \def\xxvvv{% % \ifx\tmp\@sptoken\egroup\ \vbox\bgroup\let\next\xvvv % \else @@ -112,7 +114,7 @@ \let\next\xvvv\fi%\fi \next} %end of commands for putting text vertically - +% \long\def\ifnodedefined#1#2#3{% \@ifundefined{pgf@sh@ns@#1}{#3}{#2}% } @@ -126,63 +128,63 @@ %the main gate command \DeclareExpandableDocumentCommand{\gate}{O{}O{1.5pt}O{1.5pt}m}{%optional parameter contains styling info. compulsory is gate text. - |[inner sep=4pt,minimum width=#2,minimum height=#3]| - \edef\n{\the\pgfmatrixcurrentrow} %the row - \edef\m{\the\pgfmatrixcurrentcolumn} %the column - %resent macros that are going to be set by the options - \edef\options{row=\n,col=\m,#1} - \def\toswap{0}% - \def\DisableMinSize{0}% - \pgfkeys{/quantikz,wires=1,style=,label style=,braces=}% - %import options passed as parameters - \pgfkeys{/quantikz,#1}% - \pgfkeysgetvalue{/quantikz/wires}{\quantwires} - \pgfkeysgetvalue{/quantikz/style}{\a} - \pgfkeysgetvalue{/quantikz/label style}{\b} - \pgfkeysgetvalue{/quantikz/cwires}{\mylist} - \pgfkeysgetvalue{/quantikz/nwires}{\nowires} - \ifthenelse{\toswap=1}{%if it's a swap gate... - \def\quantwires{2} - \phantom{wide} - \settowidth{\myl}{$wide$} - \settoheight{\myh}{$wide$} - \settodepth{\myd}{$wide$} - }{%not a swap gate - \settowidth{\myl}{$#4$} - \ifthenelse{\DisableMinSize=1}{%disable automatic size detection. Use $U$ instead. - \phantom{U} - \settoheight{\myh}{$U$} - \settodepth{\myd}{$U$} - }{%automatically get width and height of label - \phantom{#4} - \settoheight{\myh}{$#4$} - \settodepth{\myd}{$#4$} - } - } + |[inner sep=4pt,minimum width=#2,minimum height=#3]|% + \edef\n{\the\pgfmatrixcurrentrow} %the row + \edef\m{\the\pgfmatrixcurrentcolumn} %the column + %reset macros that are going to be set by the options + \edef\options{row=\n,col=\m,#1} + \def\toswap{0}% + \def\DisableMinSize{0}% + \pgfkeys{/quantikz,wires=1,style=,label style=,braces=}% + %import options passed as parameters + \pgfkeys{/quantikz,#1}% + \pgfkeysgetvalue{/quantikz/wires}{\quantwires} + \pgfkeysgetvalue{/quantikz/style}{\a} + \pgfkeysgetvalue{/quantikz/label style}{\b} + \pgfkeysgetvalue{/quantikz/cwires}{\mylist} + \pgfkeysgetvalue{/quantikz/nwires}{\nowires} + \ifthenelse{\toswap=1}{%if it's a swap gate... + \def\quantwires{2} + \phantom{wide} + \settowidth{\myl}{$wide$} + \settoheight{\myh}{$wide$} + \settodepth{\myd}{$wide$} + }{%not a swap gate + \settowidth{\myl}{$#4$} + \ifthenelse{\DisableMinSize=1}{%disable automatic size detection. Use $U$ instead. + \phantom{U} + \settoheight{\myh}{$U$} + \settodepth{\myd}{$U$} + }{%automatically get width and height of label + \phantom{#4} + \settoheight{\myh}{$#4$} + \settodepth{\myd}{$#4$} + } + } % - \IfInList{1}{\mylist}{\cw}{\IfInList{1}{\nowires}{}{\qw}}%do we need classical, no wire, or quantum wire? - \edef\k{\the\numexpr\n+\quantwires-1\relax} - \edef\mn{\the\numexpr\m-1\relax} - \ifthenelse{\quantwires=1}{}{%more than 1 wire on gate. iterate through each wire - \foreach \i in {\the\numexpr\n+1\relax,...,\k} { - \edef\newcom{\noexpand\vcwhexplicit{\i-\m}{\i-\mn}} - \edef\newcomb{\noexpand\vqwexplicit{\i-\m}{\i-\mn}} - \edef\val{\the\numexpr\i+1-\n\relax} - \IfInList{\val}{\mylist}{\newcom}{\IfInList{\val}{\nowires}{}{\newcomb}}%do we need classical, no wire, or quantum wire? - %apply auto width to the cell, and make sure we unset the setting so that it doesn't apply to later circuits. - \globaldefs=1 - \edef\dotikzset{\noexpand\tikzset{row \i\space column \m/.append style={minimum width={max(\the\myl+8pt,#2)}}}} - \dotikzset - \edef\undotikzset{\noexpand\tikzset{row \i\space column \m/.style={}}} - \expandafter\pgfutil@g@addto@macro\expandafter\tikzcd@atendglobals\expandafter{\undotikzset} - } - %apply auto height to last row only. unsetting already handled above. - \globaldefs=1 - \edef\dotikzset{\noexpand\tikzset{row \k\space column \m/.append style={minimum height={max(\the\myh+\the\myd+8pt,#3)}}}} - \dotikzset - - } - %call deferred gate command. + \IfInList{1}{\mylist}{\cw}{\IfInList{1}{\nowires}{}{\qw}}%do we need classical, no wire, or quantum wire? + \edef\k{\the\numexpr\n+\quantwires-1\relax} + \edef\mn{\the\numexpr\m-1\relax} + \ifthenelse{\quantwires=1}{}{%more than 1 wire on gate. iterate through each wire + \foreach \i in {\the\numexpr\n+1\relax,...,\k} { + \edef\newcom{\noexpand\vcwhexplicit{\i-\m}{\i-\mn}} + \edef\newcomb{\noexpand\vqwexplicit{\i-\m}{\i-\mn}} + \edef\val{\the\numexpr\i+1-\n\relax} + \IfInList{\val}{\mylist}{\newcom}{\IfInList{\val}{\nowires}{}{\newcomb}}%do we need classical, no wire, or quantum wire? + %apply auto width to the cell, and make sure we unset the setting so that it doesn't apply to later circuits. + \globaldefs=1 + \edef\dotikzset{\noexpand\tikzset{row \i\space column \m/.append style={minimum width={max(\the\myl+8pt,#2)}}}} + \dotikzset + \edef\undotikzset{\noexpand\tikzset{row \i\space column \m/.style={}}} + \expandafter\pgfutil@g@addto@macro\expandafter\tikzcd@atendglobals\expandafter{\undotikzset} + } + %apply auto height to last row only. unsetting already handled above. + \globaldefs=1 + \edef\dotikzset{\noexpand\tikzset{row \k\space column \m/.append style={minimum height={max(\the\myh+\the\myd+8pt,#3)}}}} + \dotikzset +% + } + %call deferred gate command. \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\pgfutil@g@addto@macro\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\tikzcd@atendsavedpaths\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\gate@end\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter\a\expandafter\expandafter\expandafter}\expandafter\expandafter\expandafter{\expandafter\b\expandafter}\expandafter{\options}{#4} } |