summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz.code.tex293
1 files changed, 224 insertions, 69 deletions
diff --git a/Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz.code.tex b/Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz.code.tex
index 7d6a96319a4..f2c15ced5be 100644
--- a/Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz.code.tex
+++ b/Master/texmf-dist/tex/latex/quantikz/tikzlibraryquantikz.code.tex
@@ -1,9 +1,22 @@
-%This is the quantikz library for typesetting quantum circuits using LaTeX/Tikz. version 0.9.1
-%Written by Alastair Kay, 2018. Published under a CC-BY-4.0 licence
-% Please email me with any bug reports or feature requests.
-%If you find this library useful, please cite its usage in your work,using the DOI: 10.17637/rh.7000520.
+%This is the quantikz library for typesetting quantum circuits using LaTeX/Tikz. version 0.9.4
+% 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 0.9.4:
+% added nwires and cwires options to gate command to simulate qcircuit's nphantom and cphantom
+% vertical text options for slice labels.
+% replaced macro for measuring width and height for greater reliability. disable auto spacing now unnecessary as things like \sqrt{} work in the gate label.
+% investigated possibility of high labels (multi-line labels, particularly for a multi-qubit gate). key disable auto height introduced.
+% now provides a quantikz environment, which is theoretically compatible with tikz' external library (entirely untested). Can still use tikzcd environment otherwise.
+% removed a tikzcd customisation fixing the baseline for one row circuits as this was messing with any manual attempts to adjust the baseline.
+%version 0.9.3:
+% adjusted spacing of gate operation between in-circuit and overlay so that transparency looks better
+% Other gate spacing adjustments. multi-qubit gates in particular should look better. 'disable auto spacing' can switch this off, particularly for use with things like \sqrt{} in the multi-qubit gate label, which will throw a weird error.
+% gate command now takes two further optional parameters: minimum width and minimum height for each cell.
+% some consolidation of styling commands
+% global keys 'transparent' and 'thin lines' added. 'thin lines' gives a look more similar to the original QCircuit.
%version 0.9.2:
% made 'wires' the default key, so [wires=2] now becomes [2]
% added 'slice title', 'slices style', 'slices label style' key to control titles of slices under 'slice all'
@@ -17,14 +30,19 @@
%version 0.9.0:
%original release.
+\ProvidesPackage{quantikz}[2019/03/18 typeset quantum circuit diagrams]
% Package(s) to include
-\RequirePackage{xargs,ifthen,xstring,xparse,etoolbox}
+\RequirePackage{xargs,ifthen,xstring,xparse,etoolbox,mathtools}
+\RequirePackage{environ} %in an attempt to help with compatibility with the external library of tikz.
\RequirePackage{tikz}
-%\RequirePackage{pgffor,pgfmath}
\usetikzlibrary{cd,decorations.pathreplacing,calc,positioning,fit,shapes.symbols,decorations.pathmorphing,shapes.misc,backgrounds,decorations.markings}
-\makeatletter
+\newlength{\myl}
+\newlength{\myh}
+\newlength{\myd}
+
+%\makeatletter
\newcounter{aaa}
\tikzset{
apply/.style args={#1 except on segments #2}{postaction={
@@ -58,37 +76,123 @@
},
},
}
+%test if item is in list of item. Probably better ways to do this, but I could get this version to work.
+\newcommand*{\IfInList}[2]{%
+ \gdef\memory{0}
+ \edef\arg{#1}
+ \foreach \q in #2 {%
+ \ifthenelse{\q=\arg}{%
+ \gdef\memory{1}
+ }{}
+ }
+ \ifthenelse{\memory=1} {%
+ \expandafter\@firstoftwo
+ }{%
+ \expandafter\@secondoftwo
+ }
+}
+%define the quantikz environment. I need this to facilitate the external library
+\NewEnviron{quantikz}[1][]{%
+ \def\@temp{\tikzcd@[#1]\BODY}%
+ \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
+\ifx\tmp\relax\egroup\egroup\let\next\relax
+ \else
+\hbox to 1.1em{\hfill\tmp\hfill}% centred
+\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}%
}
+%I don't think this is used any more
+% \newcommand\getwidth[1]{
+% \pgfkeys{minimum width=0pt}%
+% \pgfkeys{/quantikz,#1}
+% \pgfkeysgetvalue{/quantikz/minimum width}{\minwidth}
+% \minwidth
+% }
%the main gate command
-\newcommand\gate[2][]{%optional parameter contains styling info. compulsory is gate text.
- \def\toswap{0}
- \edef\options{row=\the\pgfmatrixcurrentrow,col=\the\pgfmatrixcurrentcolumn,#1}
- \pgfkeys{/quantikz,wires=1,style=,label style=,braces=}
+\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}
- \edef\n{\the\pgfmatrixcurrentrow}
- \edef\m{\the\pgfmatrixcurrentcolumn}
- \ifthenelse{\toswap=1}{\def\quantwires{2}\phantom{wide}}{\phantom{#2}}
+ \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}
- \foreach \i in {\n,...,\k} {
- \edef\from{\i-\m}
- \edef\to{\i-\the\numexpr\m-1\relax}
- \expandafter\expandafter\expandafter\vqwexplicit\expandafter\expandafter\expandafter{\expandafter\from\expandafter}\expandafter{\to}
+ \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}{#2}
+ \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}
}
}
-%deferred gate command
+
+%deferred gate command. draws a box around all included cells. this is not part of the matrix, but comes afterwards.
\newcommand{\gate@end}[4]{
\pgfkeys{/quantikz,wires=1}
\def\toswap{0}
+ \def\DisableMinSize{0}
\pgfkeys{/quantikz,#3}%
\pgfkeysgetvalue{/quantikz/wires}{\quantwires}
\pgfkeysgetvalue{/quantikz/row}{\row}
@@ -101,15 +205,20 @@
}{}
}
\ifthenelse{\toswap=1}{
- \node (group\tikzcdmatrixname-\row-\col) [fit=\LoopGG,operator,inner xsep=3pt,inner ysep=5pt,#1] {\hphantom{wide}};
- \draw [thick] (group\tikzcdmatrixname-\row-\col.west|-\tikzcdmatrixname-\row-\col.center) to[out=0,in=180] (group\tikzcdmatrixname-\row-\col.east|-\tikzcdmatrixname-\the\numexpr\row+1\relax-\col.center);
+ \node (group\tikzcdmatrixname-\row-\col) [fit=\LoopGG,operator,inner sep=0pt,#1] {\hphantom{Wide}};
+ \draw [thickness] (group\tikzcdmatrixname-\row-\col.west|-\tikzcdmatrixname-\row-\col.center) to[out=0,in=180] (group\tikzcdmatrixname-\row-\col.east|-\tikzcdmatrixname-\the\numexpr\row+1\relax-\col.center);
\draw [line width=3pt,white,shorten >=0.9pt,shorten <=0.9pt] (group\tikzcdmatrixname-\row-\col.east|-\tikzcdmatrixname-\row-\col.center) to[out=180,in=0] (group\tikzcdmatrixname-\row-\col.west|-\tikzcdmatrixname-\the\numexpr\row+1\relax-\col.center);
- \draw [thick] (group\tikzcdmatrixname-\row-\col.east|-\tikzcdmatrixname-\row-\col.center) to[out=180,in=0] (group\tikzcdmatrixname-\row-\col.west|-\tikzcdmatrixname-\the\numexpr\row+1\relax-\col.center);
+ \draw [thickness] (group\tikzcdmatrixname-\row-\col.east|-\tikzcdmatrixname-\row-\col.center) to[out=180,in=0] (group\tikzcdmatrixname-\row-\col.west|-\tikzcdmatrixname-\the\numexpr\row+1\relax-\col.center);
}{
- \node (group\tikzcdmatrixname-\row-\col) [fit=\LoopGG,operator,inner xsep=3pt,inner ysep=5pt,label={[gg label,#2]$#4$},#1] {\hphantom{$#4$}};
+ \node (group\tikzcdmatrixname-\row-\col) [fit=\LoopGG,operator,inner sep=0pt,label={[gg label,#2]$#4$},#1] {\hphantom{$#4$}};
}
}
+%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}
+}
+
%single slice
\newcommand\slice[2][]{%
@@ -134,11 +243,21 @@
}
%deferred command which will slice everything
\newcommand{\sliceallr}{
+ \edef\sstyle{\pgfkeysvalueof{/tikz/slice style}}
+ \edef\slstyle{\pgfkeysvalueof{/tikz/slice label style}}
\foreach \n in {2,...,\the\numexpr\pgfmatrixcurrentcolumn-1-\pgfkeysvalueof{/tikz/remove end slices}\relax} {
\edef\col{\the\numexpr\n-1\relax}
\edef\title{\pgfkeysvalueof{/tikz/slice titles}}
- \edef\sstyle{\pgfkeysvalueof{/tikz/slice style}}
- \edef\slstyle{\pgfkeysvalueof{/tikz/slice label style}}
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\slice@end\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter\n\expandafter\expandafter\expandafter}\expandafter\expandafter\expandafter{\expandafter\sstyle\expandafter}\expandafter{\slstyle}{\title}
+ }
+}
+%deferred slice command with vertical text
+\newcommand{\sliceallvr}{
+ \edef\sstyle{\pgfkeysvalueof{/tikz/slice style}}
+ \edef\slstyle{\pgfkeysvalueof{/tikz/slice label style}}
+ \foreach \n in {2,...,\the\numexpr\pgfmatrixcurrentcolumn-1-\pgfkeysvalueof{/tikz/remove end slices}\relax} {
+ \edef\col{\the\numexpr\n-1\relax}
+ \edef\title{\vvv{\pgfkeysvalueof{/tikz/slice titles}}}
\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\slice@end\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter\n\expandafter\expandafter\expandafter}\expandafter\expandafter\expandafter{\expandafter\sstyle\expandafter}\expandafter{\slstyle}{\title}
}
}
@@ -288,7 +407,7 @@
\node (wave-#1) [fit=(\tikzcdmatrixname-row#1),wave,#2] {};
}
-
+%put a border around a group of gates
\newcommand\gategroup[2][]{%
\pgfkeys{/quantikz,wires=1,style=,label style=,braces=}
\pgfkeys{/quantikz,#1}%
@@ -299,7 +418,7 @@
\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\gategroup@end\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter\newoptions\expandafter\expandafter\expandafter}\expandafter\expandafter\expandafter{\expandafter\options\expandafter}\expandafter{\opts}{#2}%
}
}
-
+%deferred gate group command
\newcommand{\gategroup@end}[4]{%options, gate style, text style, text
\pgfkeys{/quantikz,wires=1,style=,label style=,braces=,steps=1}%
\edef\background{0}%
@@ -310,9 +429,9 @@
\pgfkeysgetvalue{/quantikz/steps}{\steps}%
\edef\fit{(\tikzcdmatrixname-col\col.west |- \tikzcdmatrixname-row\row.north)(\tikzcdmatrixname-col\the\numexpr\col+\steps-1\relax.east |- \tikzcdmatrixname-row\the\numexpr\row+\quantwires-1\relax.south)}%
\ifthenelse{\background=1}{%
- \begin{scope}[on background layer]\node (ggroup-\row-\col) [fit=\fit,draw,inner sep=4pt,thick,label={[group label,#3]:#4},#2] {};\end{scope}
+ \begin{scope}[on background layer]\node (ggroup-\row-\col) [fit=\fit,ggroup,label={[group label,#3]:#4},#2] {};\end{scope}
}{%
- \node (ggroup-\row-\col) [fit=\fit,draw,inner sep=4pt, thick,label={[group label,#3]:#4},#2] {};
+ \node (ggroup-\row-\col) [fit=\fit,ggroup,label={[group label,#3]:#4},#2] {};
}
}
@@ -329,23 +448,23 @@
\node [phase,inner sep=2pt] at (\tikzcdmatrixname-#1) {};
}
-
%patch tikzcd to allow for multiple layers of commands
-\patchcmd\tikzcd@{\tikzpicture}{\def\toslice{0}
- \tikzpicture}{}{}
+\patchcmd\tikzcd@{\tikzpicture}{\def\toslice{0}\def\vert{0}
+ \begin{tikzpicture}}{}{}
\patchcmd\tikzcd@
{\global\let\tikzcd@savedpaths\pgfutil@empty}
{\global\let\tikzcd@savedpaths\pgfutil@empty
\global\let\tikzcd@atendsavedpaths\pgfutil@empty
\global\let\tikzcd@atendlabels\pgfutil@empty
\global\let\tikzcd@atendslices\pgfutil@empty
+ \global\let\tikzcd@atendglobals\pgfutil@empty
\pgfutil@g@addto@macro\tikzcd@savedpaths\DivideRowsCols
%\pgfmathsetmacro{\mname}{random(100000)}
- \ifthenelse{\toslice=1}{\pgfutil@g@addto@macro\tikzcd@atendslices\sliceallr}{}
+ \ifthenelse{\toslice=1}{\ifthenelse{\vert=0}{\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
-%\patchcmd\endtikzcd{\tikzcd@savedpaths}{\tikzcd@savedpaths\tikzcd@atendsavedpaths\tikzcd@atendlabels\tikzcd@atendslices}{}{}
+%\patchcmd\endtikzcd{\tikzcd@savedpaths}{\tikzcd@savedpaths\tikzcd@atendsavedpaths\tikzcd@atendlabels\tikzcd@atendslices{\globaldefs=1\tikzcd@atendglobals}}{}{}
%instead, completely redefine the function
\def\endtikzcd{%
@@ -363,14 +482,14 @@
\def\errmessage##1{\tikzcd@errmessage{##1^^J...^^Jl.\tikzcd@lineno\space%
I think the culprit is a tikzcd arrow in cell \tikzcd@currentrow-\tikzcd@currentcolumn}}%
\tikzcd@before@paths@hook%
- \tikzcd@savedpaths\tikzcd@atendsavedpaths\tikzcd@atendlabels\tikzcd@atendslices%I just added stuff here instead
+ \tikzcd@savedpaths\tikzcd@atendsavedpaths\tikzcd@atendlabels\tikzcd@atendslices{\globaldefs=1\tikzcd@atendglobals}%I just added stuff here instead
\endgroup%
- \endtikzpicture%
+ \end{tikzpicture}%
\ifnum0=`{}\fi}
%end patching
-\makeatother
+%\makeatother
%this command runs after we've finished the matrix, and makes unified cells for each row and each column. This allows much nicer alignment of large boxes.
\newcommand{\DivideRowsCols}{
@@ -402,30 +521,31 @@
%initialise all the pgfkeys for key=value parametre passing in macro options
-\pgfkeys{/tikz/slice all/.code={\def\toslice{1}},/tikz/remove end slices/.initial=0,/tikz/slice titles/.initial={\col},/tikz/slice style/.initial={},/tikz/slice label style/.initial={}}
+\pgfkeys{/tikz/slice all/.code={\def\toslice{1}},/tikz/remove end slices/.initial=0,/tikz/slice titles/.initial={\col},/tikz/slice style/.initial={},/tikz/slice label style/.initial={},/tikz/thin lines/.code={\resetstyles},/tikz/transparent/.code={\maketransparent},/tikz/vertical slice labels/.code={\def\vert{1}}}
\pgfkeys{/quantikz/.is family,/quantikz,%
.unknown/.style={%
/quantikz/wires=\pgfkeyscurrentname
},%
wires/.initial=1,%
-style/.initial={},label style/.initial={},braces/.initial={},background/.code={\def\background{1}},alternate/.code={\def\helper{1}},row/.initial=1,col/.initial=1,steps/.initial=1,Strike Width/.initial=0.08cm,Strike Height/.initial=0.12cm,swap/.code={\def\toswap{1}}}
-%\pgfkeys{/quantikz/.unknown/.style={/tikz}}
-%\pgfkeys{/tikz/background/.style={},/tikz/wires/.style={}}
+style/.initial={},label style/.initial={},braces/.initial={},background/.code={\def\background{1}},alternate/.code={\def\helper{1}},row/.initial=1,col/.initial=1,steps/.initial=1,Strike Width/.initial=0.08cm,Strike Height/.initial=0.12cm,swap/.code={\def\toswap{1}},disable auto height/.code={\def\DisableMinSize{1}},cwires/.initial={-1},nwires/.initial={-1}}
-%Define some useful commands
-\providecommand{\ket}[1]{\ensuremath{\left | #1 \right\rangle}}
-\providecommand{\bra}[1]{\ensuremath{\left \langle #1 \right |}}
-\providecommand{\proj}[1]{\ket{#1}\bra{#1}}
+%my standard Dirac notation commands. can be overridden by user.
+\providecommand{\ket}[1]{\ensuremath{\left|#1\right\rangle}}
+\providecommand{\bra}[1]{\ensuremath{\left\langle#1\right |}}
+\providecommand{\proj}[1]{\ensuremath{\ket{#1}\!\bra{#1}}}
+\providecommand{\braket}[2]{\ensuremath{\left\langle#1\middle|#2\right\rangle}}
%single qubit operations
-\newcommand{\phantomgate}[1]{|[linecont,thick, inner ysep=3pt]| \phantom{#1} \qw}
-\newcommand{\hphantomgate}[1]{|[linecont,minimum size=1.5em,thick]| \hphantom{#1} \qw}
+\newcommand{\phantomgate}[1]{|[linecont,thickness, inner ysep=3pt]| \phantom{#1} \qw}
+\newcommand{\hphantomgate}[1]{|[linecont,minimum size=1.5em,thickness]| \hphantom{#1} \qw}
\newcommand{\push}[1]{#1 \qw}
-\DeclareExpandableDocumentCommand{\phase}{O{}m}{|[phase,label={[phase label]#2},#1]| {} \qw}
+\newcommand{\alias}[1]{|[alias=#1]|}
+\DeclareExpandableDocumentCommand{\phase}{O{}m}{|[phase,#1,label={[phase label,#1]#2}]| {} \qw}
\DeclareExpandableDocumentCommand{\control}{O{}m}{|[phase,#1]| {} \qw}
\DeclareExpandableDocumentCommand{\ocontrol}{O{}m}{|[ophase,#1]| {} \qw}
\DeclareExpandableDocumentCommand{\targ}{O{}m}{|[circlewc,#1]| {} \qw}
\DeclareExpandableDocumentCommand{\targX}{O{}m}{|[crossx2,#1]| {} \qw}
+\newcommand{\linethrough}{|[linecont, inner ysep=3pt]| }
%measuring
\DeclareExpandableDocumentCommand{\meter}{O{}{m}}{|[meter,label={[my label]#2},#1]| {} \qw}
@@ -458,64 +578,75 @@ style/.initial={},label style/.initial={},braces/.initial={},background/.code={\
}
%quantum wire, absolute positioning
\newcommand{\vqwexplicit}[2]{
- \arrow[from=#1,to=#2,dash,thick] {}
+ \arrow[from=#1,to=#2,arrows] {}
}
+%classical vertical wire, absolute positioning
\newcommand{\vcwexplicit}[2]{
- \arrow[from=#1,to=#2,dash,thick,xshift=0.05cm] {}\arrow[from=#1,to=#2,dash,thick,xshift=-0.05cm] {}
+ \arrow[from=#1,to=#2,arrows,xshift=0.05cm] {}\arrow[from=#1,to=#2,arrows,xshift=-0.05cm] {}
+}
+%classical horizontal wire, absolute positioning
+\newcommand{\vcwhexplicit}[2]{
+ \arrow[from=#1,to=#2,arrows,yshift=0.05cm] {}\arrow[from=#1,to=#2,arrows,yshift=-0.05cm] {}
}
%quantum wire, absolute positioning, going to centres of cell, not edge.
\newcommand{\vqwexplicitcenter}[2]{
- \arrow[from=#1,to=#2,dash,thick,start anchor=center,end anchor=center] {}
+ \arrow[from=#1,to=#2,arrows,start anchor=center,end anchor=center] {}
}
%horizontal wires
-\newcommand{\qw}{\ifthenelse{\the\pgfmatrixcurrentcolumn>1}{\arrow[dash,thick]{l}}{}}
-\newcommand{\cw}{\ifthenelse{\the\pgfmatrixcurrentcolumn>1}{\arrow[dash,thick,yshift=0.05cm]{l}\arrow[dash,thick,yshift=-0.05cm]{l}}{}}
+\newcommand{\qw}{\ifthenelse{\the\pgfmatrixcurrentcolumn>1}{\arrow[arrows]{l}}{}}
+\newcommand{\cw}{\ifthenelse{\the\pgfmatrixcurrentcolumn>1}{\arrow[arrows,yshift=0.05cm]{l}\arrow[arrows,yshift=-0.05cm]{l}}{}}
%define the strike distance for strike-through on qwbundle.
%\newcommand*{\StrikeDistance}{0.1cm}%
%a bundle of horizontal quantum wires
-\newcommand{\qwbundle}[1][]{\ifthenelse{\the\pgfmatrixcurrentcolumn>1}{
+\newcommand{\qwbundle}[2][]{\ifthenelse{\the\pgfmatrixcurrentcolumn>1}{
\def\helper{0}
\pgfset{/quantikz,#1}
\ifthenelse{\helper=1}{
- \arrow[dash,thick,yshift=0.1cm]{l}\arrow[dash,thick]{l}\arrow[dash,thick,yshift=-0.1cm]{l}
+ \arrow[arrows,yshift=0.1cm]{l}\arrow[arrows]{l}\arrow[arrows,yshift=-0.1cm]{l}
}{
- \arrow[phantom,strike arrow]{l}
+ \arrow[phantom,strike arrow]{l}[xshift=\pgfkeysvalueof{/quantikz/Strike Width}, yshift=\pgfkeysvalueof{/quantikz/Strike Height},anchor=south west,inner sep=0pt]{\scriptstyle #2}
}}{}}
%configure some of the style properties.
-\tikzcdset{row sep/normal=0.5cm,column sep/normal=0.5cm,thick,nodes in empty cells,every cell/.style={
+\tikzcdset{row sep/normal=0.5cm,column sep/normal=0.5cm,thick,nodes in empty cells,
+ every cell/.style={
anchor=center,minimum size=0pt,inner sep=0pt,outer sep=0pt,thick
- }
+ },
+ arrows/.style={dash,thick},
+ 1-row diagram/.style={}
}
\tikzset{
- operator/.style={draw,fill=white,minimum size=1.5em, inner xsep=2pt,thick,align=center},
+ thickness/.style={thick},
+ operator/.style={draw,fill=white,minimum size=1.5em, inner sep=2pt,thickness,align=center},
+ ggroup/.style={draw,minimum size=1.5em,thickness,align=center,inner sep=4pt},
leftinternal/.style={anchor=mid west,font=\scriptsize,inner sep=4pt,align=center},
rightinternal/.style={anchor=mid east,font=\scriptsize,inner sep=4pt,align=center},
wave/.style={inner sep=-3pt,tape,fill=white,apply={draw=black} except on segments {5,6,1,2,9}},
phase/.style={fill,shape=circle,minimum size=4pt},
- phase label/.style={label distance=2mm,label position=45,anchor=mid},
+ phase label/.style={label distance=2mm,anchor=mid,label position=45},
ophase/.style={fill=white,draw=black,shape=circle,minimum size=4pt},
+ internal/.style={thickness,black},
line/.style={path picture={
-\draw[thick,black](path picture bounding box.west) -- (path picture bounding box.east);
+\draw[internal](path picture bounding box.west) -- (path picture bounding box.east);
}},
linecont/.style={circle,line},
cross/.style={path picture={
-\draw[thick,black](path picture bounding box.north) -- (path picture bounding box.south) (path picture bounding box.west) -- (path picture bounding box.east);
+\draw[internal](path picture bounding box.north) -- (path picture bounding box.south) (path picture bounding box.west) -- (path picture bounding box.east);
}},
circlewc/.style={draw,circle,cross,minimum width=4pt,inner sep=3pt},
crossx/.style={path picture={
-\draw[thick,black,inner sep=0pt]
+\draw[internal,inner sep=0pt]
(path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east) (path picture bounding box.west) -- (path picture bounding box.east);
}},
crossx2/.style={circle,crossx,minimum size=1em},
- dd/.style={decoration={brace},decorate,thick},
- dm/.style={decoration={brace,mirror},decorate,thick},
- slice/.style={thick,red,dash pattern=on 5pt off 3pt,align=center},
- meter/.style={draw,fill=white,minimum width=2em,minimum height=1.5em, rectangle, font=\vphantom{A}, line width=.8,
+ dd/.style={decoration={brace},decorate,thickness},
+ dm/.style={decoration={brace,mirror},decorate,thickness},
+ slice/.style={thickness,red,dash pattern=on 5pt off 3pt,align=center},
+ meter/.style={draw,fill=white,minimum width=2em,minimum height=1.5em, rectangle, font=\vphantom{A}, thickness,
path picture={\draw[black] ([shift={(.1,.24)}]path picture bounding box.south west) to[bend left=50] ([shift={(-.1,.24)}]path picture bounding box.south east);\draw[black,-{Latex[scale=0.6]}] ([shift={(0,.1)}]path picture bounding box.south) -- ([shift={(.3,-.1)}]path picture bounding box.north);}},
measuretab/.style={draw,signal,signal to=west,inner sep=4pt,fill=white},
meterD/.style={draw,rounded rectangle,rounded rectangle left arc=none,inner sep=4pt,fill=white},
@@ -525,10 +656,34 @@ style/.initial={},label style/.initial={},braces/.initial={},background/.code={\
group label/.style={label position=above,yshift=0.2cm,anchor=mid},
strike arrow/.style={
decoration={markings, mark=at position 0.5 with {
- \draw [black, thick,-]
+ \draw [internal,-]
++ (-\pgfkeysvalueof{/quantikz/Strike Width},-\pgfkeysvalueof{/quantikz/Strike Height} )
-- ( \pgfkeysvalueof{/quantikz/Strike Width}, \pgfkeysvalueof{/quantikz/Strike Height});} %can I use pgfkeys and do some maths here?
},
postaction={decorate},
}
+}
+
+\def\resetstyles{
+\tikzcdset{thin,every cell/.append style={thin},arrows/.append style={thin}
+ }
+\tikzset{
+ thickness/.style={thin},
+ %operator/.append style={thin},
+ %internal/.append style={thin},
+ %dd/.append style={thin},
+ %dm/.append style={thin},
+ %slice/.append style={thin},
+ meter/.append style={thin},
+ phase/.append style={minimum size=3pt},
+ ophase/.append style={minimum size=3pt},
+ %circlewc/.append style={minimum size=3pt,inner sep=2pt}
+}
+}
+
+\def\maketransparent{
+\tikzset{
+ operator/.append style={fill opacity=0},
+ meter/.append style={fill opacity=0}
+}
} \ No newline at end of file