summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/circuitikz/pgfcircvoltage.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-06-05 23:20:06 +0000
committerKarl Berry <karl@freefriends.org>2017-06-05 23:20:06 +0000
commitb5a93c0fae61203d8391db893157a51f9234e550 (patch)
treebc20e263af8341cee6c75b59399316da42107721 /Master/texmf-dist/tex/generic/circuitikz/pgfcircvoltage.tex
parentcfada733d6cd9f6fc41842c30c0047105c70ae63 (diff)
circuitikz (28may17)
git-svn-id: svn://tug.org/texlive/trunk@44488 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/circuitikz/pgfcircvoltage.tex')
-rw-r--r--Master/texmf-dist/tex/generic/circuitikz/pgfcircvoltage.tex137
1 files changed, 66 insertions, 71 deletions
diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcircvoltage.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcircvoltage.tex
index de8305354f2..143f697ce04 100644
--- a/Master/texmf-dist/tex/generic/circuitikz/pgfcircvoltage.tex
+++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcircvoltage.tex
@@ -36,9 +36,13 @@
v = #1,
\circuitikzbasekey/bipole/voltage/direction = backward,
\circuitikzbasekey/bipole/voltage/position = below
- }
+ }
}
+\ctikzset{v_/.style = {v = #1, \circuitikzbasekey/bipole/voltage/position = below} }
+\ctikzset{v^/.style = {v = #1, \circuitikzbasekey/bipole/voltage/position = above} }
+\ctikzset{v>/.style = {v = #1, \circuitikzbasekey/bipole/voltage/direction = forward} }
+\ctikzset{v</.style = {v = #1, \circuitikzbasekey/bipole/voltage/direction = backward} }
% Default position varies whether the component is a voltage source
% or not
@@ -68,7 +72,7 @@
\ctikzsetvalof{bipole/voltage/label/unit}{}
\ifpgf@circ@siunitx
\pgf@circ@handleSI{#1}
- \ifpgf@circ@siunitx@res
+ \ifpgf@circ@siunitx@res
\edef\pgf@temp{\pgf@circ@handleSI@val}
\pgfkeyslet{/tikz/circuitikz/bipole/voltage/label/name}{\pgf@temp}
\edef\pgf@temp{\pgf@circ@handleSI@unit}
@@ -77,26 +81,33 @@
\fi
\else
\fi
- }
+ }
}
-\ctikzset{v_/.style = {v = #1, \circuitikzbasekey/bipole/voltage/position = below} }
-\ctikzset{v^/.style = {v = #1, \circuitikzbasekey/bipole/voltage/position = above} }
-\ctikzset{v>/.style = {v = #1, \circuitikzbasekey/bipole/voltage/direction = forward} }
-\ctikzset{v</.style = {v = #1, \circuitikzbasekey/bipole/voltage/direction = backward} }
+
%% Output routine for generic bipoles
\def\pgf@circ@drawvoltagegeneric{
- \pgfextra{\edef\pgf@temp{/tikz/circuitikz/bipoles/\pgfkeysvalueof{/tikz/circuitikz/bipole/kind}/voltage/straight label distance}
+ \pgfextra{
+ \edef\pgf@temp{/tikz/circuitikz/bipoles/\pgfkeysvalueof{/tikz/circuitikz/bipole/kind}/voltage/straight label distance}
\pgfkeysifdefined{\pgf@temp}
- { \edef\partwidth{\ctikzvalof{bipoles/\pgfkeysvalueof{/tikz/circuitikz/bipole/kind}/voltage/straight label distance}}
- \def\tmpdistfromline{\partwidth\pgf@circ@Rlen}}
{
- \edef\partwidth{0.5*\ctikzvalof{bipoles/\pgfkeysvalueof{/tikz/circuitikz/bipole/kind}/height}}
- \def\tmpdistfromline{(\partwidth\pgf@circ@Rlen+0.2\pgf@circ@Rlen)}
- }
+ \edef\partheight{\ctikzvalof{bipoles/\pgfkeysvalueof{/tikz/circuitikz/bipole/kind}/voltage/straight label distance}}
+ \edef\tmpdistfromline{(\partheight\pgf@circ@Rlen)}
+ }
+ {
+ \pgfkeysifdefined{/tikz/circuitikz/bipoles/voltage/straight label distance}
+ {
+ \edef\partheight{\ctikzvalof{bipoles/voltage/straight label distance}}
+ \edef\tmpdistfromline{(\partheight\pgf@circ@Rlen)}
+ }
+ {%calculate default value from part height
+ \edef\partheight{0.5*\ctikzvalof{bipoles/\pgfkeysvalueof{/tikz/circuitikz/bipole/kind}/height}}
+ \edef\tmpdistfromline{(\partheight\pgf@circ@Rlen+0.2\pgf@circ@Rlen)}
+ }
+ }
\ifnum \ctikzvalof{mirror value}=-1
\ifpgf@circuit@bipole@inverted
\ifpgf@circuit@bipole@voltage@straight
@@ -126,13 +137,11 @@
\fi
\fi
\fi
-
\ifpgf@circuit@bipole@voltage@below
\def\pgf@circ@voltage@angle{90}
\else
- \def\pgf@circ@voltage@angle{-90}
- \fi
-
+ \def\pgf@circ@voltage@angle{-90}
+ \fi
\edef\pgf@temp{/tikz/circuitikz/bipoles/\pgfkeysvalueof{/tikz/circuitikz/bipole/kind}/voltage/distance from node}
\pgfkeysifdefined{\pgf@temp}
{ \edef\distacefromnode{\ctikzvalof{bipoles/\pgfkeysvalueof{/tikz/circuitikz/bipole/kind}/voltage/distance from node}} }
@@ -142,19 +151,16 @@
{ \edef\bumpb{\ctikzvalof{bipoles/\pgfkeysvalueof{/tikz/circuitikz/bipole/kind}/voltage/bump b}} }
{ \edef\bumpb{\ctikzvalof{voltage/bump b}} }
}
-
- % %\pgfkeysvalueof{/tikz/circuitikz/bipoles/length}/16 is equal to the length of the currarrow
- coordinate (pgfcirc@midtmp) at ($(\tikztostart) ! \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}/16 ! (anchorstartnode)$) %absolute move, minimum space is length of arrowhead
+ % %\pgf@circ@Rlen/16 is equal to the length of the currarrow
+ coordinate (pgfcirc@midtmp) at ($(\tikztostart) ! \pgf@circ@Rlen/16 ! (anchorstartnode)$) %absolute move, minimum space is length of arrowhead
coordinate (pgfcirc@midtmp) at ($(pgfcirc@midtmp) ! \distacefromnode ! (anchorstartnode)$)
-
- coordinate (pgfcirc@Vfrom) at ($(pgfcirc@midtmp) ! -\distfromline ! \pgf@circ@voltage@angle:(anchorstartnode)$)
- coordinate (pgfcirc@midtmp) at ($(\tikztotarget) ! \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}/16 ! (anchorendnode)$)%absolute move, minimum space is length of arrowhead
+ coordinate (pgfcirc@Vfrom) at ($(pgfcirc@midtmp) ! -\distfromline ! \pgf@circ@voltage@angle:(anchorstartnode)$)
+ coordinate (pgfcirc@midtmp) at ($(\tikztotarget) ! \pgf@circ@Rlen/16 ! (anchorendnode)$)%absolute move, minimum space is length of arrowhead
coordinate (pgfcirc@midtmp) at ($(pgfcirc@midtmp) ! \distacefromnode ! (anchorendnode)$)
coordinate (pgfcirc@Vto) at ($(pgfcirc@midtmp) ! \distfromline ! \pgf@circ@voltage@angle : (anchorendnode)$)
-
\ifpgf@circuit@bipole@voltage@below
coordinate (pgfcirc@Vcont1) at ($(\ctikzvalof{bipole/name}.center) ! \bumpb ! (\ctikzvalof{bipole/name}.-110)$)
coordinate (pgfcirc@Vcont2) at ($(\ctikzvalof{bipole/name}.center) ! \bumpb ! (\ctikzvalof{bipole/name}.-70)$)
@@ -166,45 +172,43 @@
\ifpgf@circuit@europeanvoltage
\ifpgf@circuit@bipole@voltage@straight
\ifpgf@circuit@bipole@voltage@backward
- (pgfcirc@Vto) --(pgfcirc@Vfrom) node[currarrow, sloped, allow upside down, pos=1,anchor=tip] {}
+ (pgfcirc@Vto) --(pgfcirc@Vfrom) node[currarrow, sloped, allow upside down, pos=1,anchor=tip] {}
\else
- (pgfcirc@Vfrom) --(pgfcirc@Vto) node[currarrow, sloped, allow upside down, pos=1,anchor=tip] {}
-
- \fi
+ (pgfcirc@Vfrom) --(pgfcirc@Vto) node[currarrow, sloped, allow upside down, pos=1,anchor=tip] {}
+ \fi
\else
\ifpgf@circuit@bipole@voltage@backward
- (pgfcirc@Vto) .. controls (pgfcirc@Vcont2) and (pgfcirc@Vcont1) ..
- node[currarrow, sloped, allow upside down, pos=1] {}
- (pgfcirc@Vfrom)
+ (pgfcirc@Vto) .. controls (pgfcirc@Vcont2) and (pgfcirc@Vcont1) ..
+ node[currarrow, sloped, allow upside down, pos=1] {}
+ (pgfcirc@Vfrom)
\else
(pgfcirc@Vfrom) .. controls (pgfcirc@Vcont1) and (pgfcirc@Vcont2) ..
node[currarrow, sloped, allow upside down, pos=1] {}
- (pgfcirc@Vto)
- \fi
+ (pgfcirc@Vto)
+ \fi
\fi
\else
\ifpgf@circuit@bipole@voltage@backward
\ifpgf@circ@oldvoltagedirection
- (pgfcirc@Vfrom) node[inner sep=0, anchor=\pgf@circ@bipole@voltage@label@anchor]{\scriptsize$+$}
+ (pgfcirc@Vfrom) node[inner sep=0, anchor=\pgf@circ@bipole@voltage@label@anchor]{\scriptsize$+$}
(pgfcirc@Vto) node[inner sep=0, anchor=\pgf@circ@bipole@voltage@label@anchor]{$-$}
\else
- (pgfcirc@Vfrom) node[inner sep=0, anchor=\pgf@circ@bipole@voltage@label@anchor]{\scriptsize$-$}
+ (pgfcirc@Vfrom) node[inner sep=0, anchor=\pgf@circ@bipole@voltage@label@anchor]{\scriptsize$-$}
(pgfcirc@Vto) node[inner sep=0, anchor=\pgf@circ@bipole@voltage@label@anchor]{$+$}
\fi
\else
\ifpgf@circ@oldvoltagedirection
- (pgfcirc@Vfrom) node[inner sep=0, anchor=\pgf@circ@bipole@voltage@label@anchor]{\scriptsize$-$}
+ (pgfcirc@Vfrom) node[inner sep=0, anchor=\pgf@circ@bipole@voltage@label@anchor]{\scriptsize$-$}
(pgfcirc@Vto) node[inner sep=0, anchor=\pgf@circ@bipole@voltage@label@anchor]{$+$}
\else
- (pgfcirc@Vfrom) node[inner sep=0, anchor=\pgf@circ@bipole@voltage@label@anchor]{\scriptsize$+$}
+ (pgfcirc@Vfrom) node[inner sep=0, anchor=\pgf@circ@bipole@voltage@label@anchor]{\scriptsize$+$}
(pgfcirc@Vto) node[inner sep=0, anchor=\pgf@circ@bipole@voltage@label@anchor]{$-$}
\fi
- \fi
+ \fi
\fi
}
%% Output routine for voltage sources
-
\def\pgf@circ@drawvoltagegenerator{
\ifpgf@circuit@bipole@voltage@below
coordinate (pgfcirc@Vfrom) at ($(\ctikzvalof{bipole/name}.center) ! \ctikzvalof{voltage/bump a} ! (\ctikzvalof{bipole/name}.-120)$)
@@ -213,17 +217,14 @@
coordinate (pgfcirc@Vfrom) at ($ (\ctikzvalof{bipole/name}.center) ! \ctikzvalof{voltage/bump a} ! (\ctikzvalof{bipole/name}.120)$)
coordinate (pgfcirc@Vto) at ($ (\ctikzvalof{bipole/name}.center) ! \ctikzvalof{voltage/bump a} ! (\ctikzvalof{bipole/name}.60)$)
\fi
-
\ifpgf@circuit@europeanvoltage
\ifpgf@circuit@bipole@voltage@backward
(pgfcirc@Vto) -- node[currarrow, sloped, allow upside down, pos=1] {} (pgfcirc@Vfrom)
\else
(pgfcirc@Vfrom) -- node[currarrow, sloped, allow upside down, pos=1] {} (pgfcirc@Vto)
\fi
-
- \else % american voltage
-
- \ifpgf@circuit@bipole@voltageoutsideofsymbol
+ \else% american voltage
+ \ifpgf@circuit@bipole@voltageoutsideofsymbol
% if it is a battery, must put + and -
\ifpgf@circuit@bipole@voltage@backward
(pgfcirc@Vfrom) node {$-$} (pgfcirc@Vto) node {$+$}
@@ -231,26 +232,24 @@
(pgfcirc@Vfrom) node {$+$} (pgfcirc@Vto) node {$-$}
\fi
\fi
-
\fi
}
%% Output routine
-
-\def\pgf@circ@drawvoltage{ % node name
+\def\pgf@circ@drawvoltage{% node name
+%\pgf@circ@direction
\pgfextra{
\edef\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@direction\pgf@nil}
-
\ifnum\pgfcircmathresult >4 \ifnum\pgfcircmathresult <86
\ifpgf@circuit@bipole@voltage@below
- \def\pgf@circ@bipole@voltage@label@anchor{north west}
+ \def\pgf@circ@bipole@voltage@label@anchor{north west}
\else \def\pgf@circ@bipole@voltage@label@anchor{south east}
\fi
\fi\fi
\ifnum\pgfcircmathresult >85 \ifnum\pgfcircmathresult <95
\ifpgf@circuit@bipole@voltage@below
- \def\pgf@circ@bipole@voltage@label@anchor{west}
- \else \def\pgf@circ@bipole@voltage@label@anchor{east}
+ \def\pgf@circ@bipole@voltage@label@anchor{west}
+ \else \def\pgf@circ@bipole@voltage@label@anchor{east}
\fi
\fi\fi
\ifnum\pgfcircmathresult >94 \ifnum\pgfcircmathresult <176
@@ -277,7 +276,7 @@
\else \def\pgf@circ@bipole@voltage@label@anchor{west}
\fi
\fi\fi
- \ifnum\pgfcircmathresult >284 \ifnum\pgfcircmathresult <356
+ \ifnum\pgfcircmathresult >274 \ifnum\pgfcircmathresult <356
\ifpgf@circuit@bipole@voltage@below
\def\pgf@circ@bipole@voltage@label@anchor{north east}
\else\def\pgf@circ@bipole@voltage@label@anchor{south west}
@@ -286,7 +285,7 @@
\ifnum\pgfcircmathresult >-1 \ifnum\pgfcircmathresult <5
\ifpgf@circuit@bipole@voltage@below
\def\pgf@circ@bipole@voltage@label@anchor{north}
- \else\def\pgf@circ@bipole@voltage@label@anchor{south}
+ \else\def\pgf@circ@bipole@voltage@label@anchor{south}
\fi
\fi\fi
\ifnum\pgfcircmathresult >355 \ifnum\pgfcircmathresult <361
@@ -295,7 +294,7 @@
\else\def\pgf@circ@bipole@voltage@label@anchor{south}
\fi
\fi\fi
-
+
\ifnum \ctikzvalof{mirror value}=-1
\ifpgf@circuit@bipole@voltage@below
\pgf@circuit@bipole@voltage@belowfalse
@@ -303,7 +302,7 @@
\pgf@circuit@bipole@voltage@belowtrue
\fi
\fi
-
+
\ifpgf@circuit@bipole@inverted
\ifpgf@circuit@bipole@voltage@below
\pgf@circuit@bipole@voltage@belowfalse
@@ -311,33 +310,32 @@
\pgf@circuit@bipole@voltage@belowtrue
\fi
\fi
-
+
\ifpgf@circuit@bipole@voltage@below
\def\pgf@circ@bipole@voltage@label@where{-90}
\else
\def\pgf@circ@bipole@voltage@label@where{90}
\fi
-
-
- \edef\pgf@temp{/tikz/circuitikz/bipoles/\pgfkeysvalueof{/tikz/circuitikz/bipole/kind}/voltage/european label
- distance}
+
+
+ \edef\pgf@temp{/tikz/circuitikz/bipoles/\pgfkeysvalueof{/tikz/circuitikz/bipole/kind}/voltage/european label distance}
\pgfkeysifdefined{\pgf@temp}
{ \edef\eudist{\ctikzvalof{bipoles/\pgfkeysvalueof{/tikz/circuitikz/bipole/kind}/voltage/european label distance}} }
{ \edef\eudist{\ctikzvalof{voltage/european label distance}} }
-
+
\pgfsetcornersarced{\pgfpointorigin}% do not use rounded corners!
- } %end pgfextra
+ }%end pgfextra
\ifpgf@circuit@bipole@isvoltage
- \pgf@circ@drawvoltagegenerator
+ \pgf@circ@drawvoltagegenerator
\else
- \pgf@circ@drawvoltagegeneric
+ \pgf@circ@drawvoltagegeneric
\fi
-
+
% (\ctikzvalof{bipole/name}.\pgf@circ@bipole@voltage@label@where) %Zeile sinnlos!?
\ifpgf@circuit@bipole@voltage@straight
coordinate (Vlab) at ($(pgfcirc@Vto)!0.5!(pgfcirc@Vfrom) $)
- node [anchor=\pgf@circ@bipole@voltage@label@anchor, inner sep=2pt]
+ node [anchor=\pgf@circ@bipole@voltage@label@anchor, inner sep=2pt]
at (Vlab) { \pgf@circ@finallabels{voltage/label} }
\else
coordinate (Vlab) at ($(\ctikzvalof{bipole/name}.center) !
@@ -347,10 +345,7 @@
\ctikzvalof{voltage/american label distance}
\fi !
(\ctikzvalof{bipole/name}.\pgf@circ@bipole@voltage@label@where)$)
- node [anchor=\pgf@circ@bipole@voltage@label@anchor, inner sep=2pt]
- at (Vlab) { \pgf@circ@finallabels{voltage/label} }
-
+ node [anchor=\pgf@circ@bipole@voltage@label@anchor, inner sep=2pt] at (Vlab) { \pgf@circ@finallabels{voltage/label} }
\fi
- }%end drawvoltages
-
+}%end drawvoltages
\endinput