diff options
author | Karl Berry <karl@freefriends.org> | 2021-06-15 20:05:24 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-06-15 20:05:24 +0000 |
commit | b1a5ae16842772228c63f9adfb509ec929aab68f (patch) | |
tree | 1da71c47d18a8ca2975eb1e75398cd0d30983f0f /Master/texmf-dist/tex | |
parent | cdf968374fabccbead3376f70ac764d12ad3d8cf (diff) |
circuitikz (15jun21)
git-svn-id: svn://tug.org/texlive/trunk@59598 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
5 files changed, 517 insertions, 103 deletions
diff --git a/Master/texmf-dist/tex/context/third/circuitikz/t-circuitikz.tex b/Master/texmf-dist/tex/context/third/circuitikz/t-circuitikz.tex index 671a47c9520..75f05cdaf65 100644 --- a/Master/texmf-dist/tex/context/third/circuitikz/t-circuitikz.tex +++ b/Master/texmf-dist/tex/context/third/circuitikz/t-circuitikz.tex @@ -10,8 +10,8 @@ % % See the files gpl-3.0_license.txt and lppl-1-3c_license.txt for more details. -\def\pgfcircversion{1.3.7} -\def\pgfcircversiondate{2021/06/01} +\def\pgfcircversion{1.3.8} +\def\pgfcircversiondate{2021/06/15} \writestatus{loading}{\pgfcircversiondate{} The CircuiTikz circuit drawing package version \pgfcircversion} \usemodule[tikz] diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcirc.defines.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcirc.defines.tex index 9c49d71525c..d32e7d2e2ee 100644 --- a/Master/texmf-dist/tex/generic/circuitikz/pgfcirc.defines.tex +++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcirc.defines.tex @@ -31,7 +31,7 @@ \pgfkeys{\circuitikzbasekey/.is family} -\def\circuitikzset#1{\pgfkeys{\circuitikzbasekey,#1}} +\def\circuitikzset{\expandafter\pgfqkeys\expandafter{\circuitikzbasekey}} \let\ctikzset\circuitikzset \def\ctikzvalof#1{\pgfkeysvalueof{\circuitikzbasekey/#1}} \def\ctikzsetvalof#1#2{\pgfkeyssetvalue{\circuitikzbasekey/#1}{#2}} diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex index 23e0d40b7fb..9abaf1e8b6a 100644 --- a/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex +++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex @@ -18,6 +18,16 @@ % \ctikzset{multipoles/thickness/.initial=2} \ctikzset{multipoles/font/.initial=\pgf@circ@font@tiny} +\ctikzset{multipoles/draw only pins/.initial={all}} +\ctikzset{multipoles/draw only left pins/.initial={all}} +\ctikzset{multipoles/draw only right pins/.initial={all}} +\ctikzset{multipoles/draw only top pins/.initial={all}} +\ctikzset{multipoles/draw only bottom pins/.initial={all}} +\pgfqkeys{/tikz}{draw only pins/.add code={}{\ctikzset{multipoles/draw only pins={#1}}}} +\pgfqkeys{/tikz}{draw only left pins/.add code={}{\ctikzset{multipoles/draw only left pins={#1}}}} +\pgfqkeys{/tikz}{draw only right pins/.add code={}{\ctikzset{multipoles/draw only right pins={#1}}}} +\pgfqkeys{/tikz}{draw only top pins/.add code={}{\ctikzset{multipoles/draw only top pins={#1}}}} +\pgfqkeys{/tikz}{draw only bottom pins/.add code={}{\ctikzset{multipoles/draw only bottom pins={#1}}}} % DIP (dual in line package) chips \ctikzset{multipoles/dipchip/width/.initial=1.2} \ctikzset{multipoles/dipchip/num pins/.initial=8} @@ -113,9 +123,23 @@ % Thanks also to John Kormylo https://tex.stackexchange.com/a/372996/38080 % a lot of thanks to @marmot for the un-rotation hint % https://tex.stackexchange.com/a/473571/38080 +% modifications for 'draw only pins' by Jonathan P. Spratte % DIP (dual in line package) chips +% helper macro to set the anchors inside a loop (to expand the current count) +\pgfutil@protected\def\pgf@circ@make@dippin@anchor#1% + {% + \expandafter\gdef\csname pgf@anchor@dipchip@pin #1\endcsname + {% + \pgf@circ@if@num@in@list\pgf@circ@pins@list{#1} + {\pgf@circ@dippinanchor{#1}{1}} + {\pgf@circ@dippinanchor{#1}{0}}% + }% + \expandafter\gdef\csname pgf@anchor@dipchip@bpin #1\endcsname + {\pgf@circ@dippinanchor{#1}{0}}% + } + \pgfdeclareshape{dipchip}{ \savedmacro{\ctikzclass}{\edef\ctikzclass{chips}} \saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} @@ -123,6 +147,14 @@ \pgf@circ@count@a=\ctikzvalof{multipoles/dipchip/num pins}% \def\numpins{\the\pgf@circ@count@a} } + \savedmacro\pgf@circ@pins@list + {% + \pgfkeysgetvalue + {\circuitikzbasekey/multipoles/draw only pins}\pgf@circ@temp + \expandafter\pgf@circ@set@list + \expandafter\pgf@circ@pins@list + \expandafter{\pgf@circ@temp}% + }% \savedanchor\centerpoint{% \pgf@x=-.5\wd\pgfnodeparttextbox% \pgf@y=-.5\ht\pgfnodeparttextbox% @@ -259,62 +291,85 @@ \repeatpgfmathloop \fi \endpgfscope + % draw external pins or pads \ifdim\pgf@circ@res@other>0pt + \ifpgfcirc@draw@input@leads \pgfscope \pgfsetlinewidth{\ctikzvalof{multipoles/external pins thickness}\pgflinewidth} \pgf@circ@count@a=\numpins\relax \divide\pgf@circ@count@a by 2 \pgf@circ@count@b=\pgf@circ@count@a + \edef\padfrac{\ctikzvalof{multipoles/external pad fraction}} + \ifnum\padfrac>0 + \pgf@circ@res@temp=\pgf@circ@res@step\divide\pgf@circ@res@temp by \padfrac + \fi \pgfmathloop% \ifnum\pgf@circ@count@a>0 - \edef\padfrac{\ctikzvalof{multipoles/external pad fraction}} - \ifnum\padfrac>0 - \pgf@circ@res@temp=\pgf@circ@res@step\divide\pgf@circ@res@temp by \padfrac - % left side pads - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - % right side pads - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \else - % left side pins - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - % right side pins - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \fi + % left side + \pgf@circ@if@num@in@list\pgf@circ@pins@list\pgf@circ@count@a + {% + \ifnum\padfrac>0 + % pads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \else + % pins + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \fi + } + {}% + % right side + \pgf@circ@if@num@in@list\pgf@circ@pins@list{\numpins+1-\pgf@circ@count@a} + {% + \ifnum\padfrac>0 + % pads + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \else + % pins + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \fi + } + {}% \advance\pgf@circ@count@a by -1\relax% \repeatpgfmathloop \pgfusepath{stroke} \endpgfscope \fi + \fi }% - % \pgf@sh@s@<name of the shape here> contains all the code for the shape - % and is executed just before a node is drawn. \pgfutil@g@addto@macro\pgf@sh@s@dipchip{% - % Start with the maximum pin number and go backwards. - \pgf@circ@count@a=\numpins\relax - \pgfmathloop% + \pgf@circ@count@a=\numpins + \pgfmathloop \ifnum\pgf@circ@count@a>0 - % we will create two anchors per pin: the "normal one" like `pin 1` for the - % electrical contact, and the "border one" like `bpin 1` for labels. - % they will coincide if `external pins width` is set to 0. - \expandafter\xdef\csname pgf@anchor@dipchip@pin\space\the\pgf@circ@count@a\endcsname{% - \noexpand\pgf@circ@dippinanchor{\the\pgf@circ@count@a}{1}% - } - \expandafter\xdef\csname pgf@anchor@dipchip@bpin\space\the\pgf@circ@count@a\endcsname{% - \noexpand\pgf@circ@dippinanchor{\the\pgf@circ@count@a}{0}% - } - \advance\pgf@circ@count@a by -1\relax% - \repeatpgfmathloop% - }% + % we will create two anchors per pin: the "normal one" like `pin 1` for the + % electrical contact, and the "border one" like `bpin 1` for labels. + % they will coincide if `external pins width` is set to 0. + % see the helper function above the start of the shape definition (by Jonathan P. Spratte) + \expandafter\pgf@circ@make@dippin@anchor\expandafter{\the\pgf@circ@count@a}% + \advance\pgf@circ@count@a by -1\relax + \repeatpgfmathloop + }% } % QFP (quad flat package) chips +% helper macro to set the anchors inside a loop (to expand the current count) +\pgfutil@protected\def\pgf@circ@make@qfppin@anchor#1% + {% + \expandafter\gdef\csname pgf@anchor@qfpchip@pin #1\endcsname + {% + \pgf@circ@if@num@in@list\pgf@circ@pins@list{#1} + {\pgf@circ@qfppinanchor{#1}{1}} + {\pgf@circ@qfppinanchor{#1}{0}}% + }% + \expandafter\gdef\csname pgf@anchor@qfpchip@bpin #1\endcsname + {\pgf@circ@qfppinanchor{#1}{0}}% + } \pgfdeclareshape{qfpchip}{ \savedmacro{\ctikzclass}{\edef\ctikzclass{chips}} @@ -323,6 +378,14 @@ \pgf@circ@count@a=\ctikzvalof{multipoles/qfpchip/num pins}% \def\numpins{\the\pgf@circ@count@a} } + \savedmacro\pgf@circ@pins@list + {% some magic here, thanks to Jonathan P. Spratte + \pgfkeysgetvalue + {\circuitikzbasekey/multipoles/draw only pins}\pgf@circ@temp + \expandafter\pgf@circ@set@list + \expandafter\pgf@circ@pins@list + \expandafter{\pgf@circ@temp}% + }% \savedanchor\centerpoint{% \pgf@x=-.5\wd\pgfnodeparttextbox% \pgf@y=-.5\ht\pgfnodeparttextbox% @@ -507,6 +570,7 @@ \fi \endpgfscope \ifdim\pgf@circ@res@other>0pt + \ifpgfcirc@draw@input@leads \pgfscope \pgfsetlinewidth{\ctikzvalof{multipoles/external pins thickness}\pgflinewidth} \pgf@circ@count@a=\numpins% @@ -517,44 +581,69 @@ \ifnum\padfrac>0 \pgf@circ@res@temp=\pgf@circ@res@step\divide\pgf@circ@res@temp by \padfrac % left side pads - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgf@circ@if@num@in@list\pgf@circ@pins@list\pgf@circ@count@a + {% + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + }{}% % bottom side pads - \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}} - \pgfpathlineto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down-\pgf@circ@res@other}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down-\pgf@circ@res@other}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}} + \pgf@circ@if@num@in@list\pgf@circ@pins@list{\numpins/4+\pgf@circ@count@a} + {% + \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}} + \pgfpathlineto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down-\pgf@circ@res@other}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down-\pgf@circ@res@other}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}} + }{}% % right side pads - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgf@circ@if@num@in@list\pgf@circ@pins@list{3*\numpins/4+1-\pgf@circ@count@a} + {% + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + }{}% % top side pads - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up+\pgf@circ@res@other}} - \pgfpathlineto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up+\pgf@circ@res@other}} - \pgfpathlineto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}} + \pgf@circ@if@num@in@list\pgf@circ@pins@list{3*\numpins/4+\pgf@circ@count@a} + {% + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up+\pgf@circ@res@other}} + \pgfpathlineto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up+\pgf@circ@res@other}} + \pgfpathlineto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}} + }{}% \else % left side pins - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgf@circ@if@num@in@list\pgf@circ@pins@list\pgf@circ@count@a + {% + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + }{}% % bottom side pins - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down-\pgf@circ@res@other}} + \pgf@circ@if@num@in@list\pgf@circ@pins@list{\numpins/4+\pgf@circ@count@a} + {% + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down-\pgf@circ@res@other}} + }{}% % right side pins - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgf@circ@if@num@in@list\pgf@circ@pins@list{3*\numpins/4+1-\pgf@circ@count@a} + {% + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} + }{}% % top side pins - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up+\pgf@circ@res@other}} + \pgf@circ@if@num@in@list\pgf@circ@pins@list{3*\numpins/4+\pgf@circ@count@a} + {% + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up+\pgf@circ@res@other}} + }{}% \fi \advance\pgf@circ@count@a-1\relax% \repeatpgfmathloop \pgfusepath{stroke} \endpgfscope \fi + \fi }% % \pgf@sh@s@<name of the shape here> contains all the code for the shape % and is executed just before a node is drawn. @@ -563,14 +652,9 @@ \pgf@circ@count@a=\numpins% \pgfmathloop% \ifnum\pgf@circ@count@a>0 - \expandafter\xdef\csname pgf@anchor@qfpchip@pin\space\the\pgf@circ@count@a\endcsname{% - \noexpand\pgf@circ@qfppinanchor{\the\pgf@circ@count@a}{1}% - } - \expandafter\xdef\csname pgf@anchor@qfpchip@bpin\space\the\pgf@circ@count@a\endcsname{% - \noexpand\pgf@circ@qfppinanchor{\the\pgf@circ@count@a}{0}% - } + \expandafter\pgf@circ@make@qfppin@anchor\expandafter{\the\pgf@circ@count@a}% \advance\pgf@circ@count@a-1\relax% - \repeatpgfmathloop% + \repeatpgfmathloop% }% } @@ -1520,21 +1604,103 @@ \tikzset{ALU/.style={muxdemux, muxdemux def={Lh=5, NL=2, Rh=2, NR=1, NB=2, NT=1, w=2, inset w=1, inset Lh=2, inset Rh=0, square pins=1}}} + %generic mux-demux shape + +% helper macros to set the anchors inside a loop (to expand the current count) +% left +\pgfutil@protected\def\pgf@circ@make@muxdemux@L@anchor#1% + {% + \expandafter\gdef\csname pgf@anchor@muxdemux@lpin #1\endcsname + {% + \pgf@circ@if@num@in@list\pgf@circ@Lpins@list{#1} + {\pgf@circ@muxdemux@L@anchor{#1}{1}} + {\pgf@circ@muxdemux@L@anchor{#1}{0}}% + }% + \expandafter\gdef\csname pgf@anchor@muxdemux@blpin #1\endcsname + {\pgf@circ@muxdemux@L@anchor{#1}{0}}% + } +% right +\pgfutil@protected\def\pgf@circ@make@muxdemux@R@anchor#1% + {% + \expandafter\gdef\csname pgf@anchor@muxdemux@rpin #1\endcsname + {% + \pgf@circ@if@num@in@list\pgf@circ@Rpins@list{#1} + {\pgf@circ@muxdemux@R@anchor{#1}{1}} + {\pgf@circ@muxdemux@R@anchor{#1}{0}}% + }% + \expandafter\gdef\csname pgf@anchor@muxdemux@brpin #1\endcsname + {\pgf@circ@muxdemux@R@anchor{#1}{0}}% + } +% bottom +\pgfutil@protected\def\pgf@circ@make@muxdemux@B@anchor#1% + {% + \expandafter\gdef\csname pgf@anchor@muxdemux@bpin #1\endcsname + {% + \pgf@circ@if@num@in@list\pgf@circ@Bpins@list{#1} + {\pgf@circ@muxdemux@B@anchor{#1}{1}} + {\pgf@circ@muxdemux@B@anchor{#1}{0}}% + }% + \expandafter\gdef\csname pgf@anchor@muxdemux@bbpin #1\endcsname + {\pgf@circ@muxdemux@B@anchor{#1}{0}}% + } +% top +\pgfutil@protected\def\pgf@circ@make@muxdemux@T@anchor#1% + {% + \expandafter\gdef\csname pgf@anchor@muxdemux@tpin #1\endcsname + {% + \pgf@circ@if@num@in@list\pgf@circ@Tpins@list{#1} + {\pgf@circ@muxdemux@T@anchor{#1}{1}} + {\pgf@circ@muxdemux@T@anchor{#1}{0}}% + }% + \expandafter\gdef\csname pgf@anchor@muxdemux@btpin #1\endcsname + {\pgf@circ@muxdemux@T@anchor{#1}{0}}% + } + + \pgfdeclareshape{muxdemux}{ \savedmacro{\ctikzclass}{\edef\ctikzclass{muxdemuxes}} \saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} \savedmacro{\thisshape}{\def\thisshape{\tikz@fig@name}} % pins on the four sides - % \savedmacro\NL{% - % \pgf@circ@count@a=\ctikzvalof{multipoles/muxdemux/NL}% - % \def\NL{\the\pgf@circ@count@a} - % } \savedmacro\NL{\edef\NL{\ctikzvalof{multipoles/muxdemux/NL}}} \savedmacro\NR{\edef\NR{\ctikzvalof{multipoles/muxdemux/NR}}} \savedmacro\NT{\edef\NT{\ctikzvalof{multipoles/muxdemux/NT}}} \savedmacro\NB{\edef\NB{\ctikzvalof{multipoles/muxdemux/NB}}} \savedmacro\squarepins{\edef\squarepins{\ctikzvalof{multipoles/muxdemux/square pins}}} + % pin lists + \savedmacro\pgf@circ@Lpins@list + {% + \pgfkeysgetvalue + {\circuitikzbasekey/multipoles/draw only left pins}\pgf@circ@temp + \expandafter\pgf@circ@set@list + \expandafter\pgf@circ@Lpins@list + \expandafter{\pgf@circ@temp}% + }% + \savedmacro\pgf@circ@Rpins@list + {% + \pgfkeysgetvalue + {\circuitikzbasekey/multipoles/draw only right pins}\pgf@circ@temp + \expandafter\pgf@circ@set@list + \expandafter\pgf@circ@Rpins@list + \expandafter{\pgf@circ@temp}% + }% + \savedmacro\pgf@circ@Tpins@list + {% + \pgfkeysgetvalue + {\circuitikzbasekey/multipoles/draw only top pins}\pgf@circ@temp + \expandafter\pgf@circ@set@list + \expandafter\pgf@circ@Tpins@list + \expandafter{\pgf@circ@temp}% + }% + \savedmacro\pgf@circ@Bpins@list + {% + \pgfkeysgetvalue + {\circuitikzbasekey/multipoles/draw only bottom pins}\pgf@circ@temp + \expandafter\pgf@circ@set@list + \expandafter\pgf@circ@Bpins@list + \expandafter{\pgf@circ@temp}% + }% % topleft and topright sizes \savedanchor{\topleft}{% \pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} @@ -1681,7 +1847,8 @@ \fi \pgfmathloop% \ifnum\pgf@circ@count@a>0 - %%%%% + %%%%% check if we want to draw this pin + \pgf@circ@if@num@in@list\pgf@circ@Lpins@list\pgf@circ@count@a{% \ifdim\pgf@circ@res@down>0pt % check if we have an inset \ifnum\pgf@circ@count@a>\pgf@circ@count@b\relax % for lower pins we have to shift them down @@ -1716,6 +1883,7 @@ \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\extshift}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step}} \fi %%%%% + }{}% close the pin list check \advance\pgf@circ@count@a by -1\relax% \repeatpgfmathloop\fi% % right pins @@ -1724,8 +1892,11 @@ \topright\pgf@circ@res@right=\pgf@x \pgf@circ@res@up=\pgf@y \pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@circ@res@up/\NR} \ifnum\pgf@circ@count@a>0 + %%%%% check if we want to draw this pin + \pgf@circ@if@num@in@list\pgf@circ@Rpins@list\pgf@circ@count@a{% \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step}} \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\extshift}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step}} + }{}% \advance\pgf@circ@count@a by -1\relax% \repeatpgfmathloop\fi% % bottom pins @@ -1736,6 +1907,8 @@ \pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@circ@res@right/\NB} \pgfmathsetlength{\pgf@circ@res@other}{(\pgf@circ@res@down-\pgf@circ@res@up)/(\pgf@circ@res@right-\pgf@circ@res@left)*\pgf@circ@res@step} \ifnum\pgf@circ@count@a>0 + %%%%% check if we want to draw this pin + \pgf@circ@if@num@in@list\pgf@circ@Bpins@list\pgf@circ@count@a{% \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left+(\pgf@circ@count@a-0.5)*\pgf@circ@res@step} {-\pgf@circ@res@down+(\NB-\pgf@circ@count@a+0.5)*\pgf@circ@res@other}} \ifnum\squarepins>0 @@ -1745,6 +1918,7 @@ \pgfpathlineto{\pgfpoint{\pgf@circ@res@left+(\pgf@circ@count@a-0.5)*\pgf@circ@res@step} {-\pgf@circ@res@down+(\NB-\pgf@circ@count@a+0.5)*\pgf@circ@res@other-\extshift}} \fi + }{}% \advance\pgf@circ@count@a by -1\relax% \repeatpgfmathloop\fi% % top pins @@ -1755,6 +1929,8 @@ \pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@circ@res@right/\NT} \pgfmathsetlength{\pgf@circ@res@other}{(\pgf@circ@res@down-\pgf@circ@res@up)/(\pgf@circ@res@right-\pgf@circ@res@left)*\pgf@circ@res@step} \ifnum\pgf@circ@count@a>0 + %%%%% check if we want to draw this pin + \pgf@circ@if@num@in@list\pgf@circ@Tpins@list\pgf@circ@count@a{% \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left+(\pgf@circ@count@a-0.5)*\pgf@circ@res@step} {\pgf@circ@res@down-(\NT-\pgf@circ@count@a+0.5)*\pgf@circ@res@other}} \ifnum\squarepins>0 @@ -1764,6 +1940,7 @@ \pgfpathlineto{\pgfpoint{\pgf@circ@res@left+(\pgf@circ@count@a-0.5)*\pgf@circ@res@step} {\pgf@circ@res@down-(\NT-\pgf@circ@count@a+0.5)*\pgf@circ@res@other+\extshift}} \fi + }{}% \advance\pgf@circ@count@a by -1\relax% \repeatpgfmathloop\fi% % end drawing pins; stroke them @@ -1781,12 +1958,7 @@ % we will create two anchors per pin: the "normal one" like `lpin 1` for the % external leads, and the "border one" like `blpin 1` for internal ones. % they will coincide if `external pins width` is set to 0. - \expandafter\xdef\csname pgf@anchor@muxdemux@lpin\space\the\pgf@circ@count@a\endcsname{% - \noexpand\pgf@circ@muxdemux@L@anchor{\the\pgf@circ@count@a}{1}% - } - \expandafter\xdef\csname pgf@anchor@muxdemux@blpin\space\the\pgf@circ@count@a\endcsname{% - \noexpand\pgf@circ@muxdemux@L@anchor{\the\pgf@circ@count@a}{0}% - } + \expandafter\pgf@circ@make@muxdemux@L@anchor\expandafter{\the\pgf@circ@count@a}% \advance\pgf@circ@count@a by -1\relax% \repeatpgfmathloop% % right anchors @@ -1796,12 +1968,7 @@ % we will create two anchors per pin: the "normal one" like `rpin 1` for the % external leads, and the "border one" like `brpin 1` for internal ones. % they will coincide if `external pins width` is set to 0. - \expandafter\xdef\csname pgf@anchor@muxdemux@rpin\space\the\pgf@circ@count@a\endcsname{% - \noexpand\pgf@circ@muxdemux@R@anchor{\the\pgf@circ@count@a}{1}% - } - \expandafter\xdef\csname pgf@anchor@muxdemux@brpin\space\the\pgf@circ@count@a\endcsname{% - \noexpand\pgf@circ@muxdemux@R@anchor{\the\pgf@circ@count@a}{0}% - } + \expandafter\pgf@circ@make@muxdemux@R@anchor\expandafter{\the\pgf@circ@count@a}% \advance\pgf@circ@count@a by -1\relax% \repeatpgfmathloop% % bottom anchors @@ -1811,12 +1978,7 @@ % we will create two anchors per pin: the "normal one" like `bpin 1` for the % external leads, and the "border one" like `bbpin 1` for internal ones. % they will coincide if `external pins width` is set to 0. - \expandafter\xdef\csname pgf@anchor@muxdemux@bpin\space\the\pgf@circ@count@a\endcsname{% - \noexpand\pgf@circ@muxdemux@B@anchor{\the\pgf@circ@count@a}{1}% - } - \expandafter\xdef\csname pgf@anchor@muxdemux@bbpin\space\the\pgf@circ@count@a\endcsname{% - \noexpand\pgf@circ@muxdemux@B@anchor{\the\pgf@circ@count@a}{0}% - } + \expandafter\pgf@circ@make@muxdemux@B@anchor\expandafter{\the\pgf@circ@count@a}% \advance\pgf@circ@count@a by -1\relax% \repeatpgfmathloop% % top anchors @@ -1826,12 +1988,7 @@ % we will create two anchors per pin: the "normal one" like `tpin 1` for the % external leads, and the "border one" like `btpin 1` for internal ones. % they will coincide if `external pins width` is set to 0. - \expandafter\xdef\csname pgf@anchor@muxdemux@tpin\space\the\pgf@circ@count@a\endcsname{% - \noexpand\pgf@circ@muxdemux@T@anchor{\the\pgf@circ@count@a}{1}% - } - \expandafter\xdef\csname pgf@anchor@muxdemux@btpin\space\the\pgf@circ@count@a\endcsname{% - \noexpand\pgf@circ@muxdemux@T@anchor{\the\pgf@circ@count@a}{0}% - } + \expandafter\pgf@circ@make@muxdemux@T@anchor\expandafter{\the\pgf@circ@count@a}% \advance\pgf@circ@count@a by -1\relax% \repeatpgfmathloop% }% diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcircutils.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcircutils.tex index ac87e083040..86732077b0b 100644 --- a/Master/texmf-dist/tex/generic/circuitikz/pgfcircutils.tex +++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcircutils.tex @@ -120,4 +120,261 @@ } \long\def\ctikzsubcircuitactivate#1{\csname #1@setanchors\endcsname} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Basic utility macros +%% +%% Functions provided here are: +%% \pgf@circ@ifempty{<argument>}{<true>}{<false>} +%% Tests whether <argument> is completely empty. +%% \pgf@circ@ifblank{<argument>}{<true>}{<false>} +%% Tests whether <argument> is either empty or only contains spaces. +%% \pgf@circ@trimspaces@do{<argument>}{<next>} +%% Trims at most one space from either end of <argument> and forwards the +%% result to <next> as <next>{<trimmed argument>} + +% these two are pretty standard code +\long\def\pgf@circ@ifempty#1% + {% + \if\relax\detokenize{#1}\relax + \expandafter\pgfutil@firstoftwo + \else + \expandafter\pgfutil@secondoftwo + \fi + } +\long\def\pgf@circ@ifblank#1% + {% + \if\relax\detokenize\expandafter{\pgfutil@gobble#1.}\relax + \expandafter\pgfutil@firstoftwo + \else + \expandafter\pgfutil@secondoftwo + \fi + } + +% \pgfutil@trimspaces needs two expansions. The first expansion we'll do during +% the definition. +\def\pgf@circ@trimspaces@do#1% + {% + \def\pgf@circ@trimspaces@do##1% + {\expandafter\pgf@circ@trimspaces@do@\expandafter{#1}}% + } +\expandafter\pgf@circ@trimspaces@do\expandafter{\pgfutil@trimspaces{#1}} +\def\pgf@circ@trimspaces@do@#1#2{#2{#1}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% list handling +%% +%% Contribution by Jonathan P. Spratte (blame him!) +%% +%% The list implementation here has a few limitations. Those are: +%% 1. not long, so no \par in the lists (but many used functions in pgfutil +%% aren't long as well) +%% 2. list elements can't contain a Q with category code 3 (but the used +%% function \pgfutil@trimspaces doesn't support them as well, and this +%% should be a very rare token anyway) +%% 3. list elements can't contain the token \pgf@circ@set@list as that is used +%% as the end marker +%% 4. currently these lists are meant for numeric data (hence only +%% \pgf@circ@if@num@in@list is provided as a test), as a result there is +%% another limitation for the data here. If the list element contains no +%% hyphen '-', the element will be stored without further processing +%% 'as-is' (well, after trimming spaces). If there is a hyphen we assume +%% well-behaved input data and will interpret this as a num-range without +%% further tests. +%% +%% Functions provided here are: +%% \pgf@circ@set@list<macro>{<csv-list>} +%% Parses the <csv-list> and stores the result inside <macro> (local +%% assignment). If a num-range given as <start - stop> (with or without +%% spaces) is found it will be expanded to <start>,<start+1>,...,<stop>. +%% \pgf@circ@if@num@in@list<macro>{<value>}{<true>}{<false>} +%% Checks whether <value> (numeric value, evaluated once with \numexpr) is +%% found inside the list stored in <macro>. There are two special cases: If +%% <macro> is undefined <false> is executed. If the list contains only one +%% element and that is `all' <true> is executed. + +% set the catcode of our marker +\chardef\pgf@circ@temp=\the\catcode`\Q +\catcode`\Q=3 + +% lists will have the structure +% <marker><element 1><marker>...<element n><marker> +% As marker we use a Q with category 3. Under the assumption that no list +% element does ever contain that token we can set the elements without braces, +% allowing us to use \pgfutil@in@ to search for elements (see above). The other +% token that isn't allowed to show up in the list is \pgf@circ@set@list, that we +% use as another marker during parsing. +% The other big restriction in this implementation is that lists can't contain a +% \par (but \pgfutil@in@ doesn't support that anyway so there is not much +% sense in supporting it here) +\pgfutil@protected\def\pgf@circ@set@list#1#2% + {% + % clear the error flag + \let\pgf@circ@error@marker\pgf@circ@undefined + % set the list + \edef#1% + {Q\pgf@circ@set@list@sanitize#2,\pgf@circ@set@list,\pgf@circ@set@list}% + % there was an error, throw the error message, recovery was already done by + % ignoring the offending elements. + \ifx\pgf@circ@error@marker\relax + \begingroup + \newlinechar`\^^J + \pgfutil@packageerror{circuitikz} + {% + Unallowed marker found in list^^J% + \pgfutil@unexpanded{#2}.^^J% + Offending elements were ignored.% + } + {Lists can't contain a Q with category code 3}% + \endgroup + \fi + } +% just a utility for the <marker> test +\def\pgf@circ@set@list@gobbletomarker#1Q{} +% quick way to check whether list parsing is done by gobbling up to a marker, in +% this case the marker is \pgf@circ@set@list +\def\pgf@circ@set@list@sanitize@checkend#1\pgf@circ@set@list{} +% will only be called after the last element is handled, will gobble the +% remainder of the current sanitizing step +\def\pgf@circ@set@list@sanitize@end\pgf@circ@set@list#1\pgf@circ@set@list{} +% grabs the next list element, checks whether we're done, and if not sanitizes +% it (meaning stripping spaces from either end and placing the <marker>). +\def\pgf@circ@set@list@sanitize#1,% + {% + \pgf@circ@set@list@sanitize@checkend + #1\pgf@circ@set@list@sanitize@end\pgf@circ@set@list + \pgf@circ@set@list@sanitize@a{#1}% + } +% testing whether a list element contains the used <marker> expandably, if it +% does set the flag, else continue sanitizing. +\def\pgf@circ@set@list@sanitize@a#1% + {% + \expandafter\pgf@circ@ifempty\expandafter + % if this is empty no marker was found + {\pgf@circ@set@list@gobbletomarker#1Q} + {% + \pgf@circ@ifblank{#1} + {}% ignore blank entries + {\pgf@circ@trimspaces@do{#1}\pgf@circ@set@list@sanitize@b}% + } + {% + % panic, there was a marker found in a list element. We'll recover by + % ignoring the current element after setting a flag. When we do + % \csname ...\endcsname on an undefined macro name TeX will let that + % macro to relax and we exploit this to expandable set a flag and + % gobbling the result. + \expandafter\pgfutil@gobble\csname pgf@circ@error@marker\endcsname + }% + % get the next element + \pgf@circ@set@list@sanitize + } +% we'll protect any element from further expanding using \unexpanded and place +% the marker after the element, and ignore empty/blank elements +\def\pgf@circ@set@list@sanitize@b#1% + {% + \expandafter\pgf@circ@ifempty\expandafter + % if this is empty no hyphen is found + {\pgf@circ@gobbletohyphen#1-} + {\pgfutil@unexpanded{#1}Q} + {\pgf@circ@set@list@parse@range{#1}}% + } +\def\pgf@circ@gobbletohyphen#1-{} +\def\pgf@circ@set@list@parse@range#1{\pgf@circ@set@list@parse@range@a#1Q} +\def\pgf@circ@set@list@parse@range@a#1-#2Q% + {% + \expandafter\pgf@circ@set@list@parse@range@b + \the\numexpr#1\expandafter Q\the\numexpr#2Q% + } +\def\pgf@circ@set@list@parse@range@b#1Q#2Q% + {% + \ifnum#1<#2 + % expand to the range from #1 to #2 (inclusive) + \pgf@circ@set@list@range{#1}{#2}% + \else + \ifnum#2<#1 + % if #2 is smaller than #1 just swap the order + \pgf@circ@set@list@range{#2}{#1}% + \else + % last case, they are equal, so just put the result here + #1Q% + \fi + \fi + } +\def\pgf@circ@set@list@parse@range@norange#1Q#2{\pgfutil@unexpanded{#2}Q} +\def\pgf@circ@set@list@range#1#2% + {% + #1Q% + \ifnum#1<#2 + \expandafter\pgfutil@secondoftwo + \fi + \pgfutil@gobble + {\expandafter\pgf@circ@set@list@range\expandafter{\the\numexpr#1+1}{#2}}% + } + +% flag for special value +\def\pgf@circ@all@flag{QallQ} +\pgfutil@protected\def\pgf@circ@if@num@in@list#1#2% + {% + % test whether the list macro is defined, if it isn't result is false + \pgfutil@ifx\pgf@circ@undefined#1% + {\pgfutil@secondoftwo} + {% + % test whether the list macro is just the special value 'all', if so + % true, else search (and start that by evaluating a numexpr) + \pgfutil@ifx\pgf@circ@all@flag#1% + {\pgfutil@firstoftwo} + {% + \expandafter\pgf@circ@if@num@in@list@a\expandafter + {\the\numexpr#2}% + #1% + }% + }% + } +% next step is expanding the list macro +\pgfutil@protected\def\pgf@circ@if@num@in@list@a#1#2% + {\expandafter\pgf@circ@if@num@in@list@b\expandafter{#2}{#1}} +% now use \pgfutil@in@ to check whether there is the searched list element +\pgfutil@protected\def\pgf@circ@if@num@in@list@b#1#2% + {% + \begingroup + % put the <marker> around the number to make sure only full matches are + % found. \pgfutil@in@ will set \ifpgfutil@in@ to true if it finds a match + \pgfutil@in@{Q#2Q}{#1}% + \expandafter + \endgroup + \ifpgfutil@in@ + \expandafter\pgfutil@firstoftwo + \else + \expandafter\pgfutil@secondoftwo + \fi + } + +% reset the catcode of Q +\catcode`\Q=\pgf@circ@temp + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% temporary fix for old TikZ versions (remove me) +%% +%% All blame to Romano Giannetti for this code! +%% +%% This tries to be smart and provide \pgfutil@unexpanded and \pgfutil@ifx if +%% PGF doesn't provide them. + +\ifx\pgfutil@unexpanded\pgf@circ@undefined + \ifpgfutil@format@is@context + \let\pgfutil@unexpanded\normalunexpanded + \else + \let\pgfutil@unexpanded\unexpanded + \fi +\fi + +\ifx\pgfutil@ifx\pgf@circ@undefined + \long\def\pgfutil@ifx#1#2{% + \ifx#1#2% + \expandafter\pgfutil@firstoftwo + \else + \expandafter\pgfutil@secondoftwo + \fi} +\fi + \endinput diff --git a/Master/texmf-dist/tex/latex/circuitikz/circuitikz.sty b/Master/texmf-dist/tex/latex/circuitikz/circuitikz.sty index c87b1251d58..110df9ce827 100644 --- a/Master/texmf-dist/tex/latex/circuitikz/circuitikz.sty +++ b/Master/texmf-dist/tex/latex/circuitikz/circuitikz.sty @@ -12,8 +12,8 @@ \NeedsTeXFormat{LaTeX2e} -\def\pgfcircversion{1.3.7} -\def\pgfcircversiondate{2021/06/01} +\def\pgfcircversion{1.3.8} +\def\pgfcircversiondate{2021/06/15} \ProvidesPackage{circuitikz}% [\pgfcircversiondate{} The CircuiTikz circuit drawing package version \pgfcircversion] |