summaryrefslogtreecommitdiff
path: root/graphics/circuit_macros/doc
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/circuit_macros/doc
Initial commit
Diffstat (limited to 'graphics/circuit_macros/doc')
-rw-r--r--graphics/circuit_macros/doc/AmpTable.m422
-rw-r--r--graphics/circuit_macros/doc/Antennas.m440
-rw-r--r--graphics/circuit_macros/doc/Audio.m494
-rw-r--r--graphics/circuit_macros/doc/Axes.m45
-rw-r--r--graphics/circuit_macros/doc/BigResistor.m420
-rw-r--r--graphics/circuit_macros/doc/Bip.m460
-rw-r--r--graphics/circuit_macros/doc/Buffer.m450
-rw-r--r--graphics/circuit_macros/doc/Capture.JPGbin0 -> 25460 bytes
-rw-r--r--graphics/circuit_macros/doc/CctTable.m490
-rw-r--r--graphics/circuit_macros/doc/Circuit_macros.bib155
-rw-r--r--graphics/circuit_macros/doc/Circuit_macros.pdfbin0 -> 909464 bytes
-rw-r--r--graphics/circuit_macros/doc/Circuit_macros.tex88
-rw-r--r--graphics/circuit_macros/doc/Composite.m458
-rw-r--r--graphics/circuit_macros/doc/ConfigA.m438
-rw-r--r--graphics/circuit_macros/doc/ConfigB.m442
-rw-r--r--graphics/circuit_macros/doc/ConfigC.m443
-rw-r--r--graphics/circuit_macros/doc/Conn.m469
-rw-r--r--graphics/circuit_macros/doc/Corners.m473
-rw-r--r--graphics/circuit_macros/doc/Dac.m469
-rw-r--r--graphics/circuit_macros/doc/Darlington.m436
-rw-r--r--graphics/circuit_macros/doc/Demultiplexer.m444
-rw-r--r--graphics/circuit_macros/doc/Diodes.m448
-rw-r--r--graphics/circuit_macros/doc/Emarrows.m430
-rw-r--r--graphics/circuit_macros/doc/FF.m411
-rw-r--r--graphics/circuit_macros/doc/FlipFlop.m432
-rw-r--r--graphics/circuit_macros/doc/Flowdiag.m433
-rw-r--r--graphics/circuit_macros/doc/Fuses.m432
-rw-r--r--graphics/circuit_macros/doc/Grounds.m439
-rw-r--r--graphics/circuit_macros/doc/Headers.m437
-rw-r--r--graphics/circuit_macros/doc/HybridPi.m454
-rw-r--r--graphics/circuit_macros/doc/Jack.m478
-rw-r--r--graphics/circuit_macros/doc/Logic.m462
-rw-r--r--graphics/circuit_macros/doc/Loop.m410
-rw-r--r--graphics/circuit_macros/doc/Makefile142
-rw-r--r--graphics/circuit_macros/doc/Multiplexer.m443
-rw-r--r--graphics/circuit_macros/doc/NLG.m419
-rw-r--r--graphics/circuit_macros/doc/NPDT.m435
-rw-r--r--graphics/circuit_macros/doc/Nport.m443
-rw-r--r--graphics/circuit_macros/doc/Oblique.m425
-rw-r--r--graphics/circuit_macros/doc/Opamp.m445
-rw-r--r--graphics/circuit_macros/doc/Opto.m429
-rw-r--r--graphics/circuit_macros/doc/ParSeries.m456
-rw-r--r--graphics/circuit_macros/doc/Pconn.m450
-rw-r--r--graphics/circuit_macros/doc/Potentiometers.m427
-rw-r--r--graphics/circuit_macros/doc/Relay.m484
-rw-r--r--graphics/circuit_macros/doc/Series.m424
-rw-r--r--graphics/circuit_macros/doc/ShiftR.m449
-rw-r--r--graphics/circuit_macros/doc/Sinus.m418
-rw-r--r--graphics/circuit_macros/doc/Sources.m456
-rw-r--r--graphics/circuit_macros/doc/Switches.m499
-rw-r--r--graphics/circuit_macros/doc/Taps.m443
-rw-r--r--graphics/circuit_macros/doc/Tgate.m450
-rw-r--r--graphics/circuit_macros/doc/Thermal.m48
-rw-r--r--graphics/circuit_macros/doc/Tline.m423
-rw-r--r--graphics/circuit_macros/doc/Ttree.m456
-rw-r--r--graphics/circuit_macros/doc/Variable.m428
-rw-r--r--graphics/circuit_macros/doc/Version.tex1
-rw-r--r--graphics/circuit_macros/doc/Windings.m4113
-rw-r--r--graphics/circuit_macros/doc/Workflow.m494
-rw-r--r--graphics/circuit_macros/doc/Xform.m439
-rw-r--r--graphics/circuit_macros/doc/bi_trans.m465
-rw-r--r--graphics/circuit_macros/doc/bistable.m435
-rw-r--r--graphics/circuit_macros/doc/bitr.m45
-rw-r--r--graphics/circuit_macros/doc/bitrbody.m44
-rw-r--r--graphics/circuit_macros/doc/body.tex3342
-rw-r--r--graphics/circuit_macros/doc/currents.m452
-rw-r--r--graphics/circuit_macros/doc/defines.tex1892
-rw-r--r--graphics/circuit_macros/doc/eboxdims.m414
-rw-r--r--graphics/circuit_macros/doc/fbfilter.m439
-rw-r--r--graphics/circuit_macros/doc/fet.m4170
-rw-r--r--graphics/circuit_macros/doc/lrarrows.m416
-rw-r--r--graphics/circuit_macros/doc/md.tex59
-rw-r--r--graphics/circuit_macros/doc/mplex.m449
-rw-r--r--graphics/circuit_macros/doc/oax.m45
-rw-r--r--graphics/circuit_macros/doc/oaxbody.m44
-rw-r--r--graphics/circuit_macros/doc/quick.m416
-rw-r--r--graphics/circuit_macros/doc/stringdims.m410
-rw-r--r--graphics/circuit_macros/doc/test.tex1
-rw-r--r--graphics/circuit_macros/doc/thyristor.m4118
-rw-r--r--graphics/circuit_macros/doc/tran.m45
-rw-r--r--graphics/circuit_macros/doc/tran.tex76
-rw-r--r--graphics/circuit_macros/doc/tranbody.m46
-rw-r--r--graphics/circuit_macros/doc/ujt.m428
-rw-r--r--graphics/circuit_macros/doc/woodchips.m424
84 files changed, 8896 insertions, 0 deletions
diff --git a/graphics/circuit_macros/doc/AmpTable.m4 b/graphics/circuit_macros/doc/AmpTable.m4
new file mode 100644
index 0000000000..c94f682cbc
--- /dev/null
+++ b/graphics/circuit_macros/doc/AmpTable.m4
@@ -0,0 +1,22 @@
+.PS
+# `Amptable.m4'
+cct_init
+movewid = 2pt__
+{
+ {amp ; move ; "{\tt `amp'}" ljust}
+ move down 0.4; right_
+ {amp(,0.3) ; move ; "{\tt `amp'(,0.3)}" ljust}
+ }
+ move right_ 2.0
+{ {delay ; move ; "{\tt `delay'}" ljust}
+ move down 0.4; right_
+ {delay(,0.2) ; move ; "{\tt `delay'(,0.2)}" ljust}
+ }
+
+ move right_ 2.0
+{ {integrator ; move ; "{\tt `integrator'}" ljust}
+ move down 0.5; right_
+ {integrator(,0.3) ; move ; "{\tt `integrator'(,0.3)}" wid 82pt__ ljust}
+ }
+
+.PE
diff --git a/graphics/circuit_macros/doc/Antennas.m4 b/graphics/circuit_macros/doc/Antennas.m4
new file mode 100644
index 0000000000..6053cd2e3f
--- /dev/null
+++ b/graphics/circuit_macros/doc/Antennas.m4
@@ -0,0 +1,40 @@
+.PS
+# `Antennas.m4'
+cct_init
+s_init(Antennas)
+sinclude(Circuit_macros.dim)
+
+ define(`elen_',elen_*0.9)
+ B: Here
+ A: antenna
+ s_box(T) below at A.T
+ s_box(`\tt an`'tenna') at A.n above
+ A: antenna(at A.T+(elen_,0),T)
+ s_box(T) below at A.T
+ s_box(`\tt (,T)') at A.n above
+ A: antenna(at A.T+(elen_,0),,L)
+ s_box(T1) below rjust at A.T1
+ s_box(T2) below ljust at A.T2
+ s_box(`\tt (,{,}L)') at A.n above
+ A: antenna(at A.T+(elen_,0),T,L)
+ s_box(T1) below rjust at A.T1
+ s_box(T2) below ljust at A.T2
+ s_box(`\tt (,T,L)') at A.n above
+ A: antenna(at A.T+(elen_,0),,T)
+ s_box(T) below at A.T
+ s_box(`\tt (,{,}T)') at A.n above
+ A: antenna(at A.T+(elen_,0),,S)
+ s_box(T1) below rjust at A.T1
+ s_box(T2) below ljust at A.T2
+ s_box(`\tt (,{,}S)') at A.n above
+ A: antenna(at A.T+(elen_,0),,D)
+ s_box(T1) below rjust at A.T1
+ s_box(T2) below ljust at A.T2
+ s_box(`\tt (,{,}D)') at A.n above
+ A: antenna(at A.T+(elen_,0),,P)
+ s_box(T) below at A.T
+ s_box(`\tt (,{,}P)') at A.n above
+ A: antenna(at A.T+(elen_,0),,F)
+ s_box(T) below at A.T
+ s_box(`\tt (,{,}F)') at A.n above
+.PE
diff --git a/graphics/circuit_macros/doc/Audio.m4 b/graphics/circuit_macros/doc/Audio.m4
new file mode 100644
index 0000000000..722a2434d8
--- /dev/null
+++ b/graphics/circuit_macros/doc/Audio.m4
@@ -0,0 +1,94 @@
+.PS
+# `Audio.m4'
+cct_init
+
+define(`In123',`
+thinlines_
+ arrow <- from `$1'.In1 up 0.05 left 0.15
+ "{\sl In1}sp_" rjust above
+ arrow <- left 0.15 from `$1'.In2
+ "{\sl In2}sp_" wid 0.2 rjust
+ arrow <- from `$1'.In3 down 0.05 left 0.15
+ "{\sl In3}sp_" rjust below
+thicklines_ ')
+
+L:[
+ [
+ S: speaker
+ `"\tt speaker"' at S.s+(0,-0.2) #below
+ In123(S)
+ thinlines_
+ arrow <- from S.In4 left 0.05 up 0.15
+ "{\sl In4}" above rjust
+ arrow <- from S.In5 right 0.05 up 0.15
+ "{\sl In5}" above
+ arrow <- from S.In6 left 0.05 down 0.15
+ "{\sl In6}" below rjust
+ arrow <- from S.In7 right 0.05 down 0.15
+ "{\sl In7}" below
+ spline <- from S.Box.e+(0,0.05) right 0.27 up 0.10 \
+ then right 0.1 up 0.2
+ "\sl Box" above
+ thicklines_
+ ]
+[
+ H: speaker(,,H)
+ `"\tt speaker(,{,}H)"' at H.s+(0,-0.30) #below
+ ] with .sw at last [].se+(0.25,-0.1)
+ ]
+[
+ B: bell
+ `"\tt bell"' at B.s+(0,-0.2) #below
+ In123(B)
+ thinlines_
+ arrow <- from B.Box.n+(-0.1,0) up 0.15 left 0.1 ; "\sl Box" above
+ arrow <- from B.Circle.n up 0.15 ; "\sl Circle" above
+ thicklines_
+ ] with .w at last [].e+(0.0,0.5)
+[
+ M: microphone
+ `"\tt microphone"' at M.s+(0,-0.2) #below
+ In123(M)
+ thinlines_
+ arrow <- from M.Circle.n up 0.15 ; "\sl Circle" above
+ thicklines_
+ ] with .sw at last [].se+(0.4,0)
+[
+ Z: buzzer
+ `"\tt buzzer"' at Z.s+(0,-0.2) #below
+ In123(Z)
+ thinlines_
+ arrow <- from Z.Box.n up 0.15 ; "\sl Box" above
+ thicklines_
+ ] with .sw at last [].se+(0.4,0)
+R:[
+ Z: buzzer(,,C)
+ `"\tt buzzer(,{,}C)"' at Z.s+(0,-0.2) #below
+ In123(Z)
+ thinlines_
+ spline <- from 0.8<Z.Face.s,Z.Face.n> right 2*arrowht up 0.5*arrowht \
+ then up 0.15 right 0.05
+ "\sl Face" above
+ thicklines_
+ ] with .sw at last [].se+(0.4,0)
+[[
+ E: earphone
+ `"\tt earphone"' at E.s+(0,-0.2) #below
+ In123(E)
+ thinlines_
+ arrow <- from E.Box.n up 0.15 left 0.15 ; "\sl Box" above
+ thicklines_
+ ]
+ [
+ E: earphone(,,C)
+ `"\tt earphone(,{,}C)"' at E.s+(0,-0.2) #below
+ thinlines_
+ arrow <- from E.L up 0.15 left 0.15; "\sl L" rjust
+ arrow <- from E.R up 0.15 right 0.15; "\sl R" ljust
+ "\sl N" at E.N above
+ "\sl C" at E.C
+ thicklines_
+ ] with .sw at last [].se+(0.6,0)
+] with .n at (0.6 between L and R, R.s)+(0,0.1-ifdpic(0.2,0.25))
+
+.PE
diff --git a/graphics/circuit_macros/doc/Axes.m4 b/graphics/circuit_macros/doc/Axes.m4
new file mode 100644
index 0000000000..3d8986ce5c
--- /dev/null
+++ b/graphics/circuit_macros/doc/Axes.m4
@@ -0,0 +1,5 @@
+.PS
+# `Axes.m4'
+ arrow right 0.7 "`$x$-axis'" below
+ arrow up 0.7 from 1st arrow.start "`\rput[B]{90}(0,0){$y$-axis}'" rjust
+.PE
diff --git a/graphics/circuit_macros/doc/BigResistor.m4 b/graphics/circuit_macros/doc/BigResistor.m4
new file mode 100644
index 0000000000..9599c9c9d2
--- /dev/null
+++ b/graphics/circuit_macros/doc/BigResistor.m4
@@ -0,0 +1,20 @@
+.PS
+ cct_init
+ linewid = 2.0
+ linethick_(2.0)
+
+R1: resistor
+
+ thinlines_
+ box dotted wid last [].wid ht last [].ht at last []
+
+ move to 0.85 between last [].sw and last [].se
+ spline <- down arrowht*2 right arrowht/2 then right 0.15; "\tt last []" ljust
+
+ arrow <- down 0.3 from R1.start chop 0.05; "\tt R1.start" below
+ arrow <- down 0.3 from R1.end chop 0.05; "\tt R1.end" below
+ arrow <- down last [].c.y-last arrow.end.y from R1.c; "\tt R1.centre" below
+
+ dimension_(from R1.start to R1.end,0.45,\tt elen\_,0.4)
+ dimension_(right_ dimen_ from R1.c-(dimen_/2,0),0.3,\tt dimen\_,0.5)
+.PE
diff --git a/graphics/circuit_macros/doc/Bip.m4 b/graphics/circuit_macros/doc/Bip.m4
new file mode 100644
index 0000000000..121517d16d
--- /dev/null
+++ b/graphics/circuit_macros/doc/Bip.m4
@@ -0,0 +1,60 @@
+.PS
+# `Bip.m4'
+cct_init
+
+ up_
+Q1: bi_tr(up_ dimen_)
+ thinlines_
+ showbox_(,dotted)
+ thicklines_
+ "\hbox{\sl E}" at Q1.E-(0,0.05) below
+ "\hbox{\sl B}sp_" at Q1.B rjust
+ "\hbox{\sl C}" at Q1.C above
+ "`{\tt bi\_tr(up\_ dimen\_)}'" wid 1.2 at Q1.s + (0,-0.35) below
+
+Q2: bi_tr(,R) with .E at Q1.E+(0.25,0)
+ thinlines_
+ showbox_(,dotted)
+ thicklines_
+ "\hbox{\sl E}" at Q2.E-(0,0.05) below
+ "sp_\hbox{\sl B}" at Q2.B ljust
+ "\hbox{\sl C}" at Q2.C above
+ "`{\tt bi\_tr(,R)}'" at Q2.s + (0,-0.2) below
+
+Q3: bi_tr(,,P) with .C at Q2.C+(1.15,0)
+ thinlines_
+ showbox_(,dotted)
+ thicklines_
+ "\hbox{\sl E}" at Q3.E-(0,0.05) below
+ "\hbox{\sl B}sp_" at Q3.B rjust
+ "\hbox{\sl C}" at Q3.C above
+ "`{\tt bi\_tr(,{,}P)}'" at Q3.s + (0,-0.35) below
+
+Q4: bi_tr(,,,E) with .C at Q3.C+(0.9,0)
+ thinlines_
+ showbox_(,dotted)
+ thicklines_
+ "\hbox{\sl E}" at Q4.E-(0,0.05) below
+ "\hbox{\sl B}sp_" at Q4.B rjust
+ "\hbox{\sl C}" at Q4.C above
+ "`{\tt bi\_tr(,{,},E)}'" at (Q4.s,Q4.E) + (0,-0.2) below
+
+Q5: igbt(,,) with .E at Q4.E+(0.65,0)
+ thinlines_
+ showbox_(,dotted)
+ thicklines_
+ "\hbox{\sl E}" at Q5.E-(0,0.05) below
+ "\hbox{\sl G}sp_" at Q5.G rjust
+ "\hbox{\sl C}" at Q5.C above
+ "`{\tt igbt}'" at Q5.s + (0,-0.35) below
+
+Q6: igbt(,,LD) with .E at Q5.E+(0.55,0)
+ thinlines_
+ showbox_(,dotted)
+ thicklines_
+ "\hbox{\sl E}" at Q6.E-(0,0.05) below
+ "\hbox{\sl G}sp_" at Q6.G rjust
+ "\hbox{\sl C}" at Q6.C above
+ "`{\tt igbt(,{,}LD)}'" at (Q6.s,Q6.E) + (0,-0.2) below
+
+.PE
diff --git a/graphics/circuit_macros/doc/Buffer.m4 b/graphics/circuit_macros/doc/Buffer.m4
new file mode 100644
index 0000000000..545875fe32
--- /dev/null
+++ b/graphics/circuit_macros/doc/Buffer.m4
@@ -0,0 +1,50 @@
+.PS
+# `Buffer.m4'
+log_init
+
+ bd = dimen_*3/4
+ esep = dimen_*3
+[
+ B1: BUFFER_gate(,,bd,bd)
+ thinlines_
+ { arrow <- left 0.2 up 0.2 from B1.In1; "\sl In1" wid 18bp__ rjust
+ move left 18bp__
+ `"\tt bd = dimen\_*3/4" ljust "\tt BUFFER\_gate(,{,}bd,bd)"' ljust \
+ at (last "".w,B1.s +(0,-25bp__))
+ arrow <- up 0.2 from B1.NE; "\sl NE" rjust
+ arrow <- up 0.15 right 0.15 from B1.Out; "\sl Out" above
+ arrow <- down 0.2 from B1.SE; "\sl SE" rjust
+ arrow <- right 0.3 down 0.2 from B1.C; "\sl C" ljust }
+ thicklines_
+ B2: BUFFER_gate(,N,bd,bd,NN) with .sw at B1.se+(esep,0)
+ thinlines_
+ { arrow <- left 0.2 up 0.2 from B2.In1; "\sl In1" rjust
+ arrow <- right 0.2 up 0.2 from B2.N_NE1 ; "\sl N\_NE1" ljust ht 11bp__
+ arrow <- right 0.15 up 0.15 from B2.N_NE2 ; "\sl N\_NE2" ljust
+ arrow <- down 0.15 right 0.15 from B2.Out; "\sl Out" ljust
+ `"\tt BUFFER\_gate(,N,bd,bd,NN)"' at B2.s+(0,-18bp__) }
+ thicklines_
+
+ B3: BUFFER_gen(ITNOC,bd,bd,PN,,N,LH_symbol at C) \
+ with .sw at last [].se+(esep,0)
+ { `"\tt BUFFER\_gen(ITNOC,bd,bd,PN,{,}N,"' ljust \
+ `"\tt $\;\;$LH\_symbol at C)"' ljust at B3.s+(-60bp__,-30bp__) }
+ thinlines_
+ { arrow <- left 0.2 up 0.2 from B3.In1; "\sl In1" rjust
+ arrow <- left 0.2 up 0.2 from B3.In2; "\sl In2" rjust
+ arrow <- up 0.15 right 0.15 from B3.Out; "\sl Out" above
+ arrow <- down 0.2 from B3.N_SE1; "\sl N\_SE1" rjust
+ arrow <- right 0.3 down 0.2 from B3.C; "\sl C" ljust }
+ thicklines_
+]
+
+ B4: BUFFER_gate(right_ elen_ from last [].sw+(0,-0.35),,bd,bd)
+ { `"\tt BUFFER\_gate(right\_ elen\_,{,}bd,bd)"' ljust at B4.end }
+ move to B4.start+(0,-dimen_)
+ B6: BUFFER_gate(right_ elen_,N,bd,bd,,N,LH_symbol(I) at C)
+ line down dimen_/4 from last [].N_SE1.s then left dimen_*2/3
+ {`"\tt BUFFER\_gate(right\_ elen\_,N,bd,bd,{,}N,LH\_symbol(I) at C)"' ljust \
+ `"\tt line down dimen\_/3 from last [].N\_SE1.s then left dimen\_*2/3"' \
+ ljust at B6.end }
+
+.PE
diff --git a/graphics/circuit_macros/doc/Capture.JPG b/graphics/circuit_macros/doc/Capture.JPG
new file mode 100644
index 0000000000..8819dece9c
--- /dev/null
+++ b/graphics/circuit_macros/doc/Capture.JPG
Binary files differ
diff --git a/graphics/circuit_macros/doc/CctTable.m4 b/graphics/circuit_macros/doc/CctTable.m4
new file mode 100644
index 0000000000..4fa5405689
--- /dev/null
+++ b/graphics/circuit_macros/doc/CctTable.m4
@@ -0,0 +1,90 @@
+.PS
+# `CctTable.m4'
+cct_init
+divert(-1)
+
+divert(0)dnl
+
+movewid = 2 pt__
+hm = 2.05
+vm = 0.28
+{ {resistor ; move ;"`{\tt resistor}'" ljust}
+ move right_ hm
+ {resistor(,,Q) ; move ;"`\tt resistor(,{,}Q) '" ljust}
+ move right_ hm
+ {resistor(,,E) ; move
+ "`\shortstack[l]{\tt resistor(,{,}E)\\ {\tt $\equiv$ ebox}}'" ljust}
+}
+ move down vm; right_
+{ {resistor(,,ES) ; move ;"`\tt resistor(,{,}ES) '" ljust}
+ move right_ hm
+ {resistor(,,H) ; move ;"`\tt resistor(,{,}H) '" ljust}
+ move right_ hm
+ {ebox(,,,0.5) ; move ;"`{\tt ebox(,{,},0.5)}'" ljust}
+}
+ move down vm; right_
+{ {resistor(,,V) ; move ;"`{\tt resistor(,{,}V)}'" ljust}
+ move right_ hm
+ {move down_ 0.05; right_
+ thermocouple ; move;"`{\tt thermocouple}'" ljust; move up_ 0.05}
+ move right_ hm
+ {ebox(,0.5,0.3) ; move ;"`{\tt ebox(,0.5,0.3)}'" ljust}
+}
+ move down vm; right_
+{ {inductor ; move ;"`{\tt inductor}'" ljust}
+ move right_ hm
+ {inductor(,W); move ;"`{\tt inductor(,W)}'" ljust}
+ move right_ hm
+ {inductor(,L); move ;"`{\tt inductor(,L)}'" ljust}
+}
+ move down vm; right_
+{ {inductor(,,,M) ; move ;"`{\tt inductor(,{,},M)}'" ljust}
+ move right_ hm
+ {inductor(,W,6,P); move ;"`{\tt inductor(,W,6,P)}'" ljust}
+ move right_ hm
+ {move right_ 0.2; ttmotor(,G) ; move ;"`{\tt ttmotor(,G)}'" ljust}
+}
+ move down vm; right_
+{ {capacitor ; move ;"`{\tt capacitor}'" ljust}
+ move right_ hm
+ {capacitor(,C); move ;"`{\tt capacitor(,C)}'" ljust}
+ move right_ hm
+ {capacitor(,C+); move ;"`{\tt capacitor(,C+)}'" ljust}
+}
+ move down vm; right_
+{ {capacitor(,P); move ;"`{\tt capacitor(,P)}'" ljust}
+ move right_ hm
+ {capacitor(,E); move ;"`{\tt capacitor(,E)}'" ljust}
+ move right_ hm
+ {capacitor(,K); move ;"`{\tt capacitor(,K)}'" ljust}
+}
+ move down 0.25; right_
+{ {capacitor(,M); move ;"`{\tt capacitor(,M)}'" ljust}
+ move right_ hm
+ {capacitor(,N); move ;"`{\tt capacitor(,N)}'" ljust}
+ move right_ hm
+ {xtal ; move ;"`{\tt xtal}'" ljust}
+}
+ move down 0.25; right_
+{ {memristor ; move;"`{\tt memristor}'" ljust}
+ move right_ hm
+ {heater; move;"`{\tt heater}'" ljust}
+ move right_ hm
+ {tline ; move;"`{\tt tline}'" ljust}
+}
+ move down 0.25; right_
+{ {move up_ 0.05; right_; gap ; move ;"`{\tt gap}'" ljust}
+ move right_ hm
+ {gap(,,A) ; move ;"`{\tt gap(,{,}A)}'" ljust}
+ move right_ hm
+ {arrowline ; move;"`{\tt arrowline}'" ljust}
+}
+ move down 0.25; right_
+{ {lamp ; move;"`{\tt lamp}'" ljust}
+ move right_ hm
+ {reed ; move ;"`{\tt reed}'" ljust}
+ move right_ hm
+ {reed(,,,fill_(0.9),CR) ; move ;"`{\tt reed(,{,},fill\_(0.9),CR)}'" ljust}
+}
+
+.PE
diff --git a/graphics/circuit_macros/doc/Circuit_macros.bib b/graphics/circuit_macros/doc/Circuit_macros.bib
new file mode 100644
index 0000000000..a918b18bb9
--- /dev/null
+++ b/graphics/circuit_macros/doc/Circuit_macros.bib
@@ -0,0 +1,155 @@
+
+@misc{Aplevich2011,
+author={Aplevich, J. D.},
+title={Drawing with dpic},
+note={In the dpic source distribution.},
+year={2015}}
+
+@book{Bentley88,
+author={Bentley, J.},
+title={More Programming Pearls},
+address={Reading, Massachusetts},
+publisher={Addison-Wesley},
+year={1988}}
+
+@misc{Bentley2010,
+author={Bentley, J. and Yepez, A.},
+title={Little Languages},
+publisher={Mississippi State University},
+note={\url{www.cse.msstate.edu/~niu/courses/CSE8990/slides/Alejandra-0210.pdf}},
+year={2010}}
+
+@misc{Clark99,
+author={Clark, A. R.},
+title={Using Circuit Macros},
+note={Courtesy of Alan Robert Clark at
+ \url{http://ytdp.ee.wits.ac.za/cct.html}},
+year={1999}}
+
+@article{Girou94,
+author={Girou, D.},
+title={Pr\'esentation de {PST}ricks},
+journal={Cahiers {GUT}enberg},
+volume={16},
+note={%
+ \url{http://cahiers.gutenberg.eu.org/cg-bin/article/CG_1994___16_21_0.pdf}},
+year={1994}}
+
+@book{Goossens97,
+author={Goossens, M. and Rahtz, S. and Mittelbach, F.},
+title={The \LaTeX Graphics Companion},
+address={Reading, Massachusetts},
+publisher={Addison-Wesley},
+year={1997}}
+
+@misc{IEEEstd,
+author={IEEE},
+title={Graphic Symbols for Electrical and Electronic Diagrams},
+note={Std 315-1975, 315A-1986, reaffirmed 1993.},
+institution={IEEE},
+year={1975}}
+
+@misc{Johnstone92,
+author={Johnstone, A.},
+title={Electronic symbols for \protect{\LaTeX}\ picture mode},
+institution={Royal Holloway, University of London},
+note={Email:{\tt adrean@cs.rhbnc.ac.uk}},
+year={1992}}
+
+@misc{KDEApps2009,
+author={KDE-Apps.org},
+title={Cirkuit},
+note={KDE application:
+ \url{http://kde-apps.org/content/show.php/Cirkuit?content=107098}
+ and later version at
+ \url{https://github.com/ag-ckt/cirkuit/tree/V0.5.0}},
+year={2009}}
+
+@techreport{KRm4,
+author={Kernighan, B. W. and Richie, D. M.},
+title={The {M4} Macro Processor},
+institution={Bell Laboratories},
+year={1977}}
+
+@techreport{KRpic,
+author={Kernighan, B. W.},
+title={{PIC}---{A} Graphics Language for Typesetting, User Manual},
+institution={AT\&T Bell Laboratories},
+series={Computing Science Technical Report},
+number={116},
+note={\url{http://doc.cat-v.org/unix/v10/10thEdMan/pic.pdf}},
+year={1991}}
+
+@book{Landauer95,
+author={Landauer, Thomas K.},
+title={The Trouble with Computers},
+address={Cambridge},
+publisher={MIT Press},
+year={1995}}
+
+@misc{Raymond95,
+author={Raymond, E. S.},
+title={Making Pictures With {GNU} {PIC}},
+note={In {GNU} groff source distribution, also in the dpic package and
+at \url{http://www.kohala.com/start/troff/gpic.raymond.ps}},
+year={1995}}
+
+@book{Sedra97,
+author={Sedra, A. S. and Smith, K. C.},
+title={Microelectronic Circuits},
+address={Oxford},
+publisher={Oxford University Press},
+year={1997}}
+
+@misc{Seindal94,
+author={Seindal {\sl et al}, R.},
+title={{GNU} m4},
+note={\url{http://www.gnu.org/software/m4/manual/m4.html}},
+institution={GNU},
+year={1994}}
+
+@misc{Verwer92,
+author={Verwer, N.},
+title={Readme for {L}oggates},
+institution={Utrecht, Dept. of Computer Science},
+note={Email:{\tt nico@cs.ruu.nl}},
+year={1992}}
+
+@techreport{dvips,
+author={Rokicki, T.},
+title={{DVIPS:} {A} {\TeX\ } Driver},
+institution={Stanford},
+year={1994}}
+
+@misc{gpic,
+author={Lemberg, W.},
+institution={The Free Software Foundation},
+title={Gpic man page},
+note={\url{http://www.manpagez.com/man/1/groff/}},
+year={2005}}
+
+@misc{metapost,
+author={Hobby, J. D.},
+title={A User's Manual for {M}eta{P}ost},
+institution={Bell Laboratories},
+year={1990}}
+
+@misc{mfpic,
+author={Leathrum, T. and Tobin, G.},
+title={Pictures in {\TeX\ }with Metafont},
+note={Mfpic manual},
+year={1996}}
+
+@misc{pstricks,
+author={Van Zandt, T.},
+title={{PST}ricks: Postscript Macros for Generic TeX},
+institution={CTAN.org},
+note={\url{http://mirrors.ctan.org/graphics/pstricks/base/doc/pst-user.pdf}},
+year={2007}}
+
+@misc{tikz,
+author={Tantau, T.},
+title={TiKz \& PGF},
+institution={CTAN.org},
+note={\url{http://mirrors.ctan.org/graphics/pgf/base/doc/pgfmanual.pdf}},
+year={2013}}
diff --git a/graphics/circuit_macros/doc/Circuit_macros.pdf b/graphics/circuit_macros/doc/Circuit_macros.pdf
new file mode 100644
index 0000000000..95830643bd
--- /dev/null
+++ b/graphics/circuit_macros/doc/Circuit_macros.pdf
Binary files differ
diff --git a/graphics/circuit_macros/doc/Circuit_macros.tex b/graphics/circuit_macros/doc/Circuit_macros.tex
new file mode 100644
index 0000000000..d1be7bc1e7
--- /dev/null
+++ b/graphics/circuit_macros/doc/Circuit_macros.tex
@@ -0,0 +1,88 @@
+% Circuit_macros.tex
+\documentclass{article}
+\usepackage{verbatim,url}
+\usepackage{amssymb}
+\usepackage[amssymb,Gray,thinqspace,textstyle]{SIunits}
+\usepackage{boxdims}
+\usepackage{multicol}
+\usepackage{xspace}
+\input mode
+\usepackage{ifpdf}
+\usepackage{bookmark}
+\usepackage{pdfcomment}
+% The followowing seems to cure the problem of missing underscores:
+\usepackage[T1]{fontenc}
+\usepackage{lmodern}
+%\usepackage{textcomp}
+%\usepackage{microtype}
+%\DisableLigatures{encoding=T1,family=tt*}
+%
+\addtolength{\textwidth}{3cm}
+\addtolength{\hoffset}{-1.5cm}
+\addtolength{\textheight}{4cm}
+\addtolength{\voffset}{-1in}
+\setcounter{topnumber}{3}
+
+% Exdented captions
+\makeatletter
+\long\def\@makecaption#1#2{%
+ \vskip\abovecaptionskip
+ \sbox\@tempboxa{\hskip-3em{\bf #1:} #2}%
+ \ifdim \wd\@tempboxa >\hsize
+ \hskip-3em{\bf #1:} #2\par
+ \else
+ \global \@minipagefalse
+ \hb@xt@\hsize{\box\@tempboxa\hfil}%
+ \fi
+ \vskip\belowcaptionskip}
+
+%%\@startsection {NAME}{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}
+%% optional * [ALTHEADING]{HEADING}
+
+\renewcommand\section{\@startsection {section}{1}{\z@}%
+ {-3.5ex \@plus -1ex \@minus -.2ex}%
+ {2.3ex \@plus.2ex}%
+ {\normalfont\Large\bfseries%
+\let\@@tmp\@svsec\def\@svsec{\llap{\@@tmp}}%
+}}
+\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
+ {-3.25ex\@plus -1ex \@minus -.2ex}%
+ {1.5ex \@plus .2ex}%
+ {\normalfont\large\bfseries%
+\let\@@tmp\@svsec\def\@svsec{\llap{\@@tmp}}%
+}}
+\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
+ {-3.25ex\@plus -1ex \@minus -.2ex}%
+ {1.5ex \@plus .2ex}%
+ {\normalfont\normalsize\bfseries%
+\let\@@tmp\@svsec\def\@svsec{\llap{\@@tmp}}%
+}}
+
+\makeatother
+
+\hypersetup{
+ pdflang=English,
+ unicode=true,
+ colorlinks=true,
+ linkcolor=purple,
+ citecolor=purple}
+
+\begin{document}
+\title{M4 Macros for Electric Circuit Diagrams in \LaTeX\ Documents}
+\author{Dwight Aplevich}
+\date{%
+\input Version
+\vspace*{-\baselineskip}
+}
+\maketitle
+
+\input body
+
+%\pdfbookmark[section]{\refname}{refs}
+\bibliographystyle{plain}
+\makeatletter
+\addcontentsline{toc}{section}{References\ \unhbox \voidb@x
+ \cleaders \hbox to.44em{\hss .\hss }\hfill \kern \z@ }
+\makeatother
+\bibliography{Circuit_macros}
+ \end{document}
diff --git a/graphics/circuit_macros/doc/Composite.m4 b/graphics/circuit_macros/doc/Composite.m4
new file mode 100644
index 0000000000..c77f8c89b9
--- /dev/null
+++ b/graphics/circuit_macros/doc/Composite.m4
@@ -0,0 +1,58 @@
+.PS
+# Composite.m4
+log_init
+
+divert(-1)
+
+divert(0)dnl
+
+ command "{\tt"
+[
+ K1: KelvinR
+ { "`KelvinR'" at last [].C +(0,-0.25)
+ "\sl T1" at K1.T1 above
+ "\sl T2" at K1.T2 above
+ arrow <- up 0.1 left 0.1 from last [].Start ; `"\sl Start"' above
+ arrow <- up 0.1 right 0.1 from last [].End ; `"\sl End"' above }
+ K2: KelvinR(,R) with .Start at K1.End+(0.25,0.1)
+ { "`KelvinR(,R)'" at last [].C +(0,-0.25)
+ "\sl T1" at K2.T1 rjust
+ "\sl T2" at K2.T2 ljust }
+]
+
+[
+ FTcap
+ { thinlines_
+ `"FTcap"' at last [].s +(0,-0.2)
+ arrow <- up 0.1 left 0.1 from last [].Start ; `"\sl Start"' above
+ arrow <- up 0.1 right 0.1 from last [].End ; `"\sl End"' above
+ arrow <- up 0.15 left 0.1 from last [].T1 ; `"\sl T1"' rjust
+ arrow <- right 0.1 from last [].T2 ; `"\sl T2"' ljust
+ thicklines_ }
+ FTcap(B) with .w at last [].e+(0.65,0)
+ { thinlines_
+ `"FTcap(B)"' at last [].s +(0,-0.2)
+ arrow <- up 0.1 left 0.1 from last [].Start ; `"\sl Start"' above
+ arrow <- up 0.1 right 0.1 from last [].End ; `"\sl End"' above
+ arrow <- up 0.15 left 0.1 from last [].T1 ; `"\sl T1"' rjust
+ arrow <- left 0.1 from last [].T2 ; `"\sl T2"' rjust
+ thicklines_ }
+ FTcap(C) with .w at last [].e+(0.65,0)
+ { thinlines_
+ `"FTcap(C)"' at last [].s +(0,-0.2)
+ arrow <- up 0.1 left 0.1 from last [].Start ; `"\sl Start"' above
+ arrow <- up 0.1 right 0.1 from last [].End ; `"\sl End"' above
+ arrow <- left 0.1 from last [].T ; `"\sl T"' rjust
+ thicklines_ }
+ FTcap(D) with .w at last [].e+(0.65,0)
+ { thinlines_
+ `"FTcap(D)"' at last [].s +(0,-0.2)
+ arrow <- up 0.1 left 0.1 from last [].Start ; `"\sl Start"' above
+ arrow <- up 0.1 right 0.1 from last [].End ; `"\sl End"' above
+ arrow <- left 0.1 from last [].T ; `"\sl T"' rjust
+ thicklines_ }
+
+] with .sw at last [].se+(0.1,0)
+
+ command "}"
+.PE
diff --git a/graphics/circuit_macros/doc/ConfigA.m4 b/graphics/circuit_macros/doc/ConfigA.m4
new file mode 100644
index 0000000000..56fd5fe54f
--- /dev/null
+++ b/graphics/circuit_macros/doc/ConfigA.m4
@@ -0,0 +1,38 @@
+.PS
+# ConfigA.m4
+sinclude(Circuit_macros.dim)
+s_init(ConfigA)
+gen_init
+ "{\tt .pic}" above
+ arrow <-
+ M4: shadebox(box wid boxht "{\tt m4}")
+
+ arrow <-
+ Conf: shadebox(box wid boxwid*2 "Configuration file")
+ s_box(\tt pstricks.m4) at Conf.nw above ljust
+
+ arrow <- from Conf.e
+ Gen: shadebox(box wid boxwid*2.25)
+ s_box(\tt libgen.m4) at Gen.nw above ljust
+ s_box(\tt\small\shortstack[l]{%
+ $\;\cdots$ \\
+ ``define(\char96cct\_init\char39,...)'' \\
+ $\;\cdots$}) with .w at 0.05 between Gen.w and Gen.e
+
+ Src: shadebox(box ht Gen.ht wid Conf.wid with .nw at Conf.sw+(0,-0.25))
+ s_box(Diagram source {\tt quick.m4}) at Src.nw above ljust
+ s_box(\tt\small\shortstack[l]{%
+ .PS \\
+ cct\_init \\
+ $\;\cdots$}) with .w at 0.05 between Src.w and Src.e
+ arrow from Src.w left linewid/2 then up M4.y-Src.y-M4.ht/4 then left linewid/2
+
+ arrow <- right from Src.e
+ Cct: shadebox(box wid boxwid*2.25)
+ s_box(\tt libcct.m4) at Cct.nw above ljust
+ s_box(\tt\small\shortstack[l]{%
+ $\;\cdots$ \\
+ ``define(\char96resistor\char39,...)'' \\
+ $\;\cdots$}) with .w at 0.05 between Cct.w and Cct.e
+
+.PE
diff --git a/graphics/circuit_macros/doc/ConfigB.m4 b/graphics/circuit_macros/doc/ConfigB.m4
new file mode 100644
index 0000000000..a33e57b86b
--- /dev/null
+++ b/graphics/circuit_macros/doc/ConfigB.m4
@@ -0,0 +1,42 @@
+.PS
+# ConfigB.m4
+sinclude(Circuit_macros.dim)
+s_init(ConfigB)
+gen_init
+ aw = linewid/2
+ linewid = linewid*2/3
+ "{\tt .pic}" above
+ arrow <- right aw
+ M4: shadebox(box wid boxht "{\tt m4}")
+
+ arrow <- right aw
+ Src: shadebox(box wid boxwid*1.85)
+ s_box(Diagram source) at Src.nw above ljust
+ s_box(\tt\small\shortstack[l]{%
+ .PS \\
+ ``include(pstricks.m4)'' \\
+ cct\_init \\
+ $\;\cdots$}) with .w at 0.05 between Src.w and Src.e
+
+ arrow <- right aw from 0.35 between Src.ne and Src.se
+ Conf: shadebox(box wid boxwid*2 "Configuration file" with .nw at (Here,Src.n))
+ { s_box(\tt pstricks.m4) at Conf.nw above ljust }
+
+ arrow <- right aw from Conf.e
+ Gen: shadebox(box wid Conf.wid)
+ s_box(\tt libgen.m4) at Gen.nw above ljust
+ s_box(\tt\small\shortstack[l]{%
+ $\;\cdots$ \\
+ ``define(\char96cct\_init\char39,...)'' \\
+ $\;\cdots$}) with .w at 0.05 between Gen.w and Gen.e
+
+ Cct: shadebox(box wid Conf.wid with .nw at Conf.sw+(0,-0.25))
+ s_box(\tt libcct.m4) at Cct.nw above ljust
+ s_box(\tt\small\shortstack[l]{%
+ $\;\cdots$ \\
+ ``define(\char96resistor\char39,...)'' \\
+ $\;\cdots$}) with .w at 0.05 between Cct.w and Cct.e
+ dw =(Conf.w.x-Src.e.x)/2
+ arrow from Cct.w left dw then up Src.y-Cct.y-0.05 then left dw
+
+.PE
diff --git a/graphics/circuit_macros/doc/ConfigC.m4 b/graphics/circuit_macros/doc/ConfigC.m4
new file mode 100644
index 0000000000..ccf8bae2d7
--- /dev/null
+++ b/graphics/circuit_macros/doc/ConfigC.m4
@@ -0,0 +1,43 @@
+.PS
+# ConfigC.m4
+sinclude(Circuit_macros.dim)
+s_init(ConfigC)
+gen_init
+ aw = linewid/2
+ linewid = linewid*2/3
+ "{\tt .pic}" above
+ arrow <- right aw
+ M4: shadebox(box wid boxht "{\tt m4}")
+
+ arrow <- right aw
+ Src: shadebox(box wid boxwid*1.85)
+ s_box(Diagram source) at Src.nw above ljust
+ s_box(\tt\small\shortstack[l]{%
+ .PS \\
+ ``include(libgen.m4)'' \\
+ cct\_init \\
+ $\;\cdots$}) with .w at 0.05 between Src.w and Src.e
+
+ arrow <- right aw from 0.35 between Src.ne and Src.se
+ Gen: shadebox(box wid boxwid*2.25 with .nw at (Here,Src.n))
+ s_box(\tt libgen.m4) at Gen.nw above ljust
+ s_box(\tt\small\shortstack[l]{%
+ ``if..include(pstricks.m4)'' \\
+ $\;\cdots$ \\
+ ``define(\char96cct\_init\char39,...)'' \\
+ $\;\cdots$}) with .w at 0.05 between Gen.w and Gen.e
+ arrow <- right aw from Gen.e
+ Conf: shadebox(box wid boxwid*1.8 "Configuration file")
+ { s_box(\tt pstricks.m4) at Conf.nw above ljust }
+
+
+ Cct: shadebox(box wid Gen.wid with .nw at Gen.sw+(0,-0.25))
+ s_box(\tt libcct.m4) at Cct.nw above ljust
+ s_box(\tt\small\shortstack[l]{%
+ $\;\cdots$ \\
+ ``define(\char96resistor\char39,...)'' \\
+ $\;\cdots$}) with .w at 0.05 between Cct.w and Cct.e
+ dw =(Cct.w.x-Src.e.x)/2
+ arrow from Cct.w left dw then up Src.y-Cct.y-0.05 then left dw
+
+.PE
diff --git a/graphics/circuit_macros/doc/Conn.m4 b/graphics/circuit_macros/doc/Conn.m4
new file mode 100644
index 0000000000..7253d2b313
--- /dev/null
+++ b/graphics/circuit_macros/doc/Conn.m4
@@ -0,0 +1,69 @@
+.PS
+# `Conn.m4'
+cct_init
+
+T:[
+ ifelse(ifmpost(T)`'ifpostscript(T),,`command "{\sf"')
+ S1: tstrip(U)
+ thinlines_
+ arrow <- left 0.15 from S1.L1; "L1" rjust
+ arrow <- left 0.15 from S1.L4; "L4" wid 0.2 rjust
+ "$\vdots$" at (0.5 between last "" and 2nd last "")+(-0.15,0.02)
+ arrow <- right 0.25 from S1.R1; "R1" ljust
+ arrow <- right 0.25 from S1.R4; "R4" ljust
+ "$\vdots$" at (0.5 between last "" and 2nd last "")+(0.15,0.02)
+ arrow <- right 0.15 up 0.10 from S1.T1; "T1" ljust
+ arrow <- right 0.15 up 0.10 from S1.T4; "T4" ht 11 pt__ ljust
+ "$\vdots$" at (0.5 between last "" and 2nd last "")+(0.15,0.02)
+ thicklines_
+ CS1: "`\tt tstrip(U)'" at S1.s+(0,-0.15)
+ S2: tstrip(R,5,DO;wid=1.0;ht=0.25) with .sw at S1.se+(0.7,0.15)
+ thinlines_
+ arrow <- up 0.2 right 0.1 from S2.T1; "T1" above
+ arrow <- up 0.2 right 0.1 from S2.T5; "T5" above
+ "$\cdots$" at 0.5 between last "" and 2nd last "" above
+ CS2: `"\tt tstrip(R,5,"' ht 0.1 ljust \
+ `"\tt $\;\;$DO;wid=1.0;ht=0.25)"' ljust at S2.sw+(-0.1,-0.2)
+ ifelse(ifmpost(T)`'ifpostscript(T),,`command "}"')
+]
+
+C: [
+ C1: ccoax
+ `"\tt ccoax\vphantom{(}"' ht 11 pt__ at C1.s below
+ thinlines_
+ arrow <- up 0.1 right 0.1 from C1.C.ne; "C" ljust
+ arrow <- down 0.05 right 0.1 from C1.S.e; "S" wid 0.1 ht 11pt__ ljust
+ thicklines_
+ C2: ccoax(at C1+(0,0.3),F)
+ `"\tt ccoax(,F)"' ht 11 pt__ wid 0.65 at C2.ne ljust
+ ] with .C1.sw at T.S2.se+(0.5,0.0)
+
+Y: [
+ tconn(,O)
+ {`"\tt tconn(,O)"' at last line.c+(0,-0.2) wid 43 pt__ }
+ move to Here+(0.3,0)
+ P1: tconn(,>)
+ {`"\tt (,>)"' at last line.c+(0,-0.2)}
+ move to P1.end+(0.3,0)
+ tconn(,>>)
+ {`"\tt (,>>)"' at last line.c+(0,-0.2)}
+ move to P1.start+(0,linewid)
+ P3: tconn(,<)
+ {`"\tt tconn(,<)"' at last line.c+(0,-0.2)}
+ move to P3.end+(0.3,0)
+ tconn(,<<)
+ {`"\tt (,<<)"' at last line.c+(0,-0.2)}
+
+] with .sw at (C.e.x-0.4,T.s.y)
+
+B: [
+ tbox(V_2)
+ `"\tt tbox(V\_2)"' at last [].sw below ljust
+ [ left_;
+ tbox(V_1,,,<>) ] with .nw at last [].sw+(0,-0.25)
+ `"\tt tbox(V\_1,{,},<>)"' at last [].sw below ljust
+# `"\tt left\_"' at last [].sw +(0,-0.2) ljust `"\tt tbox(V\_1)"' ljust
+] with .nw at Y.ne+(0.2,0)
+
+
+.PE
diff --git a/graphics/circuit_macros/doc/Corners.m4 b/graphics/circuit_macros/doc/Corners.m4
new file mode 100644
index 0000000000..4873af1fa9
--- /dev/null
+++ b/graphics/circuit_macros/doc/Corners.m4
@@ -0,0 +1,73 @@
+.PS
+# `Corners.m4'
+cct_init
+s_init(Corners)
+sinclude(Circuit_macros.dim)
+
+linethick = 4
+[
+ [ [ line up 0.2
+ line from Here+(0.2,0) left 0.2 ]
+ s_box(`\tt\shortstack[l]{line up 0.2\\ line right 0.2}') \
+ with .n at last [].s +(0,-0.1)
+ ]
+
+ [ [ line up 0.2 then right 0.2 ]
+ s_box(`\tt\shortstack[l]{line up 0.2 \bsl\\ \enskip then right 0.2}') \
+ with .n at last [].s +(0,-0.1)
+ ] with .nw at last [].ne+(0.25,0)
+
+ [ [ line up 0.2
+ line right 0.2 chop -hlth chop 0 ]
+ s_box(`\tt\shortstack[l]{%
+ line up 0.2\\ line right 0.2 \bsl\\ \enskip chop `-hlth' chop 0}') \
+ with .n at last [].s +(0,-0.1)
+ ] with .nw at last [].ne+(0.25,0)
+
+ [ [ line up 0.2
+ round
+ line right 0.2 ]
+ s_box(`\tt\shortstack[l]{%
+ line up 0.2\\`\smash{round}\vphantom{r}'\\ line right 0.2}') \
+ with .n at last [].s +(0,-0.1)
+ ] with .nw at last [].ne+(0.25,0)
+ ]
+
+[
+ [ [ line up 0.15 left 0.15
+ corner
+ line up 0.1 right 0.1 ]
+ s_box(`\tt\shortstack[l]{%
+ line up 0.15 left 0.15\\`corner'\\ line up 0.1 right 0.1}') \
+ with .n at last [].s +(0,-0.1)
+ ]
+
+ [ [ A: Here
+ corner(,at A)
+ s_box(`\sl A') at A below ]
+ s_box(`\tt c`'orner(,at A)') with .n at last [].s +(0,-0.1)
+ ] with .nw at last [].ne+(0.2,0)
+
+ [ [ L: line right 0.2 down 0.3 outlined "lightgray"
+ M: line up 0.2 right 0.1 outlined "lightgray"
+ s_box(\sl L) at L.c+(-0.1,-0.05)
+ s_box(\sl M) at M.c+( 0.13,0)
+ Mitre_(L,M,5 bp__) ]
+ s_box(`\tt Mitre\_(L,M,5 bp\_\_)') with .n at last [].s +(0,-0.1)
+ ] with .nw at last [].ne+(0.2,0)
+
+ [ [ A: (0,0)
+ B: (0.3,0.2)
+ C: (0.5,0.1)
+ line outlined "lightgray" from A to B
+ line outlined "lightgray" from C to B
+ s_box(\sl A) at A rjust
+ s_box(\sl B) at B+(0,2pt__) above
+ s_box(\sl C) at C ljust
+ mitre_(A,B,C) ]
+ s_box(\tt mitre\_(A,B,C)) with .n at last [].s +(0,-0.1)
+ ] with .nw at last [].ne+(0.2,0)
+
+ ] with .nw at last [].sw+(0,-0.1)
+
+.PE
diff --git a/graphics/circuit_macros/doc/Dac.m4 b/graphics/circuit_macros/doc/Dac.m4
new file mode 100644
index 0000000000..77dda3cf55
--- /dev/null
+++ b/graphics/circuit_macros/doc/Dac.m4
@@ -0,0 +1,69 @@
+.PS
+# Dac.m4
+cct_init
+s_init(Dacx)
+
+ ar = 0.15
+
+Q: dac
+thinlines_
+ arrow <- left ar from last [].In1; { move left 0.15 }
+ "In1" above rjust at Here+(0.1,0)
+ "\sl NW" at Q.NW above rjust
+ "\sl SW" at Q.SW below rjust
+ "\sl SE" at Q.SE below ljust
+ "\sl NE" at Q.NE above ljust
+ arrow <- up ar from Q.N1; "\sl N1" above
+ arrow <- down ar from Q.S1; "\sl S1" below
+ arrow <- right ar from Q.Out1; "\sl Out1" above ljust at Here-(0.1,0)
+ arrow <- right ar down ar/2 from Q.C; "\sl C" ljust
+ s_box(`\tt d`'ac') at Q.s+(0,-0.3) below
+thicklines_
+
+Q:dac(,,2,2,3,3) with .w at last [].e+(0.9,0)
+thinlines_
+ "DAC" at Q.C
+ arrow <- left ar from Q.In1; "\sl In1" rjust
+ arrow <- left ar from Q.In2; "\sl In2" rjust
+ arrow <- up ar from Q.N1; "\sl N1" above rjust
+ arrow <- up ar from Q.N2; "\sl N2" above ljust
+ arrow <- right ar from Q.Out1; "\sl Out1" ljust
+ arrow <- right ar from Q.Out2; "\sl Out2" ljust
+ arrow <- right ar from Q.Out3; "\sl Out3" ljust
+ arrow <- down ar left ar/2 from Q.S1; "\sl S1" below rjust
+ arrow <- down ar from Q.S2; "\sl S2" below
+ arrow <- down ar right ar/2 from Q.S3; "\sl S3" below ljust
+ s_box(
+ `\tt Q: d`'ac(,{,}2,2,3,3); \"DAC\" \"2\" at Q.C') at Q.s+(0,-0.3) below
+thicklines_
+
+Q: adc with .nw at last [].ne + (0.9,0)
+thinlines_
+ "\sl NW" at Q.NW above rjust
+ "\sl SW" at Q.SW below rjust
+ "\sl SE" at Q.SE below ljust
+ "\sl NE" at Q.NE above ljust
+ arrow <- left ar from Q.In1; "\sl In1" rjust above at Here+(0.1,0)
+ arrow <- up ar from Q.N1; "\sl N1" above
+ arrow <- down ar from Q.S1; "\sl S1" below
+ arrow <- right ar from Q.Out1; "\sl Out1" ljust above at Here-(0.1,0)
+ arrow <- left ar down ar/2 from Q.C; "\sl C" rjust
+ s_box(`\tt a`'dc') at Q.s+(0,-0.3) below
+thicklines_
+
+Q:adc(,,2,2,3,3) with .w at last [].e+(0.8,0)
+thinlines_
+ "ADC" at Q.C
+ arrow <- left ar from Q.In1; "\sl In1" rjust
+ arrow <- left ar from Q.In2; "\sl In2" rjust
+ arrow <- up ar from Q.N1; "\sl N1" above rjust
+ arrow <- up ar from Q.N2; "\sl N2" above ljust
+ arrow <- right ar from Q.Out1; "\sl Out1" ljust
+ arrow <- right ar from Q.Out2; "\sl Out2" ljust
+ arrow <- right ar from Q.Out3; "\sl Out3" ljust
+ arrow <- down ar left ar/2 from Q.S1; "\sl S1" below rjust
+ arrow <- down ar from Q.S2; "\sl S2" below
+ arrow <- down ar right ar/2 from Q.S3; "\sl S3" below ljust
+ s_box(`\tt a`'dc(,{,}2,2,3,3)') at Q.s+(0,-0.3) below
+
+.PE
diff --git a/graphics/circuit_macros/doc/Darlington.m4 b/graphics/circuit_macros/doc/Darlington.m4
new file mode 100644
index 0000000000..234c86e558
--- /dev/null
+++ b/graphics/circuit_macros/doc/Darlington.m4
@@ -0,0 +1,36 @@
+.PS
+# `Darlington.m4'
+cct_init
+
+up_
+Darlington
+{ "\sl E" at last [].E below ljust
+ "\sl B" at last [].B rjust
+ "\sl C" at last [].C above ljust
+ `"\tt Darlington"' at last [].s+(0,-10bp__) below }
+Darlington(R,DZB1) with .sw at last [].se+(0.5,0)
+{ "\sl E" at last [].E below rjust
+ "\sl B" at last [].B ljust
+ "\sl B1" at last [].B1 below
+ "\sl C" at last [].C above rjust
+ `"\tt (R,DZB1)"' at last [].s+(0,-10bp__) below }
+Darlington(,EB1) with .sw at last [].se+(0.5,0)
+{ "\sl E" at last [].E below ljust
+ "\sl B" at last [].B rjust
+ "\sl B1" at last [].B1 rjust
+ "\sl C" at last [].C above ljust
+ `"\tt (,EB1)"' at last [].s+(0,-10bp__) below }
+Darlington(,EB1DZR1) with .sw at last [].se+(0.5,0)
+{ "\sl E" at last [].E below ljust
+ "\sl B" at last [].B rjust
+ "\sl B1" at last [].B1 below rjust
+ "\sl C" at last [].C above ljust
+ `"\tt (,EB1DZR1)"' at last [].s+(0,-10bp__) below }
+Darlington(,EB1DE1E2) with .sw at last [].se+(0.5,0)
+{ "\sl E" at last [].E below ljust
+ "\sl B" at last [].B rjust
+ "\sl B1" at last [].B1 below rjust
+ "\sl C" at last [].C above ljust
+ `"\tt (,EB1DE1E2)"' at last [].s+(0,-10bp__) below }
+
+.PE
diff --git a/graphics/circuit_macros/doc/Demultiplexer.m4 b/graphics/circuit_macros/doc/Demultiplexer.m4
new file mode 100644
index 0000000000..210b643441
--- /dev/null
+++ b/graphics/circuit_macros/doc/Demultiplexer.m4
@@ -0,0 +1,44 @@
+.PS
+# `Demultiplexer.m4'
+log_init
+
+ ifmpost(`command "verbatimtex {\sf etex"',
+ `ifpostscript(,
+ `command "{\sf"')')
+
+ right_
+
+ Demux(4,DM1)
+ `"\tt Demux(4,DM1)"' at last [].s below
+ `"\sl Out0"' at last [].Out0.end +(6bp__,6bp__)
+ `"\sl Out3"' at last [].Out3.end +(6bp__,-6bp__)
+ `"\sl In"' at last [].In.end rjust wid 11bp__
+ `"\sl Sel"' at last [].Sel.end ljust above
+ left_; Demux(4,,LOE) with .c at last [].c+(1.2,0)
+ `"\tt left\_; Demux(4,{,}LOE)"' at last [].s + (0,-20bp__) ht 10bp__
+ `"\sl Sel"' at last [].Sel.end rjust
+ `"\sl Out0"' at last [].Out0.end +(-6bp__,6bp__)
+ `"\sl OE"' at last [].OE.end ljust
+ `"\sl In"' at last [].In.end+(0,5bp__) ljust
+ right_; Demux(4,,NOEBN2) with .c at last [].c+(1.2,0)
+ `"\tt (4,{,}NOEBN2)"' at last [].s below
+ `"\sl Sel0"' at last [].Sel0.end rjust
+ `"\sl Sel1"' at last [].Sel1.end ljust
+ `"\sl Out0"' at last [].Out0.end +(5bp__,6bp__)
+ `"\sl Out3"' at last [].Out3.end +(5bp__,6bp__)
+ `"\sl NOE"' at last [].NOE.end rjust
+ `"\sl In"' at last [].In.end above
+ down_; Demux(8,,L3,,28*L_unit) with .c at last [].c+(1.8,0)
+ `"\tt down\_; Demux(8,{,}L3,{,}28*L\_unit)"' at last [].s+(0,-15bp__) \
+ ht 10bp__ wid 170bp__
+ `"\sl Sel0"' at last [].Sel0.end rjust
+ `"\sl Sel2"' at last [].Sel2.end rjust below
+ `"\sl Out0"' at last [].Out0.end rjust
+ `"\sl Out7"' at last [].Out7.end ljust
+ `"\sl In"' at last [].In.end rjust
+
+ifmpost(`command "verbatimtex } etex"',
+`ifpostscript(,
+`command "}"')')
+
+.PE
diff --git a/graphics/circuit_macros/doc/Diodes.m4 b/graphics/circuit_macros/doc/Diodes.m4
new file mode 100644
index 0000000000..360d8e9d9e
--- /dev/null
+++ b/graphics/circuit_macros/doc/Diodes.m4
@@ -0,0 +1,48 @@
+.PS
+# `Diodes.m4'
+cct_init
+movewid = 2pt__
+{ {diode ; move ; "`{\tt diode}'" ljust}
+ move down 0.2; right_
+ {diode(,S) ; move ; "`{\tt diode(,S)}'" ljust}
+ move down 0.2; right_
+ {diode(,V) ; move ; "`{\tt diode(,V)}'" ljust}
+ move down 0.2; right_
+ {diode(,v) ; move ; "`{\tt diode(,v)}'" ljust}
+ move down 0.2; right_
+ {diode(,w) ; move ; "`{\tt diode(,w)}'" ljust}
+ move down 0.2; right_
+ {diode(,B) ; move ; "`{\tt diode(,B)}'" ljust}
+ move down 0.2; right_
+ {diode(,G) ; move ; "`{\tt diode(,G)}'" ljust}
+ }
+
+ move right_ 2.0
+{ {diode(,K) ; move ; "`{\tt diode(,K)}'" ljust}
+ move down 0.2; right_
+ {diode(,ZK) ; move ; "`{\tt diode(,ZK)}'" ljust}
+ move down 0.2; right_
+ {diode(,CR) ; move ; "`{\tt diode(,CR)}'" ljust}
+ move down 0.2; right_
+ {diode(,L) ; move ; "`{\tt diode(,L)}'" ljust}
+ move down 0.2; right_
+ {diode(,F) ; move ; "`{\tt diode(,F)}'" ljust}
+ move down 0.2; right_
+ {diode(,Sh) ; move ; "`{\tt diode(,Sh)}'" ljust}
+ move down 0.2; right_
+ {diode(,D) ; move ; "`{\tt diode(,D)}'" ljust}
+ }
+
+ move right_ 2.0
+{ {diode(,Z,RE) ; move ; "`{\tt diode(,Z,RE)}'" ljust}
+ move down 0.25; right_
+ {diode(,T) ; move ; "`{\tt diode(,T)}'" ljust}
+ move down 0.30; right_
+ {diode(,P) ; move ; "`{\tt diode(,P)}'" ljust}
+ move down 0.30; right_
+ {diode(,LE) ; move ; "`{\tt diode(,LE)}'" ljust}
+ move down 0.15; right_
+ {diode(,LER) ; move ; "`{\tt diode(,LER)}'" ljust}
+ }
+
+.PE
diff --git a/graphics/circuit_macros/doc/Emarrows.m4 b/graphics/circuit_macros/doc/Emarrows.m4
new file mode 100644
index 0000000000..c4b2131902
--- /dev/null
+++ b/graphics/circuit_macros/doc/Emarrows.m4
@@ -0,0 +1,30 @@
+.PS
+# `Emarrows.m4'
+cct_init
+ hskip = 0.6
+[
+ { em_arrows(N)
+ box dotted wid last [].wid ht last [].ht at last [].c
+ thinlines_
+ arrow <- left 0.15 from last [].Head; "\sl Head" wid 0.31 rjust
+ arrow <- down 0.12 from last [].Tail; "\sl Tail" below
+ "\sl A1" rjust below at last [].A1.c
+ "\sl A2" ljust above at last [].A2.c
+ thicklines_
+ move down 0.25 from last [].s
+ move up 0.2 from last [].n
+ "\tt em\_arrows(N)" at last [].s+(0,-0.20) below }
+ { em_arrows(ND,45) with .sw at last [].se+(hskip*1.5,0)
+ "\tt em\_arrows(ND,45)" at last [].s below }
+ { em_arrows(I) with .sw at last [].se+(hskip,0)
+ "\tt $\ldots$(I)" at last [].s below }
+ { em_arrows(ID) with .sw at last [].se+(hskip,0)
+ "\tt $\ldots$(ID)" at last [].s below }
+ { em_arrows(E) with .sw at last [].se+(hskip,0)
+ "\tt $\ldots$(E)" at last [].s below }
+ { em_arrows(ED) with .sw at last [].se+(hskip,0)
+ "\tt $\ldots$(ED)" at last [].s below }
+ ]
+#showbox_
+
+.PE
diff --git a/graphics/circuit_macros/doc/FF.m4 b/graphics/circuit_macros/doc/FF.m4
new file mode 100644
index 0000000000..e8bdafe239
--- /dev/null
+++ b/graphics/circuit_macros/doc/FF.m4
@@ -0,0 +1,11 @@
+.PS
+# `FF.m4'
+log_init
+S: NOR_gate
+ left_
+R: NOR_gate at S+(0,-L_unit*(AND_ht+1))
+ line from S.Out right L_unit*3 then down S.Out.y-R.In2.y then to R.In2
+ line from R.Out left L_unit*3 then up S.In2.y-R.Out.y then to S.In2
+ line left 4*L_unit from S.In1 ; "$S$sp_" rjust
+ line right 4*L_unit from R.In1 ; "sp_$R$" ljust
+.PE
diff --git a/graphics/circuit_macros/doc/FlipFlop.m4 b/graphics/circuit_macros/doc/FlipFlop.m4
new file mode 100644
index 0000000000..c04ca6ba89
--- /dev/null
+++ b/graphics/circuit_macros/doc/FlipFlop.m4
@@ -0,0 +1,32 @@
+.PS
+# `FlipFlop.m4'
+log_init
+iflatex(`textoffset = 1bp__; ifpsfrag(,`latexcommand({\sf)') ')
+s_init(Flipflop)
+sinclude(Circuit_macros.dim)
+right_
+ { Q1: FlipFlop(D,Q1)
+ s_box(``\tt FlipFlop(D,Q1)'') at last [].Chip.s below
+ h1 = L_unit*20
+ w1 = L_unit*12
+ FlipFlop(T,Q2,ht h1 wid w1 fill_(0.9)) with .w at last [].e+(0.25,0)
+ s_box(``\tt FlipFlop(T,Q2,ht h1 wid w1 fill\_(0.9))'') \
+ at (last [].Chip,2nd last [].Chip.s)+(0,-0.25)
+ FlipFlop(RS) with .w at last [].e+(0.25,0)
+ s_box(``\tt FlipFlop(RS)'') at last [].Chip.s below
+ FlipFlop(JK) with .w at last [].e+(0.25,0)
+ s_box(``\tt FlipFlop(JK)'') with .n at last [].PinPR.end
+ }
+ move down 1.5; right_
+ { FlipFlopX(,,:D;E:CK,,:Q;:lg_bartxt(Q))
+ s_box(``\shortstack[l]{\tt FlipFlopX(,{,}\\
+ \tt\quad:D;E:CK,{,}:Q;:lg\_bartxt(Q))}'') at last [].Chip.s below
+ FlipFlopX(,,:T;E:CK,,:Q;) with .Chip.c at last [].e+(1.25,0)
+ s_box(``\shortstack[l]{\tt FlipFlopX(,{,}\\
+ \tt\quad:T;E:CK,{,}:Q;)}'') at last [].Chip.s below
+ FlipFlopX(,,:J;E:CK;:K,N:CLR,:Q;) with .Chip.c at last [].e+(1.25,0)
+ s_box(``\shortstack[l]{\tt FlipFlopX(,{,} \\
+ \tt\quad:J;E:CK;:K,N:CLR,:Q;)}'') at last [].Chip.s below
+ }
+ iflatex(ifpsfrag(,`latexcommand(})'))
+.PE
diff --git a/graphics/circuit_macros/doc/Flowdiag.m4 b/graphics/circuit_macros/doc/Flowdiag.m4
new file mode 100644
index 0000000000..5af78953f0
--- /dev/null
+++ b/graphics/circuit_macros/doc/Flowdiag.m4
@@ -0,0 +1,33 @@
+.PS
+# `Flowdiag.m4'
+define(`shadellipse',`{ellipse $1 fill invis
+ define(`m4h',`1.0 pt__')dnl
+ ellipse invis fill 0.5 wid last ellipse .wid+linethick pt__ \
+ ht last ellipse .ht + linethick pt__ at last ellipse+(m4h,-m4h)}
+ ellipse fill 1 $1')
+
+ shadellipse "{\tt .m4}" "diagram"
+ arrow right linewid*2/3
+
+ {shadellipse(with .b at Here+(-linewid*0.5,boxht/3+linewid/3)) \
+ "{\tt .m4}" "macros"}
+ arrow from last ellipse.b down linewid/3 then right linewid*0.5
+ move down boxht/6; right
+
+ shadebox(box wid boxht "{\bf m4}")
+ arrow right linewid/2
+
+ shadebox(box "{\bf pic}" "interpreter")
+ arrow right from Here-(0,boxht/6)
+
+ {shadellipse(with .b at Here+(-linewid*0.5,boxht/3+linewid/3)) \
+ "{\tt .tex}" "files"}
+ {arrow from last ellipse.b down linewid/3 then right linewid*0.5}
+ move up boxht/6; right
+
+ shadebox(box "\LaTeX" "or" "PDFlatex")
+ arrow right linewid*2/3
+
+ shadebox(box wid boxht "{\tt .dvi}" "or" "{\tt .pdf}")
+
+.PE
diff --git a/graphics/circuit_macros/doc/Fuses.m4 b/graphics/circuit_macros/doc/Fuses.m4
new file mode 100644
index 0000000000..b308e5aadb
--- /dev/null
+++ b/graphics/circuit_macros/doc/Fuses.m4
@@ -0,0 +1,32 @@
+.PS
+# `Fuses.m4'
+cct_init
+
+movewid = 0.25
+
+ {fuse ; {"`{\tt fuse}'" at last line.c+(0,-0.2)}
+ move
+ fuse(,D) ; {"`{\tt fuse(,D)}'" at last line.c+(0,-0.2)}
+ move
+ fuse(,B) ; {"`{\tt fuse(,B)}'" at last line.c+(0,-0.2)}
+ move
+ fuse(,C) ; {"`{\tt fuse(,C)}'" at last line.c+(0,-0.2)}
+ move
+ fuse(,S) ; {"`{\tt fuse(,S)}'" at last line.c+(0,-0.2)}
+ move
+ fuse(,HB) ; {"`{\tt fuse(,HB)}'" at last line.c+(0,-0.2)}
+ }
+ move down; right_
+ fuse(,HC,0.5,0.3) ; {"`{\tt (,HC,0.5,0.3)}'" at last line.c+(0,-0.25)}
+ move
+ cbreaker; {"`{\tt cbreaker}'" at last line.c+(0,-0.25)}
+ move
+ cbreaker(,R); {"`{\tt cbreaker(,R)}'" at last line.c+(0,-0.25)}
+ move
+ cbreaker(,{,}D); {"`{\tt $\ldots$(,{,}D)}'" at last line.c+(0,-0.25)}
+ move
+ cbreaker(,{,}T); {"`{\tt $\ldots$(,{,}T)}'" at last line.c+(0,-0.25)}
+ move
+ cbreaker(,{,}TS); {"`{\tt $\ldots$(,{,}TS)}'" at last line.c+(0,-0.25)}
+
+.PE
diff --git a/graphics/circuit_macros/doc/Grounds.m4 b/graphics/circuit_macros/doc/Grounds.m4
new file mode 100644
index 0000000000..13b4730b80
--- /dev/null
+++ b/graphics/circuit_macros/doc/Grounds.m4
@@ -0,0 +1,39 @@
+.PS
+# `Grounds.m4'
+cct_init
+
+sep = 0.65
+Ground: ground
+ move right sep
+GT: ground(,T)
+ move right sep
+GF: ground(,,F)
+ move right sep
+GE: ground(,,E)
+ move right sep
+
+B: Here+(0,-0.5) ; {
+ "{\tt `ground'}" wid 32bp__ at (Ground,B)
+ "{\tt `ground'(,T)}" at (GT,B)+(0,7bp__)
+ "{\tt (,{,}F)}" at (GF,B)
+ "{\tt (,{,}E)}" at (GE,B)}
+
+
+GS: ground(,,S)
+ move right sep
+GS90: [ground(,,S,90) ] with .n at Here
+ move right sep from GS90.n
+GQ: ground(,,Q)
+ move right sep
+GL: ground(,,L)
+ move right sep
+GP: ground(,,P)
+
+C: Here+(0,-0.5)
+ "{\tt (,{,}S)}" at (GS,C)
+ "{\tt (,{,}S,90)}" at (GS90,C)
+ "{\tt (,{,}Q)}" at (GQ,C)
+ "{\tt (,{,}L)}" at (GL,C)
+ "{\tt (,{,}P)}" at (GP,C)
+
+.PE
diff --git a/graphics/circuit_macros/doc/Headers.m4 b/graphics/circuit_macros/doc/Headers.m4
new file mode 100644
index 0000000000..a4e1abce3b
--- /dev/null
+++ b/graphics/circuit_macros/doc/Headers.m4
@@ -0,0 +1,37 @@
+.PS
+# Headers.m4
+log_init
+
+ Header
+ {"\sl P1" at last [].P1 rjust
+ `"\tt Header"' at last [].s+(0,-10pt__)
+ "\sl P2" at last [].P2 rjust}
+
+ Header(2,3,8mm__,10mm__) with .nw at last [].ne+(0.75,-0.05)
+ {"\sl P1" at last [].P1 rjust
+ `"\tt Header(2,3,8mm\_\_,10mm\_\_)"' at last [].s+(0,-10pt__)
+ "\sl P2" at last [].P2 ljust
+ "\sl P5" at last [].P5 rjust
+ "\sl P6" at last [].P6 ljust}
+
+ left_
+ Header(2,4,,,fill_(0.9)) with .sw at last [].se+(0.75,0)
+ {"\sl P1" at last [].P1 rjust_
+ `"\tt left\_; Header(2,4,{,},fill\_(0.9))"' at last [].s+(0,-20pt__)
+ "\sl P8" at last [].P8 ljust_}
+
+ down_
+ Header(2,8) with .nw at last [].ne+(0.75,0)
+ {"\sl P1" at last [].P1 ljust
+ "\sl P2" at last [].P2 ljust
+ `"\tt down\_; Header(2,8)" ' at last [].s+(0,-10pt__)
+ "\sl P15" at last [].P15 rjust
+ "\sl P16" at last [].P16 rjust}
+ {thinlines_
+ arrow <- right 0.15 from last [].PinP1.e
+ `"\sl PinP1"' ljust
+ arrow <- right 0.15 from last [].PinP2.e
+ `"\sl PinP2"' ljust
+ thicklines_ }
+
+.PE
diff --git a/graphics/circuit_macros/doc/HybridPi.m4 b/graphics/circuit_macros/doc/HybridPi.m4
new file mode 100644
index 0000000000..3b89b5ddda
--- /dev/null
+++ b/graphics/circuit_macros/doc/HybridPi.m4
@@ -0,0 +1,54 @@
+.PS
+cct_init
+linewid = linewid*6/6.2435
+command "{\sf"
+# `Point_(degrees)
+# hybrid_PI_BJT([L][M])
+# L=left orientation; M=mirror'
+define(`hybrid_PI_BJT',
+`[ # Size (and direction) parameters:
+ hunit = ifinstr(`$1',M,-)dimen_
+ vunit = ifinstr(`$1',L,-)dimen_*3/2
+ hp_ang = rp_ang # Save the reference direction
+
+ Rpi: resistor(to rvec_(0,-vunit)); point_(hp_ang) # Restore direction
+ DotG: dot(at rvec_(hunit*5/4,0))
+ Gm: consource(to rvec_(0,vunit),I,R); point_(hp_ang) # Restore direction
+ dot(at rvec_(hunit*3/4,0))
+ Ro: resistor(to rvec_(0,-vunit)); point_(hp_ang) # Restore direction
+ line from Rpi.start to Rpi.start+vec_(-hunit/2,0) chop -lthick/2 chop 0
+ Base: dot(,,1)
+ line from Gm.end to Ro.start+vec_(hunit/2,0) chop -lthick/2 chop 0
+ Collector: dot(,,1)
+ line from Rpi.end to Ro.end chop -lthick/2
+ DotE: dot(at 0.5 between Rpi.end and DotG)
+ line to rvec_(0,-vunit/2)
+ Emitter: dot(,,1)
+ # Labels
+ `"$\mathrm{r_\pi}$"' at Rpi.c+vec_(hunit/4,0)
+ `"$ + $"' at Rpi.c+vec_(-hunit/6, vunit/4)
+ `"$ - $"' at Rpi.c+vec_(-hunit/6,-vunit/4)
+ `"$\mathrm{v_\pi}$"' at Rpi.c+vec_(-hunit/4,0)
+ `"$\mathrm{g_m}$$\mathrm{v_\pi}$"' at Gm.c+vec_(-hunit*3/8,-vunit/4)
+ `"$\mathrm{r_o}$"' at Ro.c+vec_(hunit/4,0)
+ `$2' ] ')
+
+[
+Q: hybrid_PI_BJT
+ "Base" at Q.Base +(0.15,0.1)
+ "Emitter" ht 0.1 wid 0.5 at Q.Emitter.w rjust
+ "Collector" ht 0.1 at Q.Collector +(-0.2,0.1)
+ `"hybrid\_PI\_BJT"' ht 0.1 at Q.s+(0,-0.2)
+ hybrid_PI_BJT(M) with .Collector at last [].Collector+(0.15,0)
+ `"hybrid\_PI\_BJT(M)"' ht 0.1 at last [].s+(0,-0.2)
+ hybrid_PI_BJT(LM) with .w at last [].e
+ `"hybrid\_PI\_BJT(LM)"' ht 0.1 at last [].s+(0,-0.2)
+Point_(45)
+ hybrid_PI_BJT with .Emitter at last [].Base+(elen_*1.75,0.1)
+ `"\shortstack[l]{Point\_(45)\\ hybrid\_PI\_BJT}"' \
+ ht 0.25 at last [].s+(0.2,-0.2)
+]
+#print last [].wid
+
+command "}%"
+.PE
diff --git a/graphics/circuit_macros/doc/Jack.m4 b/graphics/circuit_macros/doc/Jack.m4
new file mode 100644
index 0000000000..3c56061e67
--- /dev/null
+++ b/graphics/circuit_macros/doc/Jack.m4
@@ -0,0 +1,78 @@
+.PS
+# `Jack.m4'
+cct_init
+
+P: [
+ P1: plug
+ "\sl A" wid 0.1 at P1.A rjust
+ "\sl B" at P1.B rjust
+ "\sl TB" at P1.TB ljust above
+ "\sl TA" at P1.TA ljust below
+ P2: plug(,R) with .B at P1.A+(0.85,0)
+ "\sl A" wid 0.1 at P2.A rjust
+ "\sl B" at P2.B rjust
+# P3: plug(L) with .A at P2.A+(1,0)
+# "\sl A" wid 0.1 at P3.A ljust
+# "\sl B" at P3.B ljust
+ P4: plug(,3) with .A at P2.B+(0.85,0)
+ "\sl A" at P4.A rjust
+ "\sl B" at P4.B rjust
+ "\sl C" at P4.C rjust
+ P5: plug(L,3R) with .A at P4.A+(1,0)
+ "\sl A" wid 0.1 at P5.A ljust
+ "\sl B" at P5.B ljust
+ "\sl C" at P5.C ljust
+ `"\tt plug"' below at P1.s+(0,-0.1)
+ `"\tt plug(,R)"' below at P2.s+(0,-0.1)
+# `"\tt plug(L)"' below at P3.s+(0,-0.1)
+ `"\tt plug(,3)"' below at P4.s+(-0.1,-0.1)
+ `"\tt plug(L,3R)"' below at P5.s+(0.1,-0.1)
+]
+
+L: [ right_
+ J1: jack
+ thinlines_
+ "\sl L" wid 0.1 rjust at J1.L
+ arrow <- right 0.1 from J1.F; "\sl F" ljust
+ arrow <- down 0.1 from J1.G then left 0.1 ; "\sl G" rjust
+ thicklines_
+ J2:[K2: jack(,LMBS) #with .F at J1.F+(1.2,0)
+ thinlines_
+ "\sl L" rjust at K2.L
+ arrow <- from K2.LM left 0.25; "\sl LM" wid 0.18 rjust
+ arrow <- from K2.LB left 0.25; "\sl LB" rjust
+ "\sl S" rjust at K2.S
+ thicklines_ ] with .K2.F at J1.F+(1.2,0)
+ J3: jack(L,RLS) with .F at J2.K2.F+(0.4,0)
+ thinlines_
+ "\sl L" ljust at J3.L
+ "\sl S" ljust at J3.S
+ thicklines_
+ J4: jack(L,RLBLMLMS) with .F at J3.F+(1.1,0)
+ thinlines_
+ "\sl L1" ljust at J4.L1
+ arrow <- right 0.3 from J4.LM1; "\sl LM1" ljust
+ "\sl L2" ljust at J4.L2
+ arrow <- right 0.3 from J4.LM2; "\sl LM2" wid 0.2 ht 11pt__ ljust
+ "\sl S" ljust at J4.S
+ "\sl L" ljust at J4.L
+ arrow <- right 0.2 from J4.LB ; "\sl LB" ljust
+ right_
+ J5: jack(,RSBSMLB) with .F at J4.F+(1.95,0)
+ thinlines_
+ "\sl L" rjust at J5.L
+ "\sl S" rjust at J5.S
+ "\sl S1" rjust at J5.S1
+ arrow <- left 0.3 from J5.SM1; "\sl SM1" rjust
+ spline 0.5 <- left 0.25 then left 0.1 down 0.05 from J5.LB; "\sl LB" rjust
+ spline 0.5 <- left 0.25 then left 0.1 up 0.05 from J5.SB; "\sl SB" rjust
+ thicklines_
+
+ `"\tt jack"' ht 0.15 below at J1.s+(0,-0.15)
+ `"\tt jack(,LMBS)"' below at (J2,last "")
+ `"\tt ..(L,RLS)"' below at (J3,last "")
+ `"\tt ..(L,RLBLMLMS)"' below at (J4,last "")
+ `"\tt ..(,RSBSMLB)"' below at (J5,last "")
+] with .nw at P.sw + (0,0.1)
+
+.PE
diff --git a/graphics/circuit_macros/doc/Logic.m4 b/graphics/circuit_macros/doc/Logic.m4
new file mode 100644
index 0000000000..d42e02768e
--- /dev/null
+++ b/graphics/circuit_macros/doc/Logic.m4
@@ -0,0 +1,62 @@
+.PS
+# Logic.m4
+cct_init
+ifdef(`AND_gate',,`include(liblog.m4)')
+xgap = 0.6
+[ dmov = 0.4
+{ {AND_gate ; "{\tt AND\_gate}" ljust at last [].w + (xgap,0)}
+ move down dmov; right_
+ {OR_gate ; "{\tt OR\_gate}" ljust at last [].w + (xgap,0)}
+ move down dmov; right_
+ {BUFFER_gate ; "{\tt BUFFER\_gate}" ljust at last [].w + (xgap,0)}
+ move down dmov; right_
+ {XOR_gate ; "{\tt XOR\_gate}" ljust at last [].w + (xgap,0)}
+ }
+
+ move right_ 140pt__
+{ { NAND_gate; "{\tt NAND\_gate}" ljust at last [].w + (xgap,0) }
+ move down dmov; right_
+ { Gate: NOR_gate(3)
+ "{\tt NOR\_gate(3)}" ljust at last [].w + (xgap,0)
+ thinlines_
+ spline <- from Gate.Out right arrowht*2.0 \
+ then up 0.15 then right 0.05
+ "{\tt Out}" ljust
+ spline <- from Gate.N_Out down arrowht*2.0 \
+ then right 0.1+arrowht*1.5+NOT_rad down 0.15-arrowht*2.0
+ "{\tt N\_Out}" ljust
+ for_(1,3,1,
+ `arrow <- left 0.2 down 0.05 from Gate.In`'m4x
+ "{\tt In`'m4x\/}" rjust at Here+(0,(2-m4x)*0.02)')
+ }
+ thicklines_
+ move down dmov; right_
+ { NOT_gate ; "{\tt NOT\_gate}" ljust at last [].w + (xgap,0) }
+ move down dmov; right_
+ {Gate: NXOR_gate(NPN); "{\tt NXOR\_gate(NPN)}" ljust at last [].w + (xgap,0)
+ for_(1,3,1,
+ `arrow <- left 0.2 up 0.05 from Gate.In`'m4x
+ "{\tt In`'m4x\/}" rjust at Here+(0,(2-m4x)*0.02)')
+ }
+}
+ move right_ 140pt__
+{ {NAND_gate(,B) ; "{\tt NAND\_gate(,B)}" ljust at last [].w + (xgap,0)}
+ { line invis right 1.6 from last [].se then down 1}
+ move down dmov; right_
+ move left N_diam*L_unit; right_
+ {NOR_gate(3,NB) ; "{\tt NOR\_gate(3,NB)}" ljust at (last "",last []) }
+ move down dmov; right_
+ {BOX_gate(PN,N,,,=1)
+ "{\tt BOX\_gate(PN,N,{,},=1)}" ljust at (last "",last [])
+ line left 0.15 from last [].In1
+ line left 0.15-NOT_rad*2 from last [].In2
+ line right 0.15 from last [].Out }
+ move down dmov; move right_ N_diam*L_unit
+ {BOX_gate(PP,N,,,=)
+ "{\tt BOX\_gate(PP,N,{,},=)}" ljust at (last "",last [])
+ line left 0.15 from last [].In1
+ line left 0.15 from last [].In2
+ line right 0.15 from last [].Out }
+}
+]
+.PE
diff --git a/graphics/circuit_macros/doc/Loop.m4 b/graphics/circuit_macros/doc/Loop.m4
new file mode 100644
index 0000000000..379d19f299
--- /dev/null
+++ b/graphics/circuit_macros/doc/Loop.m4
@@ -0,0 +1,10 @@
+.PS
+# `Loop.m4'
+cct_init
+define(`dimen_',0.75)
+loopwid = 1; loopht = 0.75
+ source(up_ loopht); llabel(-,v_s,+)
+ resistor(right_ loopwid); llabel(,R,); b_current(i)
+ inductor(down_ loopht,W); rlabel(,L,)
+ capacitor(left_ loopwid,C); llabel(+,v_C,-); rlabel(,C,)
+.PE
diff --git a/graphics/circuit_macros/doc/Makefile b/graphics/circuit_macros/doc/Makefile
new file mode 100644
index 0000000000..a934e20bba
--- /dev/null
+++ b/graphics/circuit_macros/doc/Makefile
@@ -0,0 +1,142 @@
+# The installed library directory, change this if necessary:
+LIBDIR = ..
+
+DOC = Circuit_macros
+DOCSRC = Circuit_macros.tex body.tex defines.tex
+
+PICTEX = \
+ AmpTable.tex Antennas.tex Audio.tex Axes.tex \
+ Buffer.tex BigResistor.tex Bip.tex \
+ CctTable.tex Composite.tex ConfigA.tex ConfigB.tex ConfigC.tex Conn.tex \
+ Corners.tex \
+ Dac.tex Darlington.tex Demultiplexer.tex Diodes.tex \
+ Emarrows.tex FF.tex FlipFlop.tex \
+ Flowdiag.tex Fuses.tex Grounds.tex \
+ Headers.tex HybridPi.tex Jack.tex \
+ Logic.tex Loop.tex Multiplexer.tex NPDT.tex NLG.tex Nport.tex \
+ Oblique.tex Opamp.tex Opto.tex \
+ ParSeries.tex Pconn.tex Potentiometers.tex Relay.tex \
+ Series.tex ShiftR.tex Sinus.tex Sources.tex Switches.tex \
+ Taps.tex Tgate.tex Thermal.tex Tline.tex Ttree.tex \
+ Variable.tex Xform.tex Windings.tex Workflow.tex \
+ bitr.tex bi_trans.tex \
+ bistable.tex currents.tex eboxdims.tex fbfilter.tex fet.tex \
+ lrarrows.tex mplex.tex oax.tex \
+ quick.tex stringdims.tex thyristor.tex ujt.tex woodchips.tex
+
+VERBATIM = BigResistor2.verb eboxdims.verb
+BOXDIMS = Antennas.tex bi_trans.tex ConfigA.tex ConfigB.tex ConfigC.tex \
+ Corners.tex \
+ Dac.tex eboxdims.tex FlipFlop.tex \
+ Opamp.tex ParSeries.tex Sinus.tex stringdims.tex Ttree.tex \
+ Windings.tex woodchips.tex
+# BOXDIMS = $(PICTEX)
+
+LATEX = latex
+M4 = m4 -I $(LIBDIR)
+# If M4PATH has been set:
+M4 = m4
+
+# For gpic
+MODE = gpic
+PIC = gpic -t
+PRE =
+POST = ;printf '\\centerline{\\box\\graph}\n'
+PST =
+
+# For dpic; comment these to stick with gpic.
+MODE = pstricks
+PIC = dpic -p
+# PIC = $$HOME/dpic/test/dpic -p
+# PIC = $$HOME/dpic/p2c/ftp/dpic -p
+PRE =
+POST =
+#POST = ;printf '}%%'
+PST = ;printf '\\usepackage{pstricks}\n' >> heading.tex
+# PST = ;printf '\\usepackage{tikz}\n' >> heading.tex
+
+SFX = dvi
+
+M4LIBS = $(MODE).m4
+.SUFFIXES: .tex .m4
+.m4.tex: $*.m4
+ touch $(DOC).dim
+ $(M4) $(M4LIBS) $(DOC).dim $*.m4 > $*.pic
+ ($(PRE) $(PIC) $*.pic $(POST)) > $*.tex
+
+CMpdf:
+ touch mode.tex
+ -if grep -q tikz mode.tex ; then true ; else \
+ make clean ; printf "\\usepackage{tikz}\n" > mode.tex ; fi
+ make MODE=pgf PIC="dpic -g" LATEX=pdflatex SFX=pdf \
+ POST="; printf '\\\\vspace*{-0.5\\\\baselineskip}\\n'" \
+ $(DOC).pdf
+ chmod 644 $(DOC).pdf
+
+$(DOC).ps:
+ printf "\n $(DOC).ps:\n\n"
+ make MODE=pstricks PIC="dpic -p" LATEX=latex SFX=dvi POST="" $(DOC).dvi
+ dvips -t letter $(DOC) -o
+
+$(DOC).$(SFX): mode.tex citations $(PICTEX)
+ @printf "\n $(DOC).SFX=$(DOC).$(SFX):\n\n"
+ $(LATEX) $(DOC) ; bibtex $(DOC)
+ -@if grep -s "Warning: Reference " $(DOC).log ; then \
+ @printf "\n Warning:\n\n" ; \
+ $(LATEX) $(DOC) ; bibtex $(DOC) ; \
+ elif test ! -f $(DOC).$(SFX) ; then\
+ @printf "\n No file $(DOC).$(SFX)\n\n" ; \
+ $(LATEX) $(DOC) ; bibtex $(DOC) ; fi
+
+citations: mode.tex $(DOC).bbl $(PICTEX)
+ @printf "\n citations:\n\n"
+ $(LATEX) $(DOC) ; bibtex $(DOC)
+ touch citations
+
+$(DOC).bbl: $(DOC).bib $(DOC).aux
+ bibtex $(DOC)
+
+$(DOC).aux: mode.tex $(DOCSRC) heading.tex $(VERBATIM) $(PICTEX)
+ @printf "\n $(DOC).aux:\n\n"
+ $(LATEX) $(DOC) ; bibtex $(DOC)
+ rm -f $(BOXDIMS)
+ make $(BOXDIMS)
+
+mode.tex:
+ -if test "$(MODE)" = "pstricks" ; then \
+ printf "\\usepackage{pstricks}\n" > mode.tex ; else \
+ printf "\\usepackage{tikz}\n" > mode.tex ; fi
+
+heading.tex:
+ printf '\\documentclass{article}\n' > heading.tex
+ printf '\\usepackage{verbatim,url}\n' >> heading.tex
+ printf '\\usepackage{multicol}\n' >> heading.tex
+ printf '\\usepackage{amssymb,boxdims}\n' >> heading.tex $(PST)
+
+oax.tex tran.tex bitr.tex: oax.m4
+ $(M4) $(M4LIBS) $*.m4 > $*.pic
+ $(PIC) $*.pic > $*.tex
+
+pics: $(PICTEX)
+
+BigResistor2.verb: BigResistor.m4
+ ( printf '\\begin{verbatim}\n'; \
+ sed -n '/thinlines/,/PE/p' BigResistor.m4 ;\
+ printf '\\end{verbatim}\n' ) > BigResistor2.verb
+
+eboxdims.verb: eboxdims.m4
+ ( printf '\\begin{verbatim}\n' ; \
+ sed -e '/thinlines/,$$d' eboxdims.m4 ; \
+ printf '.PE\n\\end{verbatim}\n' ) > eboxdims.verb
+
+ex08.m4: ../examples/ex08.m4
+ cp ../examples/ex08.m4 ex08.m4
+
+clobber: clean
+ rm -f *.dvi Circuit_macros.pdf
+# rm -f Circuit_macros.pdf
+
+clean:
+ rm -f *.bbl *.log *.aux *.blg *.toc citations *.verb ex08.m4
+ rm -f *.pic $(PICTEX) heading.tex *.dim *.uu Circuit_macros.ps Circuit_macros.dvi
+ rm -f mode.tex Circuit_macros.out *.upa *.upb *.brf
diff --git a/graphics/circuit_macros/doc/Multiplexer.m4 b/graphics/circuit_macros/doc/Multiplexer.m4
new file mode 100644
index 0000000000..f4b72154a4
--- /dev/null
+++ b/graphics/circuit_macros/doc/Multiplexer.m4
@@ -0,0 +1,43 @@
+.PS
+# `Multiplexer.m4'
+log_init
+
+ ifmpost(`command "verbatimtex {\sf etex"',
+ `ifpostscript(,
+ `command "{\sf"')')
+
+ right_
+
+ Mux(4,M1)
+ `"\tt Mux(4,M1)"' at last [].s below
+ `"\sl In0"' at last [].In0.end rjust wid 14bp__
+ `"\sl In1"' at last [].In1.end rjust
+ `"\sl In2"' at last [].In2.end rjust
+ `"\sl In3"' at last [].In3.end rjust
+ `"\sl Out"' at last [].Out.end above
+ `"\sl Sel"' at last [].Sel.end ljust above
+ left_; Mux(4,,LNOE) with .c at last [].c+(0.9,0)
+ `"\tt left\_; Mux(4,{,}LNOE)"' at last [].s +(0,-20bp__) ht 10bp__
+ `"\sl In0"' at last [].In0.end above
+ `"\sl NOE"' at last [].NOE.end +(4bp__,0) below
+ `"\sl Out"' at last [].Out.end below
+ `"\sl Sel"' at last [].Sel.end rjust below
+ right_; Mux(4,,OEBN2) with .c at last [].c+(1.4,0)
+ `"\tt Mux(4,{,}OEBN2)"' at last [].s below
+ `"\sl Sel0"' at last [].Sel0.end rjust
+ `"\sl Sel1"' at last [].Sel1.end ljust
+ `"\sl In0"' at last [].In0.end rjust
+ `"\sl In3"' at last [].In3.end rjust
+ `"\sl OE"' at last [].OE.end rjust
+ down_; Mux(8,,L3,,28*L_unit) with .c at last [].c+(1.7,0)
+ `"\tt down\_; Mux(8,{,}L3,{,}28*L\_unit)"' at last [].s below
+ `"\sl Sel0"' at last [].Sel0.end rjust
+ `"\sl Sel2"' at last [].Sel2.end rjust below
+ `"\sl In0"' at last [].In0.end rjust
+ `"\sl In7"' at last [].In7.end ljust wid 14bp__
+
+ifmpost(`command "verbatimtex } etex"',
+`ifpostscript(,
+`command "}"')')
+
+.PE
diff --git a/graphics/circuit_macros/doc/NLG.m4 b/graphics/circuit_macros/doc/NLG.m4
new file mode 100644
index 0000000000..2b9a39f86e
--- /dev/null
+++ b/graphics/circuit_macros/doc/NLG.m4
@@ -0,0 +1,19 @@
+.PS
+# NLG.m4
+cct_init
+
+ define(`nullor',`nport(`$1'
+ {`"${}0$"' at Box.w ljust
+ `"$\infty$"' at Box.e rjust},shift($@))')
+
+N: nullor
+`"\tt nullor"' at last [].s+(0,-3pt__) below
+G: gyrator with .sw at N.se+(0.5,0)
+`"\tt gyrator"' at G.s+(0,-3pt__) below
+I: gyrator(invis,,0,N) with .w at G.e+(0.5,0)
+`"\tt gyrator(invis,{,}0,N)"' at I.s
+V: gyrator(invis wid boxht,,0,NV) with .w at I.e+(1,0)
+`"\tt gyrator(invis wid boxht,{,}0,NV)"' at V.s+(0,-3pt__) below
+
+ move right 0.9
+.PE
diff --git a/graphics/circuit_macros/doc/NPDT.m4 b/graphics/circuit_macros/doc/NPDT.m4
new file mode 100644
index 0000000000..17f4ef26b1
--- /dev/null
+++ b/graphics/circuit_macros/doc/NPDT.m4
@@ -0,0 +1,35 @@
+.PS
+# `NPDT.m4'
+cct_init
+ linewid = linewid*1.2
+ movewid = 1.0
+
+ NPDT
+ { `"\sl R" at last [].R.s below
+ "\sl T" at last [].T.s below
+ "\sl L" at last [].L.s below' }
+ { `"\tt NPDT"' at last [].s +(0,-0.22) }
+ up_; NPDT with .L at last[].R+(0.75,0)
+ { `"\sl R"' wid 8pt__ at last [].R.e ljust
+ "\sl T" at last [].T.e ljust
+ "\sl L" at last [].L.e ljust }
+ { `"\tt up\_; NPDT\strut"' at last [].s +(0.1,-0.15) }
+ right_
+ NPDT(2) with .L1 at last [].L+(0.75,0)
+ { for_(1,2,1,
+ `"\sl R`'m4x" at last [].R`'m4x.e ljust
+ "\sl L`'m4x" wid 11pt__ at last [].L`'m4x.w rjust') }
+ { `"\tt NPDT(2)\strut"' at last [].s +(0,-0.15) }
+ move
+ NPDT(3,R) with .L3 at last [].R1+(0.75,0)
+ { for_(1,3,1,
+ `"\sl R`'m4x" at last [].R`'m4x.e ljust
+ "\sl L`'m4x" wid 11pt__ at last [].L`'m4x.w rjust') }
+ { `"\tt NPDT(3,R)\strut"' at last [].s below }
+ left_; NPDT(2,R) with .R1 at last [].R3+(0.75,0)
+ { for_(1,2,1,
+ `"\sl R`'m4x" at last [].R`'m4x.w rjust
+ "\sl L`'m4x" wid 11pt__ at last [].L`'m4x.e ljust') }
+ { `"\tt left\_; NPDT(2,R)\strut"' at last [].s +(0,-0.15) }
+
+.PE
diff --git a/graphics/circuit_macros/doc/Nport.m4 b/graphics/circuit_macros/doc/Nport.m4
new file mode 100644
index 0000000000..37dbffeacc
--- /dev/null
+++ b/graphics/circuit_macros/doc/Nport.m4
@@ -0,0 +1,43 @@
+.PS
+# `Nport.m4'
+cct_init
+textoffset = 5bp__
+
+Twoport: nport
+
+ "\sl W1a" above rjust at Twoport.W1a
+ "\sl W1b" below rjust at Twoport.W1b wid 0.25
+ "\sl E1a" above ljust at Twoport.E1a
+ "\sl E1b" below ljust at Twoport.E1b
+
+Nport: nport(wid 2.0 ht 1 fill_(0.9) "n-port",1,2,3,4) \
+ with .Box.w at Twoport.Box.e+(1.0,0)
+
+ "\sl W1a" rjust at Nport.W1a
+ "\sl W1b" rjust at Nport.W1b
+
+ "\sl E1a" ljust at Nport.E1a
+ "\sl E3b" ljust at Nport.E3b
+
+ "\sl N1a" above at Nport.N1a
+ "\sl N1b$\;\;$" above at Nport.N1b
+ "\sl $\;\;$N2a" above at Nport.N2a
+ "\sl N2b" above at Nport.N2b
+
+ "\sl S1a" below at Nport.S1a
+ "\sl S4b" below at Nport.S4b
+
+ "$\cdots$" at 0.5<Nport.S1a,Nport.S4b>+(0,-0.10)
+ "$\vdots$" at 0.5<Nport.E1a,Nport.E3b>+(0.15,0.05)
+
+Nterm: nterm with .Box.w at Nport.Box.e+(1.0,0)
+ "\sl W1" rjust at Nterm.W1
+ "\sl E1" ljust at Nterm.E1
+ "\sl S1" below at Nterm.S1
+
+ `"\tt nport"' at Twoport.s+(0,-0.3)
+ `"\tt nport(wid 2.0 ht 1 fill\_(0.9) \"n-port\",1,2,3,4)"' \
+ at Nport.s+(0,-0.25)
+ `"\tt nterm"' at Nterm.s+(0,-0.3)
+
+.PE
diff --git a/graphics/circuit_macros/doc/Oblique.m4 b/graphics/circuit_macros/doc/Oblique.m4
new file mode 100644
index 0000000000..c8dfd5fa7a
--- /dev/null
+++ b/graphics/circuit_macros/doc/Oblique.m4
@@ -0,0 +1,25 @@
+.PS
+# `Oblique.m4'
+cct_init
+
+Ct:dot; Point_(-60); capacitor(,C); dlabel(0.12,0.12,,,C_3)
+Cr:dot; left_; capacitor(,C); dlabel(0.12,0.12,C_2,,)
+Cl:dot; down_; capacitor(from Ct to Cl,C); dlabel(0.12,-0.12,,,C_1)
+
+T:dot(at Ct+(0,elen_))
+ inductor(from T to Ct); dlabel(0.12,-0.1,,,L_1)
+
+ Point_(-30); inductor(from Cr to Cr+vec_(elen_,0))
+ dlabel(0,-0.07,,L_3,)
+R:dot
+L:dot( at Cl-(R.x-Cr.x,Cr.y-R.y) )
+
+ inductor(from L to Cl); dlabel(0,-0.12,,L_2,)
+ right_; resistor(from L to R); rlabel(,R_2,)
+ resistor(from T to R); dlabel(0,0.15,,R_3,) ; b_current(y,ljust)
+ line from L to 0.2<L,T>
+ source(to 0.5 between L and T); dlabel(sourcerad_+0.07,0.1,-,,+)
+ dlabel(0,sourcerad_+0.07,,u,)
+ resistor(to 0.8 between L and T); dlabel(0,0.15,,R_1,)
+ line to T
+.PE
diff --git a/graphics/circuit_macros/doc/Opamp.m4 b/graphics/circuit_macros/doc/Opamp.m4
new file mode 100644
index 0000000000..5bdb8ac208
--- /dev/null
+++ b/graphics/circuit_macros/doc/Opamp.m4
@@ -0,0 +1,45 @@
+.PS
+# Opamp.m4
+sinclude(FOpamp.dim)
+sinclude(Circuit_macros.dim)
+s_init(Opamp)
+cct_init
+
+ A: opamp
+ thinlines_
+ s_box(`\tt opam{}p') at A.s-(0,0.35)
+ s_box(\tt Out) below at A.Out
+ spline <- from A.In1 left 0.1 then up 0.1 left 0.1
+ s_box(\tt In1) rjust above
+ spline <- from A.In2 left 0.1 then down 0.1 left 0.1
+ s_box(\tt In2) rjust below
+ arrow <- up 0.1 right 0.1 from A.N
+ s_box(\tt N) ljust above
+ arrow <- up 0.1 right 0.1 from A.E1
+ s_box(\tt E1) ljust above
+ arrow <- up 0.1 right 0.1 from A.E
+ s_box(\tt E) ljust above
+ arrow <- down 0.1 right 0.1 from A.E2
+ s_box(\tt E2) ljust below
+ arrow <- down 0.1 right 0.1 from A.S
+ s_box(\tt S) ljust below
+ arrow <- left 0.2 from A.W
+ s_box(\tt W) rjust
+ thicklines_
+ Point_(15)
+ B: opamp(,,,,PR) with .sw at A.se+(0.65,0)
+ thinlines_
+ s_box(`\tt Point\_(15); opam{}p(,{,},{,}PR)') at B.s-(0,0.20)
+ spline <- right arrowht up arrowht from B.V1 then right 0.1
+ s_box(\tt V1) ljust
+ spline <- right arrowht down arrowht from B.V2 then right 0.1
+ s_box(\tt V2) ljust
+ thicklines_
+ Point_(90)
+ C: opamp with .sw at B.se+(1.05,0)
+ s_box(`\tt Point\_(90); opam{}p') at C.s-(0,0.35)
+ right_
+ D: opamp(,,,,T) with .sw at C.se+(0.65,0)
+ s_box(`\tt opam{}p(,{,},{,}T)') at D.s-(0,0.20)
+
+.PE
diff --git a/graphics/circuit_macros/doc/Opto.m4 b/graphics/circuit_macros/doc/Opto.m4
new file mode 100644
index 0000000000..7cbc4abf08
--- /dev/null
+++ b/graphics/circuit_macros/doc/Opto.m4
@@ -0,0 +1,29 @@
+.PS
+cct_init
+# `opto([R|L][A|B])'
+define(`opto',
+`[{u = dimen_/2
+ Q: bi_trans(up u*2,ifinstr(`$1',R,R),ifinstr(`$1',B,B)CBUdE)
+ E: Q.E; C: Q.C; A:ifinstr(`$1',R,Q.e+(u*3/2,u),Q.w+(-u*3/2,u)); K: A-(0,u*2)
+ ifinstr(`$1',B,line from Q.B to (Q.B,E); B: Here)
+ D: diode(from A to K)
+ arrow from D.c+(0,u/6) to Q.ifinstr(`$1',R,e,w)+(0,u/6) chop u/3 chop u/4
+ arrow from last arrow.start-(0,u/3) to last arrow.end-(0,u/3)
+ Enc: box rad u wid abs(C.x-A.x)+u*2 ht u*2 with .c at 0.5 between C and K
+ `$2' }]')
+
+Q1: opto
+Q2: opto(type=B;orientation=Rightleft) with .w at Q1.e+(dimen_,0)
+
+{"\sl C" at Q1.C above}
+{"\sl C" at Q2.C above}
+{"\sl A" at Q1.A above}
+{"\sl A" at Q2.A above}
+{"\sl E" at Q1.E below}
+{"\sl E" at Q2.E below}
+{"\sl K" at Q1.K below}
+{"\sl K" at Q2.K below}
+{"\sl B" at Q2.B below}
+
+.PE
+
diff --git a/graphics/circuit_macros/doc/ParSeries.m4 b/graphics/circuit_macros/doc/ParSeries.m4
new file mode 100644
index 0000000000..7becb98528
--- /dev/null
+++ b/graphics/circuit_macros/doc/ParSeries.m4
@@ -0,0 +1,56 @@
+.PS
+# ParSeries.m4
+sinclude(tst.dim)
+sinclude(Circuit_macros.dim)
+s_init(ParSeries)
+cct_init
+
+command "\newcommand{\X}{\enskip}"
+
+setdir_(R)
+Ex1: [
+P:parallel_(
+ `L:inductor(,W); llabel(+,L,-)',
+ series_(`R1:resistor; llabel(,R1)',`R2:resistor; llabel(,R2)'),
+ `C:capacitor; llabel(,C)' )
+ dot(at P.Start); "{\small\sl Start}" at rvec_(0,-3pt__) below ljust
+ dot(at P.End); "{\small\sl End}" below ljust
+ ]
+#showbox_
+
+s_box(``\shortstack[l]{
+\tt parallel\_( \char96 L:inductor(,W); llabel(+,L,-)\char39,\\
+\X\tt series\_(\char96 R1:resistor; llabel(,R1)\char39,
+\char96 R2:resistor; llabel(,R2)\char39),\\
+\X\tt \char96 C:capacitor; llabel(,C)\char39\ )}'') with .nw at Ex1.sw+(0,-0.2)
+#showbox_(last "")
+
+setdir_(Down)
+Ex2: [
+P: parallel_(
+ series_(
+ `R1:resistor; rlabel(,R_1)',
+ parallel_(
+ series_(`resistor; rlabel(,R_2)',`inductor(,W); rlabel(,L)'),
+ `capacitor(,C); rlabel(,C)' ),
+ line down dimen_/2 ),
+ `Sep=linewid*3/2; V:source; rlabel(+,V,-)' )
+ dot(at P.Start); "{\small\sl Start}" below
+ dot(at P.End); "{\small\sl End}" below
+ ] with .sw at Ex1.se+(0.3,0)
+#showbox_
+
+s_box(``\shortstack[l]{\tt setdir\_(Down)\\
+\tt parallel\_(\\
+\X\tt series\_(\char96 R1:resistor; rlabel(,R\_1)\char39,\\
+\X\X\tt parallel\_(\\
+\X\X\X\tt series\_(\char96 resistor; rlabel(,R\_2)\char39,\\
+\X\X\X\tt\hphantom{\tt series\_(}%
+\char96{}inductor(,W); rlabel(,L)\char39),\\
+\X\X\X\tt \char96 capacitor(,C); rlabel(,C)\char39\ ),\\
+\X\X\tt line down dimen\_/2),\\
+\X\tt \char96 Sep=linewid*3/2; V:source; rlabel(+,V,-)\char39)}
+'') with .nw at Ex2.ne+(0.15,0)
+#showbox_(last "")
+
+.PE
diff --git a/graphics/circuit_macros/doc/Pconn.m4 b/graphics/circuit_macros/doc/Pconn.m4
new file mode 100644
index 0000000000..946ec0fda6
--- /dev/null
+++ b/graphics/circuit_macros/doc/Pconn.m4
@@ -0,0 +1,50 @@
+.PS
+# `Pconn.m4'
+cct_init
+
+P1: [
+ C1: pconnex(,A)
+ thinlines_
+ arrow <- left 0.2 from C1.H.w; `"\sl H"' rjust
+ thicklines_
+ `"\tt pconnex(,A)"' at last [].s below
+ C2: pconnex(,AF) with .w at C1.e+(0.3,0)
+ thinlines_
+ arrow <- right 0.2 up 0.1 from C2.H.e; `"\sl H"' ljust
+ N: box invis wid (C2.w.x-C1.e.x)/2 ht C1.N.ht \
+ with .n at 0.5 between C1.ne and C2.nw "\sl N"
+ arrow from N.w to C1.N.e
+ arrow from N.e to C2.N.w
+ G: box invis wid N.wid ht N.ht with .n at (N,C1.N.s) "\sl G"
+ arrow from G.w to C1.G.e
+ arrow from G.e to C2.G.w
+ `"\tt (,AF)"' at last [].s below
+ C03: pconnex(,AC) with .w at C2.e+(0.2,0)
+ `"\tt (,AC)"' at last [].s below
+ C3: pconnex(,ACF) with .w at last [].e+(0.2,0)
+ `"\tt (,ACF)"' at last [].s below
+
+ C4: pconnex(,P) with .w at last [].e+(0.2,0)
+ `"\tt (,P)"' at (C4,last "") below
+ C5: pconnex(U,D) with .w at last [].e+(0.2,0)
+ `"\tt (U,D)"' at last [].s below
+ C6: pconnex(U,DF) with .w at last [].e+(0.2,0)
+ `"\tt (U,DF)"' at last [].s below
+ C7: pconnex(U,J) with .w at last [].e+(0.2,0)
+ `"\tt (U,J)"' at last [].s below
+ C8: pconnex(U,JF) with .w at last [].e+(0.2,0)
+ `"\tt (U,JF)"' at last [].s below
+ ]
+
+P2: [
+ C9: pconnex(,G)
+ `"\tt (,G)"' at last [].s below
+ C91: pconnex(,GF) with .w at last [].e+(0.2,0)
+ `"\tt (,GF)"' at last [].s below
+ C92: pconnex(L,GF) with .w at last [].e+(0.2,0)
+ `"\tt (L,GF)"' at last [].s below
+ C10: pconnex(,GC) with .w at last [].e + (0.2,0)
+ `"\tt (,GC)"' ht 11pt__ at last [].s below
+] with .nw at P1.C1.sw + (0,-0.25)
+
+.PE
diff --git a/graphics/circuit_macros/doc/Potentiometers.m4 b/graphics/circuit_macros/doc/Potentiometers.m4
new file mode 100644
index 0000000000..99a6b1fdac
--- /dev/null
+++ b/graphics/circuit_macros/doc/Potentiometers.m4
@@ -0,0 +1,27 @@
+.PS
+# `Potentiometers.m4'
+cct_init
+
+ down_
+ P: potentiometer(down_ dimen_)
+ "\tt `potentiometer'(down\_ dimen\_)" wid 1.9 at P.End +(0,-0.30)
+ "\sl Start" ljust at P.Start
+ "\sl End" ljust at P.End
+ "\sl T1" below ljust at P.T1
+
+ R: potentiometer(down_ dimen_,,0.5,-5mm__) \
+ with .Start at P.Start + (1.7,0)
+ "\tt ...(down\_ dimen\_,{,}0.5,-5mm\_\_)" at R.End +(0,-0.12)
+ "\sl Start" ljust at R.Start
+ "\sl End" ljust at R.End
+ "\sl T1" below rjust at R.T1
+
+ Q: potentiometer(down_ dimen_,,0.25,-5mm__,0.75,5mm__) \
+ with .Start at R.Start + (1.7,0)
+ "\tt ...(down\_ dimen\_,{,}0.25,-5mm\_\_,0.75,5mm\_\_)" at Q.End+(0,-0.30)
+ "\sl Start" ljust at Q.Start
+ "\sl End" ljust at Q.End
+ "\sl T1" below rjust at Q.T1
+ "\sl T2" below ljust at Q.T2
+
+.PE
diff --git a/graphics/circuit_macros/doc/Relay.m4 b/graphics/circuit_macros/doc/Relay.m4
new file mode 100644
index 0000000000..ee52fa4994
--- /dev/null
+++ b/graphics/circuit_macros/doc/Relay.m4
@@ -0,0 +1,84 @@
+.PS
+# Relay.m4
+cct_init
+
+movw = 0.85
+{contact
+ {`"\tt contact"' at last [].s+(0,-0.2)
+ "\sl P" rjust at last [].P.w
+ "\sl O" ljust at last [].O
+ "\sl C" ljust at last [].C }
+ move right_ movw; contact(R,)
+ {`"\tt contact(,R)"' at last [].s+(0,-0.2)
+ "\sl P" rjust at last [].P.w
+ "\sl O" ljust at last [].O
+ "\sl C" ljust at last [].C }
+ move right_ movw; contact(P)
+ {`"\tt contact(P)"' at last [].s+(0,-0.2)
+ "\sl P" rjust at last [].P.w
+ "\sl O" ljust at last [].O
+ "\sl C" ljust at last [].C }
+ move right_ movw; contact(O,); {`"\tt contact(O,)"' at last [].s+(0,-0.2)}
+ move right_ movw; contact(C,); {`"\tt contact(C,)"' at last [].s+(0,-0.2)}
+#move right_ movw; reed; {`"\tt reed"' at last [].s+(0,-0.2)}
+}
+move down 0.8
+right_
+{contact(I)
+ {`"\tt contact(I)"' at last [].s+(0,-0.2)
+ "\sl P" rjust at last [].P.w
+ "\sl O" ljust at last [].O.e
+ "\sl C" ljust at last [].C.e }
+ move right_ movw; contact(RI)
+ {`"\tt contact(RI)"' at last [].s+(0,-0.2)
+ "\sl P" rjust at last [].P.w
+ "\sl O" ljust at last [].O.e
+ "\sl C" ljust at last [].C.e }
+ move right_ movw; contact(PI)
+ {`"\tt contact(PI)"' at last [].s+(0,-0.2)
+ "\sl P" rjust at last [].P.w
+ "\sl O" ljust at last [].O.e
+ "\sl C" ljust at last [].C.e }
+ move right_ movw; contact(OI); {`"\tt contact(OI)"' at last [].s+(0,-0.2)}
+ move right_ movw; contact(CI); {`"\tt contact(CI)"' at last [].s+(0,-0.2)}
+#move right_ movw; reed(,,,fill_(0.9),CR);
+# {`"\shortstack[l]{\tt reed(\\\tt$\;\;$,{,},fill\_(0.9),CR)}"' \
+# at last [].s+(0,-0.2)}
+}
+move down 1.2
+right_
+{
+relay
+ {"\sl V1" wid 0.16 rjust at last [].V1
+ "\sl V2" ljust at last [].V2
+ "\sl P1" rjust at last [].P1.w
+ "\sl O1" ljust at last [].O1
+ "\sl C1" ljust at last [].C1 }
+`"\tt relay"' at last [].s+(0,-0.2)
+relay(2) with .sw at last [].sw+(1.2,0)
+ {"\sl V1" rjust at last [].V1
+ "\sl V2" ljust at last [].V2
+ "\sl P1" rjust at last [].P1.w
+ "\sl O1" ljust at last [].O1
+ "\sl C1" ljust below at last [].C1
+ "\sl P2" rjust at last [].P2.w
+ "\sl O2" ljust at last [].O2
+ "\sl C2" ljust at last [].C2 }
+`"\tt relay(2)"' at last [].s+(0,-0.2)
+relay(2,RPI) with .sw at last [].sw+(1.2,0)
+ {"\sl V1" rjust at last [].V1
+ "\sl V2" ljust at last [].V2
+ "\sl P1" rjust at last [].P1.w
+ "\sl O1" ljust at last [].O1
+ "\sl C1" ljust at last [].C1+(0,2pt__)
+ "\sl P2" rjust at last [].P2.w
+ "\sl O2" ljust at last [].O2+(0,-2pt__)
+ "\sl C2" ljust at last [].C2 }
+`"\tt relay(2,RIP)"' at last [].s+(0,-0.2)
+relay(2,O) with .sw at last [].sw+(1.2,0)
+`"\tt relay(2,O)"' at last [].s+(0,-0.2)
+relay(2,CT) with .sw at last [].sw+(1.2,0)
+`"\tt relay(2,CT)"' at last [].s+(0,-0.2)
+}
+
+.PE
diff --git a/graphics/circuit_macros/doc/Series.m4 b/graphics/circuit_macros/doc/Series.m4
new file mode 100644
index 0000000000..6fb5321dd2
--- /dev/null
+++ b/graphics/circuit_macros/doc/Series.m4
@@ -0,0 +1,24 @@
+.PS
+# Series.m4
+cct_init
+
+[
+ setdir_(Right)
+ resistor; llabel(,R); capacitor; llabel(,C);
+ inductor; llabel(,L)
+]
+[
+
+ pushdef(`elen_',dimen_)
+ resistor; llabel(,R); capacitor; llabel(,C);
+ inductor; llabel(,L)
+ popdef(`elen_')
+] with .nw at last [].sw + (0,-0.15)
+
+[
+ resistor; llabel(,R)
+ capacitor( right_ dimen_/4); llabel(,C)
+ inductor; llabel(,L)
+] with .nw at last [].sw + (0,-0.15)
+
+.PE
diff --git a/graphics/circuit_macros/doc/ShiftR.m4 b/graphics/circuit_macros/doc/ShiftR.m4
new file mode 100644
index 0000000000..e7bf1f0c5c
--- /dev/null
+++ b/graphics/circuit_macros/doc/ShiftR.m4
@@ -0,0 +1,49 @@
+.PS
+# ShiftR.m4
+log_init
+
+ iflatex(`textoffset = 1bp__; ifpsfrag(,`latexcommand({\sf)') ')
+
+define(`lg_plen',3)
+
+define(`customFF',`FlipFlopX(wid 10*L_unit ht FF_ht*L_unit,,
+ :S;NE:CK;:R, N:PR, :Q;;ifelse(`$1',1,:lg_bartxt(Q)), N:CLR) ')
+
+ F0: customFF(1)
+
+ BUFFER_gate(,N) with .Out at F0.W1.end
+ line left 2*L_unit from last [].In1
+ T: dot
+ reversed(`NOT_gate',left 10*L_unit)
+ Serial: "\scriptsize\shortstack[r]{SERIAL\\ INPUT}" rjust
+ line from T to (T,F0.W3) then to F0.W3.end
+
+ NCLR: NOT_gate(right T.x-Serial.x from (Serial,F0.S1.end),N)
+ "$\overline{\hbox{\scriptsize CLEAR}}$" at NCLR.start rjust
+
+ CLK: NOT_gate(right T.x-Serial.x from NCLR.start+(0,-BUF_ht*3/2*L_unit))
+ "\scriptsize CLOCK" at CLK.start rjust
+
+for_(1,4,1,`
+ F`'m4x: customFF(eval(m4x!=4)) with .W3.end at F`'eval(m4x-1).E3.end
+ ')
+
+ "\scriptsize OUTPUT" at F4.E1.end ljust
+ line from NCLR.end to F4.S1.end
+
+ down_
+for_(0,4,1,`
+ line from F`'m4x.W2.end down F0.W2.y-CLK.y
+ ifelse(eval(m4x!=4),1,`dot',`line to CLK.end')
+ N`'m4x: NAND_gate with .Out at F`'m4x.N1.end
+ line up 2*L_unit from N`'m4x.In2
+ { line up 6*L_unit from N`'m4x.In1
+ "\scriptsize PR`'eval(4-m4x)" rjust }
+ ifelse(eval(m4x!=4),1,
+ `dot; dot(at F`'m4x.S1.end)',
+ `line to (Serial,Here)
+ "\scriptsize\shortstack[r]{PRESET\\ ENABLE}" wid 0.4 rjust ')
+ ')
+
+ iflatex(ifpsfrag(,`latexcommand(})'))
+.PE
diff --git a/graphics/circuit_macros/doc/Sinus.m4 b/graphics/circuit_macros/doc/Sinus.m4
new file mode 100644
index 0000000000..242707d112
--- /dev/null
+++ b/graphics/circuit_macros/doc/Sinus.m4
@@ -0,0 +1,18 @@
+.PS
+# Sinus.m4
+cct_init
+s_init(Sinus)
+sinclude(tst.dim)
+sinclude(Circuit_macros.dim)
+
+define(`phsource',`source($1,
+#`Set angle to 0, draw sinusoid, restore angle'
+ m4smp_ang = rp_ang; rp_ang = 0
+ sinusoid(m4h/2,twopi_/(m4h),
+ ifelse(`$2',,,`($2)/360*2*pi_+')pi_/2,-m4h/2,m4h/2) with .Origin at Here
+ rp_ang = m4smp_ang,
+$3,$4,$5)')
+
+phsource(,120)
+s_box(`{\tt phsourc{}e(,120)}') with .e at last line.end+(0,-0.2)
+.PE
diff --git a/graphics/circuit_macros/doc/Sources.m4 b/graphics/circuit_macros/doc/Sources.m4
new file mode 100644
index 0000000000..a70cea1113
--- /dev/null
+++ b/graphics/circuit_macros/doc/Sources.m4
@@ -0,0 +1,56 @@
+.PS
+# `Sources.m4'
+cct_init
+divert(-1)
+
+divert(0)dnl
+
+iflatex(`ifpsfrag(,`latexcommand({\sf)') ')
+
+movewid = 2pt__
+moveht = 0.275
+define(`NL',`; move down $1; right_')
+{
+ {source ; move ; "`source'" ljust} NL
+ {source(,I) ; move ; "`source(,I)'" ljust} NL
+ {source(,i) ; move ; "`source(,i)'" ljust} NL
+ {source(,V) ; move ; "`source(,V)'" ljust} NL
+ {source(,v) ; move ; "`source(,v)'" ljust} NL
+ {source(,SC) ; move ; "`source(,SC)'" ljust} NL
+ {source(,AC); move ; "`source(,AC)'" ljust} NL
+ {source(,X) ; move ; "`source(,X)'" ljust} NL
+ {source(,F) ; move ; "`source(,F)'" ljust} NL
+ {source(,G) ; move ; "`source(,G)'" ljust} NL
+ {source(,Q) ; move ; "`source(,Q)'" ljust}
+}
+ move right_ 2.0
+{
+ {source(,,0.4) ; move ; "`source(,{,}0.4)'" ljust} NL(0.35)
+ {source(,P) ; move ; "`source(,P)'" ljust} NL
+ {source(,U) ; move ; "`source(,U)'" ljust} NL
+ {source(,H) ; move ; "`source(,H)'" ljust} NL
+ {source(,R) ; move ; "`source(,R)'" ljust} NL
+ {source(,S) ; move ; "`source(,S)'" ljust} NL
+ {source(,SCr) ; move ; "`source(,SCr)'" ljust} NL
+ {source(,T) ; move ; "`source(,T)'" ljust} NL
+ {source(,L) ; move ; "`source(,L)'" ljust} NL
+ {source(,B) ; move ; "`source(,B)'" ljust} NL(moveht*0.8)
+ {nullator ; move ; "`nullator'" ljust} NL(moveht*0.6)
+ {norator ; move ; "`norator'" ljust}
+}
+ move right_ 2.0
+ {source(,N) ; move ; "`source(,N)'" ljust} NL
+ {source(,"\rm mA");move; "`source(,\"mA\")'" ljust} NL(0.31)
+# {source(,"mA");move; "`source(,'" ljust \
+# "`\enskip \"mA\")'" ljust} NL(0.31)
+ {consource ; move ; "`consource'" ljust} NL(0.32)
+ {consource(,I) ; move ; "`consource(,I)'" ljust} NL(0.32)
+ {consource(,i) ; move ; "`consource(,i)'" ljust} NL(0.32)
+ {source(,SE) ; move ; "`source(,SE)'" ljust} NL
+ {consource(,V) ; move ; "`consource(,V)'" ljust} NL(0.32)
+ {consource(,v) ; move ; "`consource(,v)'" ljust} NL(0.3)
+ {battery ; move ; "`battery'" ljust} NL
+ {battery(,3,R) ; move ; "`battery(,3,R)'" ljust}
+
+iflatex(`ifpsfrag(,`latexcommand(})')')
+.PE
diff --git a/graphics/circuit_macros/doc/Switches.m4 b/graphics/circuit_macros/doc/Switches.m4
new file mode 100644
index 0000000000..03218d4ab5
--- /dev/null
+++ b/graphics/circuit_macros/doc/Switches.m4
@@ -0,0 +1,99 @@
+.PS
+# Switches.m4
+cct_init
+movewid = 0.25
+moveht = moveht*1.25
+ right_; {
+ lswitch; rlabel(,`\hbox{\tt `lswitch'}')
+ move right_
+ lswitch(,,O); rlabel(,`\hbox{\tt (,{,}O)}')
+ move right_
+ lswitch(,,C); rlabel(,`\hbox{\tt (,{,}C)}')
+ move right_
+ lswitch(,,DA); rlabel(,`\hbox{\tt (,{,}DA)}')
+ move right_
+ lswitch(,,DO); rlabel(,`\hbox{\tt (,{,}DO)}')
+ move right_
+ lswitch(,,DC); rlabel(,`\hbox{\tt (,{,}DC)}')
+ }
+ move down; right_; {
+ lswitch(,,K); rlabel(,`\hbox{\tt (,{,}K)}')
+ move right_
+ lswitch(,,KD); rlabel(,`\hbox{\tt (,{,}KD)}')
+ move right_
+ lswitch(,,KOD); rlabel(,`\hbox{\tt (,{,}KOD)}')
+ move right_
+ lswitch(,,KCD); rlabel(,`\hbox{\tt (,{,}KCD)}')
+ move right_
+ bswitch; rlabel(,`\hbox{\tt `bswitch'}')
+ move right_
+ bswitch(,,C); rlabel(,`\hbox{\tt (,{,}C)}')
+ }
+ move down; right_; {
+ S: dswitch(,,)
+ ifgpic(`{[line invis] at S.c+(0,-0.2)}')
+ rlabel(,`\hbox{\tt \shortstack{`dswitch'=\\`switch'(,{,},D)}}')
+ thinlines_
+ { spline <- from 0.25 along_(S) up 0.1 then up 0.05 left 0.1
+ "\tt W" rjust
+ spline <- from S.c+(0,m4sc*2) up 0.1 then up 0.05 left 0.1
+ "\tt B" rjust }
+ thicklines_
+ move right_
+ S: dswitch(,,WdBK); rlabel(,`\hbox{\tt (,{,}WdBK)}')
+ thinlines_
+ { spline <- from tr_xy(0,-2) up 0.1 then up 0.10 left 0.1
+ "\tt dB" rjust
+ spline <- from tr_xy(4,-2) right 0.1 then right 0.05 up 0.15
+ "\tt K" above }
+ thicklines_
+ move right_
+ dswitch(,,WBuD); rlabel(,`\hbox{\tt (,{,}WBuD)}')
+ move right_
+ dswitch(,,WdBKF); rlabel(,`\hbox{\tt (,{,}WdBKF)}')
+ move right_
+ dswitch(,,WBL); rlabel(,`\hbox{\tt (,{,}WBL)}')
+ move right_
+ dswitch(,,WdBKL); rlabel(,`\hbox{\tt (,{,}WdBKL)}')
+ }
+ move down; right_; {
+ dswitch(,,WBT); rlabel(,`\hbox{\tt (,{,}WBT)}')
+ move right_
+ dswitch(,,WdBKC); rlabel(,`\hbox{\tt (,{,}WdBKC)}')
+ move right_
+ dswitch(,,WBM); rlabel(,`\hbox{\tt (,{,}WBM)}')
+ move right_
+ dswitch(,,WBCO); rlabel(,`\hbox{\tt (,{,}WBCO)}')
+ move right_
+ dswitch(,,WBMP); rlabel(,`\hbox{\tt (,{,}WBMP)}')
+ move right_
+ dswitch(,,WBoKCP); rlabel(,`\hbox{\tt (,{,}WBoKCP)}')
+ }
+ move down; right_; {
+ dswitch(,,WBCY); rlabel(,`\hbox{\tt (,{,}WBCY)}')
+ move right_
+ dswitch(,,WBCZ); rlabel(,`\hbox{\tt (,{,}WBCZ)}')
+ move right_
+ dswitch(,,WBCE); rlabel(,`\hbox{\tt (,{,}WBCE)}')
+ move right_
+ dswitch(,,WBRH); rlabel(,`\hbox{\tt (,{,}WBRH)}')
+ move right_
+ dswitch(,,WBRdH); rlabel(,`\hbox{\tt (,{,}WBRdH)}')
+ move right_
+ dswitch(,,WBRHH); rlabel(,`\hbox{\tt (,{,}WBRHH)}')
+ }
+ move down; right_; {
+ dswitch(,,WBMMR); rlabel(,`\hbox{\tt (,{,}WBMMR)}')
+ move right_
+ dswitch(,,WBMM); rlabel(,`\hbox{\tt (,{,}WBMM)}')
+ move right_
+ dswitch(,,WBMR); rlabel(,`\hbox{\tt (,{,}WBMR)}')
+ move right_
+ dswitch(,,WBEL); rlabel(,`\hbox{\tt (,{,}WBEL)}')
+ move right_
+ dswitch(,,WBLE); rlabel(,`\hbox{\tt (,{,}WBLE)}')
+ move right_
+ dswitch(,,WdBoKEL); rlabel(,`\hbox{\tt (,{,}WdBoKEL)}')
+ }
+
+.PE
diff --git a/graphics/circuit_macros/doc/Taps.m4 b/graphics/circuit_macros/doc/Taps.m4
new file mode 100644
index 0000000000..7b8797d035
--- /dev/null
+++ b/graphics/circuit_macros/doc/Taps.m4
@@ -0,0 +1,43 @@
+.PS
+# `Taps.m4'
+cct_init
+
+ t = 0.2 in__
+ right_
+ R1: resistor(,,E); addtaps(<-,0.2,-t,0.8,t)
+ "\sl R1.start" wid 0.5 ht 11pt__ at R1.start above
+ "\sl R1.end" at R1.end above
+ "\sl Tap1" at Tap1 rjust
+ "\sl Tap2" at Tap2 ljust
+ `"\tt right\_; t = 0.2in\_\_" ljust \
+ "\tt R1:$\;$resistor(,{,}E)" ljust \
+ "\tt addtaps(<-,0.2,-t,0.8,t)" ljust' at R1.end+(0.3,0)
+
+ move to R1.end+(2.25,0.1); right_
+ R2: ebox(,elen_*0.6,)
+ addtaps(type=-;name=Tx,0.2,-t,0.5,-t,0.8,-t)
+ "\sl Tx1" at Tx1 rjust
+ "\sl Tx3" at Tx3 ljust
+ `"\tt R2:$\;$ebox(,elen\_*0.6)" ljust \
+ "\tt addtaps(type=-;name=Tx," ljust \
+ "\tt \hspace*{0.2in}0.2,-t,0.5,-t,0.8,-t)" ljust ' at R2.end+(0.1,-0.15)
+
+ R3: tapped(`ebox(,elen_*0.6,)',->,0.2,-t,0.5,-t,0.8,-t) \
+ with .Start at R1.start+(0.25in__,-0.6in__)
+ "\sl R3.Start" at R3.Start rjust
+ "\sl R3.End" at R3.End ljust
+ "\sl R3.Tap1" at R3.Tap1 rjust
+ "\sl R3.Tap3" at R3.Tap3 ljust
+ `"\tt \
+ R3:$\;$tapped(`ebox(,elen\_*0.6,)',->,0.2,-t,0.5,-t,0.8,-t) \char92" ljust \
+ "\tt $\;$ with .Start at R1.start+(0.25in\_\_,-0.6in\_\_)" ljust' \
+ at R3.End+(0.5,0)
+
+ L1: tapped(`inductor(right_ 9*dimen_/8,,9)',
+ -,0,-t,3/9,-t/2,6/9,-t/2,1,-t) at R3+(0,-0.6)
+ `"\tt L1:$\;$tapped(`inductor(right\_ 9*dimen\_/8,{,}9)'," ljust' \
+ `"\hspace*{0.5in}\tt -,0,-t,3/9,-t/2,6/9,-t/2,1,-t)" ljust' at (last "",L1)
+ "\sl L1.Tap1" at L1.Tap1-(10pt__,0) below
+ "\sl L1.Tap4" at L1.Tap4+(10pt__,0) below
+
+.PE
diff --git a/graphics/circuit_macros/doc/Tgate.m4 b/graphics/circuit_macros/doc/Tgate.m4
new file mode 100644
index 0000000000..ff42cecb8d
--- /dev/null
+++ b/graphics/circuit_macros/doc/Tgate.m4
@@ -0,0 +1,50 @@
+.PS
+# Tgate.m4
+cct_init
+right_
+
+[ { Q: tgate
+ "$A$" at Q.A rjust
+ "$B$" at Q.B ljust
+ "$G$" at Q.G ljust below
+ "$Gb$" at Q.Gb ljust above
+ `"\tt tgate"' at Q.A-(0.25,0) rjust
+ }
+
+ move down_ linewid; right_
+ { Q: tgate(,L)
+ "$A$" at Q.A rjust
+ "$B$" at Q.B ljust
+ "$G$" at Q.G ljust above
+ "$Gb$" at Q.Gb ljust below
+ `"\tt tgate(,L)"' wid 0.65 at Q.A-(0.25,0) rjust
+ }
+ ]
+
+[ { Q: tgate(,B)
+ "$A$" at Q.A rjust
+ "$B$" at Q.B ljust
+ "$G$" at Q.G ljust
+ `"\tt tgate(,B)"' at Q.G-(0,10bp__) below
+ }
+ ] with .Q.A at last [].Q.B+(0.5,linewid/2)
+
+[ { Q: ptrans
+ "$A$" at Q.A rjust
+ "$B$" at Q.B ljust
+ "$G$" at Q.G rjust below
+ "$Gb$" at Q.Gb rjust
+ `"\tt ptrans"' at Q.B+(0.25,0) ljust
+ }
+
+ move down_ linewid; right_
+ { Q: ptrans(,L)
+ "$A$" at Q.A rjust
+ "$B$" at Q.B ljust
+ "$G$" at Q.G ljust above
+ "$Gb$" at Q.Gb ljust below
+ `"\tt ptrans(,L)"' at Q.B+(0.25,0) ljust
+ }
+ ] with .Q.Gb at (last [].e.x+elen_/2+0.5,1st [].Q.Gb.y)
+
+.PE
diff --git a/graphics/circuit_macros/doc/Thermal.m4 b/graphics/circuit_macros/doc/Thermal.m4
new file mode 100644
index 0000000000..6feffc3680
--- /dev/null
+++ b/graphics/circuit_macros/doc/Thermal.m4
@@ -0,0 +1,8 @@
+.PS
+# Thermal.m4
+cct_init
+define(`thermalsw',
+ `dswitch(`$1',`$2',WDdBT)
+ circle rad distance(M4T,last line.c) at last line.c')
+thermalsw
+.PE
diff --git a/graphics/circuit_macros/doc/Tline.m4 b/graphics/circuit_macros/doc/Tline.m4
new file mode 100644
index 0000000000..eed6106c07
--- /dev/null
+++ b/graphics/circuit_macros/doc/Tline.m4
@@ -0,0 +1,23 @@
+.PS
+# `Tline.m4'
+cct_init
+hgt = elen_*1.5
+ewd = dimen_*0.9
+define(`sresistor',`resistor(right_ ewd); llabel(,r)')
+define(`sinductor',`inductor(right_ ewd,W); llabel(,L)')
+define(`tsection',`sinductor
+ { dot; line down_ hgt*0.25; dot
+ parallel_(`resistor(down_ hgt*0.5); rlabel(,R)',
+ `capacitor(down_ hgt*0.5); rlabel(,C)')
+ dot; line down_ hgt*0.25; dot }
+ sresistor ')
+
+SW: Here
+ gap(up_ hgt)
+ sresistor
+ for i=1 to 4 do { tsection }
+ line dotted right_ dimen_/2
+ tsection
+ gap(down_ hgt)
+ line to SW
+.PE
diff --git a/graphics/circuit_macros/doc/Ttree.m4 b/graphics/circuit_macros/doc/Ttree.m4
new file mode 100644
index 0000000000..6cf9203b00
--- /dev/null
+++ b/graphics/circuit_macros/doc/Ttree.m4
@@ -0,0 +1,56 @@
+.PS
+# Ttree.m4
+# A binary tree using m4
+gen_init
+sinclude(tst.dim)
+s_init(Ttree)
+
+# `Node(no in row, head [location],
+# displacement of top of body (.n) wrt head,
+# body Node 1, body Node 2, ...) '
+define(`Node',`
+ Head`$1': `$2'
+ ifelse(`$3',,,`Body`$1': [
+ Loopover_(`v',`v; define(`m4ct',m4Lx)',shift(shift(shift($@))))
+ ] with .n at Head`$1' + `$3'
+ connect(`$1',m4ct)')')
+
+define(`connect',`Bot: move from Head$1.sw to Head$1.se
+for_(1,`$2',1,
+ `Top: move from Body$1.Head`'m4x.nw to Body$1.Head`'m4x.ne
+ Move: move from Head$1 to Body$1.Head`'m4x
+ if Bot.len*Top.len*Move.len > 0 then {
+ line from Intersect_(Move,Top) to Intersect_(Move,Bot)}')')
+
+ vsep = 0.75
+
+ Node(1,s_box($`h(h(h(x_1,x_2),h(x_3,x_4)),h(h(x_5,x_6),h(x_7,x_8)))'$),
+ (0,-vsep),
+ Node(1,s_box($`h(h(x_1,x_2),h(x_3,x_4))'$),
+ (0,-vsep),
+ Node(1,s_box($`h(x_1,x_2)'$),
+ (0,-vsep),
+ Node(1,s_box($`x_1:=((A,pk_A),h_1)'$)),
+ Node(2,s_box($`x_2:=((B,pk_B),h_2)'$) \
+ with .n at last "".ne+(0.2,-vsep*2/3))),
+ Node(2,s_box($`h(x_3,x_4)'$) with .nw at Head1.ne+(Body1.wid/2+0.1,0),
+ (0,-vsep),
+ Node(1,s_box($`x_3:=((A,pk_A^\prime),h_3)'$)),
+ Node(2,s_box($`x_4:=((D,pk_D),h_4)'$) \
+ with .n at last "".ne+(0.2,-vsep*2/3)))),
+ Node(2,s_box($`h(h(x_5,x_6),h(x_7,x_8))'$) \
+ with .nw at Head1.ne+(Body1.wid/2,0),
+ (0,-vsep),
+ Node(1,s_box($`h(x_5,x_6)'$),
+ (0,-vsep*5/4),
+ Node(1,s_box($`x_5:=((E,pk_E),h_5)'$)),
+ Node(2,s_box($`x_6:=((H,pk_H),h_6)'$) \
+ with .n at last "".ne+(0.2,-vsep*2/3))),
+ Node(2,s_box($`h(x_7,x_8)'$) with .nw at Head1.ne+(Body1.wid/2+0.1,0),
+ (0,-vsep*5/4),
+ Node(1,s_box($`x_7:=((D,pk_D^\prime),h_7)'$)),
+ Node(2,s_box($`x_8:=((K,pk_K),h_8)'$) \
+ with .n at last "".ne+(0.2,-vsep*2/3))),
+ Node(3,s_box($`h(x_9)'$) at 0.5 between Head1 and Head2)))
+
+.PE
diff --git a/graphics/circuit_macros/doc/Variable.m4 b/graphics/circuit_macros/doc/Variable.m4
new file mode 100644
index 0000000000..6fac01e164
--- /dev/null
+++ b/graphics/circuit_macros/doc/Variable.m4
@@ -0,0 +1,28 @@
+.PS
+# `Variable.m4'
+cct_init
+
+define(`elen_',dimen_); down_
+[ { variable(`capacitor') }; move right
+ { variable(`resistor',uN) }; move right
+ { variable(`capacitor(,C)') }; move right
+ { variable(`inductor') }; move right
+ { variable(`inductor(,W)') }
+ ]
+[
+ skp = 0.4
+ hskip = linewid*0.5
+ cskip = hskip
+Orig: Here
+ { move right cskip+elen_+hskip
+ line invis right_ elen_ "\tt C"; move right_ hskip
+ line invis right_ elen_ "\tt S" }
+ Loopover_(`char',
+ `move down skp ifelse(char,A,*0.5)
+ { line invis right_ cskip "\tt char"
+ variable(`capacitor(,C)',char); move right_ hskip
+ variable(`capacitor(,C)',char`'C); move right_ hskip
+ variable(`capacitor(,C)',char`'S) }',
+ A,P,L,N)
+ ] with .w at last [].e+(0.4,0)
+.PE
diff --git a/graphics/circuit_macros/doc/Version.tex b/graphics/circuit_macros/doc/Version.tex
new file mode 100644
index 0000000000..aee229c54b
--- /dev/null
+++ b/graphics/circuit_macros/doc/Version.tex
@@ -0,0 +1 @@
+Version 9.0
diff --git a/graphics/circuit_macros/doc/Windings.m4 b/graphics/circuit_macros/doc/Windings.m4
new file mode 100644
index 0000000000..0c1ff4b87b
--- /dev/null
+++ b/graphics/circuit_macros/doc/Windings.m4
@@ -0,0 +1,113 @@
+.PS
+cct_init
+# Windings.m4
+ ifelse(xtract(m4postprocessor,pstricks,pgf,mpost,pdf,postscript,svg),,
+ `print "
+ `pstricks, pgf, mpost, pdf, postscript, or svg required for Windings.m4'"
+ "`pstricks, pgf, mpost, pdf, postscript, or svg required for Windings.m4'"',
+`
+ s_init(Windings)
+ ifdef(`Windings_1',,`sinclude(FWindings.dim)')
+ sinclude(Circuit_macros.dim)
+ ifdef(`Windings_1',,`sinclude(tst.dim)')
+
+define(`vlight',`rgbstring(0.9,0.9,0.9)')
+define(`lightgray',`rgbstring(0.7,0.7,0.7)')
+
+[ W: winding ]
+ s_box(\tt w{}inding) at last [].s below
+
+[ winding(R) ] with .n at last "".s+(0,-0.1)
+ s_box(\tt w{}inding(R)) at last [].s below
+
+[ sk = 0.75
+ d = 1.5*sk
+ p = 0.4*sk
+ w = 1*sk
+
+W: winding(L,d,p,4,w,vlight)
+
+thinlines_
+ dimension_(from W.nw+(p/4,0) right p,0.1,s_box(\tt pitch\strut) above,W)
+ dimension_(from W.sw to W.nw,0.2,s_box(\tt diam),H)
+ dimension_(from W.e+(-p/2,-w/2) up w,-0.3,,s_ht)
+ s_box(\tt\hfill core wid) at W.e ljust
+ arrow <- up d-w+0.1 left d/10 from W.ne+(-p/2,-(d-w))
+ s_box(\tt core color) at Here+(-0.2,0) ljust above
+thicklines_
+] with .sw at last [].se+(0.25,0)
+ "\tt T1" at last [].W.T1 below
+ "\tt T2" at last [].W.T2 below
+
+[
+#`winding(L|R, diam, pitch, nturns, core wid, core color )'
+boxwid = 0.3
+boxht = 0.4
+ down_
+B1: box
+ winding(,boxwid*1.3,boxht/5,3,boxwid) at B1
+ "Left pins" "cw" at B1.s+(0,-0.15)
+ for_(1,2,1,`"\sl\small T`'m4x" at last [].T`'m4x rjust')
+B2: box at B1.e + (0.5,0)
+ winding(R,boxwid*1.3,boxht/5,3,boxwid) at B2
+ "Left pins" "ccw" at B2.s+(0,-0.15)
+ for_(1,2,1,`"\sl\small T`'m4x" at last [].T`'m4x rjust')
+ up_
+B3: box at B1.s + (0,-0.55)
+ winding(,boxwid*1.3,boxht/5,3,boxwid) at B3
+ "Right pins" "cw" at B3.s+(0,-0.15)
+ for_(1,2,1,`"\sl\small T`'m4x" at last [].T`'m4x ljust')
+B4: box at (B2,B3)
+ winding(R,boxwid*1.3,boxht/5,3,boxwid) at B4
+ "Right pins" "ccw" at B4.s+(0,-0.15)
+ for_(1,2,1,`"\sl\small T`'m4x" at last [].T`'m4x ljust')
+] with .sw at last [].se+(0.1,0)
+
+[
+ Q: box invis ht 1 wid 5/4
+ g = Q.wid/12
+ ironwid = Q.wid/4.5
+
+ line thick ironwid/(1bp__)+linethick from Q.n+(g/2-linethick/2 bp__,0) \
+ to Q.ne then to Q.se then to Q.sw then to Q.nw \
+ then to Q.n+(-g/2+linethick/2 bp__,0)
+ ifmpost(`rgbdraw(0.7,0.7,0.7,')
+ line thick ironwid/(1bp__)-linethick outlined lightgray \
+ from Q.n+(g/2+linethick/2 bp__,0) \
+ to Q.ne then to Q.se then to Q.sw then to Q.nw \
+ then to Q.n+(-g/2-linethick/2 bp__,0)
+ ifmpost(`)')
+
+thinlines_
+ dimension_(from Q.n+(-g/2,-ironwid/2) right g,-ironwid/4,
+ "$g$" below,1,2pt__)
+thicklines_
+
+ down_
+ P: winding(R,ironwid*5/4,ironwid/2,4,ironwid,lightgray) at Q.w
+ line left ironwid*2/3 from P.T1
+ arrow right to P.T1 "$i_1$" above
+ line left ironwid*2/3 from P.T2
+ gap(up_ to 2nd last line.end)
+ llabel(-,s_box($v_1$),+)
+ "$N_1$" at P.e ljust
+
+ up_
+ S: winding(L,ironwid*5/4,ironwid/2,4,ironwid,lightgray) at Q.e
+ line right ironwid*2/3 from S.T2
+ arrow left to S.T2 "$i_2$" above
+ line right ironwid*2/3 from S.T1
+ gap(up_ to 2nd last line.end)
+ rlabel(-,s_box($v_2$),+)
+ "$N_2$" at S.w rjust
+
+ box dashed rad ironwid/4 wid Q.wid ht Q.ht at Q
+ arrow right arrowht from 0.5 between Q.n and Q.ne
+ "$\phi$" ljust at Here+(0,5pt__)
+
+ move up ironwid/2 from Q.n
+ move down ironwid/2 from Q.s
+] with .sw at last [].se+(0.15,0)
+
+')
+.PE
diff --git a/graphics/circuit_macros/doc/Workflow.m4 b/graphics/circuit_macros/doc/Workflow.m4
new file mode 100644
index 0000000000..b4c0bea1a0
--- /dev/null
+++ b/graphics/circuit_macros/doc/Workflow.m4
@@ -0,0 +1,94 @@
+.PS
+# Workflow.m4
+gen_init
+command "{\small\sf"
+
+boxwid = boxwid*0.8
+
+B:[
+define(`fbox',`box fill_(0.95)')
+define(`lbx',`"\setbox0=\hbox{$1}\parbox{\wd0}{\raggedleft $2}" rjust')
+
+ boxwid = 0.58
+ boxht = 0.4
+ linethick_(1.0)
+ arrowwid = 0.05
+ arrowht = 0.1
+ fillval = 0.8
+ hsep = 0.06
+ vsep = 0.15
+
+ arlen = 0.5*1.25
+
+Tpic: fbox "\LaTeX"
+Pict2e: fbox "\LaTeX" "pict2e" with .w at Tpic.e+(boxwid*3/4,0)
+PDF: arrow <- up arlen from 0.5 between Tpic.n and Pict2e.n lbx(PDF,PDF\\ .pdf)
+ "\tt -d" rjust above
+
+ arrow <- up arlen from Pict2e.n lbx(\LaTeX,\LaTeX\\ .tex)
+E: Here
+ "\tt -e" rjust above
+
+ arrow <- up arlen from Tpic.n lbx(tpic,tpic\\ .tex)
+
+Psfrag: fbox "\LaTeX" "psfrag" with .w at Pict2e.e+(hsep,0)
+ arrow <- up arlen from Psfrag.n lbx(Postscript,Postscript\\ psfrag\\ .eps)
+ "\tt -f" rjust above
+ boxstep = Psfrag.x-Pict2e.x
+PGF: fbox "\LaTeX" "or" "PDFlatex" "tikz" ht 1.6*boxht \
+ with .nw at Psfrag.ne+(hsep,0)
+ arrow <- up arlen from PGF.n lbx(PGF,PGF\\ .tex)
+ "\tt -g" rjust above
+Mfpic: fbox "\LaTeX" "Mfpic" with .nw at PGF.ne+(hsep,0)
+MetaFont: fbox "Metafont" with .n at Mfpic.s+(0,-vsep)
+ arrow from Mfpic.s to MetaFont.n
+ arrow from MetaFont.s down vsep/2 then right boxwid/2+hsep/2 \
+ then up Mfpic.n.y-MetaFont.s.y+vsep*3/2 \
+ then left hsep/2+boxwid/4 then down vsep
+ arrow <- up arlen from Mfpic.n lbx(mfpic,mfpic\\ .tex)
+ "\tt -m" rjust above
+PSTricks: fbox "\LaTeX" "PSTricks" with .w at Mfpic.e+(hsep,0)
+ arrow <- up arlen from PSTricks.n lbx(PSTricks,PSTricks\\ .tex)
+ "\tt -p" rjust above
+
+ arrow <- up vsep from (0.5<PSTricks,Mfpic>,E)
+Dpic: fbox "dpic" with .s at Here
+
+MetaPost: fbox "MetaPost" with .w at PSTricks.e+(boxwid*3/4,0)
+ arrow <- up arlen from MetaPost.n lbx(Meta-,Meta-\\ Post\\ .mp)
+ "\tt -s" rjust above
+ arrow <- up arlen from 0.5 between PSTricks.n and MetaPost.n \
+ lbx(Post-,Post-\\ script\\ .eps)
+ "\tt -r" rjust above
+MPLaTeX: fbox ht boxht + vsep/2 "\LaTeX" "or" "PDFlatex" \
+ with .n at MetaPost.s+(0,-vsep)
+ arrow from MetaPost.s to MPLaTeX.n
+
+ arrow <- up arlen from MetaPost.n+(boxstep,0) lbx(SVG,SVG\\ .svg)
+ "\tt -v" rjust above
+Inkscape: fbox "Inkscape" "or" "HTML" with .n at last arrow.start
+ arrow <- up arlen from Inkscape.n+(boxstep,0) lbx(Xfig,Xfig\\ .fig)
+ "\tt -x" rjust above
+Xfig: fbox "Xfig" with .n at last arrow.start
+
+IsLaTeX: fbox ht boxht + vsep/2 "\LaTeX" "or" "PDFlatex" \
+ with .n at Inkscape.s+(0,-vsep)
+ arrow from Inkscape.s to IsLaTeX.n
+
+ line from (PDF,E) to (Xfig,E)
+
+Gpic: fbox "gpic -t" at (Tpic,Dpic)
+ line down vsep from Gpic.s
+M4: fbox "m4" at 0.5<Gpic,Dpic>
+ arrow from M4.e to Dpic.w ".pic" above
+ arrow from M4.w to Gpic.e ".pic" above
+ arrow <- up vsep from 1/3<M4.nw,M4.ne>
+ `"\setbox0=\hbox{Diagram source}\raisebox{-\dp0}{\box0}"' rjust
+ arrow <- up vsep from 2/3<M4.nw,M4.ne>
+ `"Macro libraries"' ljust
+]
+
+# print last [].wid
+
+command "}%"
+.PE
diff --git a/graphics/circuit_macros/doc/Xform.m4 b/graphics/circuit_macros/doc/Xform.m4
new file mode 100644
index 0000000000..697d87fafa
--- /dev/null
+++ b/graphics/circuit_macros/doc/Xform.m4
@@ -0,0 +1,39 @@
+.PS
+# `Xform.m4'
+cct_init
+
+divert(-1)
+define(`trlabels',
+ `{ thinlines_
+ ifelse(`$1',R,
+ `arrow from `$3'.P1 <- right 0.12 up 0.072 chop 1pt__ ; "\sl P1" ljust
+ arrow from `$3'.P2 <- right 0.12 down 0.072 chop 1pt__ ; "\sl P2" ljust
+ arrow from `$3'.TP <- right 0.12 chop 1pt__ ; "\sl TP" wid 0.2 ljust
+ arrow from `$3'.S1 <- left 0.12 up 0.072 chop 1pt__ ; "\sl S1" rjust
+ arrow from `$3'.S2 <- left 0.12 down 0.072 chop 1pt__ ; "\sl S2" rjust
+ arrow from `$3'.TS <- left 0.12 chop 1pt__ ; "\sl TS" rjust
+ ',`
+ arrow from `$3'.P1 <- left 0.12 up 0.072 chop 1pt__ ; "\sl P1" rjust
+ arrow from `$3'.P2 <- left 0.12 down 0.072 chop 1pt__ ; "\sl P2" rjust
+ arrow from `$3'.TP <- left 0.12 chop 1pt__ ; "\sl TP" wid 0.2 rjust
+ arrow from `$3'.S1 <- right 0.12 up 0.072 chop 1pt__ ; "\sl S1" ljust
+ arrow from `$3'.S2 <- right 0.12 down 0.072 chop 1pt__ ; "\sl S2" ljust
+ arrow from `$3'.TS <- right 0.12 chop 1pt__ ; "\sl TS" ljust
+ ')
+ `"'\tt `$2'`"' at `$3'.s+(0,-(`$4'))
+ thicklines_ } ')
+divert(0)dnl
+
+ down_
+ T1: transformer
+ trlabels(,`transformer',T1,0.3)
+ T2: transformer(down_ 0.6,,2,P,8) with .w at T1.e+(1,0)
+ trlabels(,`...(down\_ 0.6,,2,P,8)',T2,0.3)
+ T3: transformer(,,8,WD12,4) with .w at T2.e+(1,0)
+ trlabels(,`...(,,8,WD12,4)',T3,0.21)
+ T4: transformer(,,9,AL) with .sw at T3.se+(1,0)
+ trlabels(,`...(,,9,AL)',T4,0.3)
+ T5: transformer(,R,8,AW) with .sw at T4.se+(1,0)
+ trlabels(R,`...(,R,8,AW)',T5,0.3)
+
+.PE
diff --git a/graphics/circuit_macros/doc/bi_trans.m4 b/graphics/circuit_macros/doc/bi_trans.m4
new file mode 100644
index 0000000000..9884a14007
--- /dev/null
+++ b/graphics/circuit_macros/doc/bi_trans.m4
@@ -0,0 +1,65 @@
+.PS
+# `bi_trans.m4'
+sinclude(Circuit_macros.dim)
+s_init(bitrans)
+ifdef(`bitrans_1',,`sinclude(tst.dim)')
+
+cct_init
+
+[[
+Q: bi_trans(,,BCuEBUS)
+ s_box($C$) at Q.C below
+ s_box($B$) at Q.B above
+ s_box($E$) at Q.E below
+
+thinlines_
+M4_xyO: Q.M4_xyO
+ spline <- from tr_xy(0,5.25) left 0.1 then up 0.15 left 0.15
+ s_box(\tt B) above
+ spline <- from 0.5<tr_xy(3,0),tr_xy(1.2,4)> right 0.1 then right 0.15 up 0.15
+ s_box(\tt C) ljust
+ spline <- from 0.7<tr_xy(-2,4),tr_xy(2,4)> up 0.1 then right 0.15 up 0.15
+ s_box(\tt BU) above
+ spline <- from 0.7<tr_xy(-3,0),tr_xy(-1.2,4)> left 0.1 then left 0.15 up 0.15
+ s_box(\tt uE) rjust
+ arrow <- from Q.Bulk.start+vec_(vscal_(m4_U,0,0.5)) up 0.15 left 0.15
+ s_box(\tt S) above rjust
+ arrow <- from Q.Bulk.end up 0.1 right 0.1
+ s_box($\;\;$\tt S) above
+ ]
+ s_box(\tt bi\_trans(,{,}BCuEBUS)) at last [].s below
+]
+
+[[
+Q2: bi_trans(,,BCdE2BU)
+ s_box($C$) at Q2.C below
+ s_box($B$) at Q2.B above
+
+thinlines_
+M4_xyO: Q2.M4_xyO
+ arrow <- from Q2.E0 down 0.1 right 0.1; s_box($\;\;E0$) below
+ arrow <- from Q2.E2 down 0.1 left 0.1; s_box($E2\;\;$) below
+ arrow <- from Q2.E1 down 0.1 ; s_box($E1$) below
+ spline <- from 0.4<Q2.Em2.start,Q2.Em2.end> left 0.1 then up 0.15 left 0.15
+ s_box($Em2\;\;$) above
+ ]
+ s_box(\tt bi\_trans(,{,}BCdE2BU)) at last [].s below
+] with .nw at last [].ne+(0.5,0)
+
+[[
+Q2: bi_trans(,,BC2dEBU)
+ s_box($E$) at Q2.E below
+ s_box($B$) at Q2.B above
+
+thinlines_
+M4_xyO: Q2.M4_xyO
+ arrow <- from Q2.C0 down 0.1 left 0.1; s_box($C0\;\;$) below
+ arrow <- from Q2.C2 down 0.1 right 0.1; s_box($\;\;C2$) below
+ arrow <- from Q2.C1 down 0.1 ; s_box($C1$) below
+ spline <- from 0.4<Q2.Cm2.start,Q2.Cm2.end> right 0.1 then up 0.15 right 0.15
+ s_box($Cm2\;\;$) above
+ ]
+ s_box(\tt bi\_trans(,{,}BC2dEBU)) at last [].s below
+] with .nw at last [].ne+(0.5,0)
+
+.PE
diff --git a/graphics/circuit_macros/doc/bistable.m4 b/graphics/circuit_macros/doc/bistable.m4
new file mode 100644
index 0000000000..d158e10a04
--- /dev/null
+++ b/graphics/circuit_macros/doc/bistable.m4
@@ -0,0 +1,35 @@
+.PS
+# `bistable.m4'
+cct_init # Default initialization
+
+ up_
+rgbdraw(1,0,0,
+Q1: bi_tr(,R) # Q1 upward with base to the right
+ llabel(,Q_1) ) # Label to left of last []
+rgbdraw(0,0,1,
+Q2: bi_tr with .C at Q1.C+(elen_*7/4,0) # Q2 with base to left
+ rlabel(,Q_2) )
+
+ ground(at Q1.E)
+ ground(at Q2.E)
+
+ line right_ dimen_/3 from Q1.B # Extend the base conductors
+B1: Here
+ line left_ dimen_/3 from Q2.B
+B2: Here
+
+ resistor(up_ elen_*0.75 from Q1.C); llabel(,"$R_L$" wid 0.16) #Load resistors
+ line to (Q2.C,Here) "$V_{\hbox{cc}}$" below
+ resistor(down_ to Q2.C); llabel(,R_L)
+
+ move to Q1.C+(0,dimen_/5)
+ { resistor(right_ to (B1,Here)); llabel(,R_1)
+X: line to B2 } # Label the line to be jumped
+ resistor(from (Q2.C,Here) left_ to (B2,Here)); rlabel(,R_1)
+ crossover(to B1,R,X)
+
+ resistor(down_ elen_*0.75); rlabel(,R_2) # Bias resistors
+ {"$-V_{\hbox{cc}}$" rjust}
+ line to (B2,Here)
+ resistor(up_ to B2); rlabel(,R_2)
+.PE
diff --git a/graphics/circuit_macros/doc/bitr.m4 b/graphics/circuit_macros/doc/bitr.m4
new file mode 100644
index 0000000000..d5dd735ee6
--- /dev/null
+++ b/graphics/circuit_macros/doc/bitr.m4
@@ -0,0 +1,5 @@
+.PS
+# `bitr.m4'
+cct_init
+include(bitrbody.m4)
+.PE
diff --git a/graphics/circuit_macros/doc/bitrbody.m4 b/graphics/circuit_macros/doc/bitrbody.m4
new file mode 100644
index 0000000000..597b83a0cb
--- /dev/null
+++ b/graphics/circuit_macros/doc/bitrbody.m4
@@ -0,0 +1,4 @@
+S: dot; line left_ 0.1; up_
+Q1: bi_tr(,R) with .B at Here
+ground(at Q1.E)
+line up 0.1 from Q1.C; resistor(right_ S.x-Here.x); dot
diff --git a/graphics/circuit_macros/doc/body.tex b/graphics/circuit_macros/doc/body.tex
new file mode 100644
index 0000000000..d1fb66d626
--- /dev/null
+++ b/graphics/circuit_macros/doc/body.tex
@@ -0,0 +1,3342 @@
+% body.tex
+\newcommand{\bq}{}
+\newcommand{\dpic}{{\bq dpic}\xspace}
+\newcommand{\Dpic}{{\bq Dpic}\xspace}
+\newcommand{\dvips}{{\bq dvips}\xspace}
+\newcommand{\gpic}{{\bq gpic}\xspace}
+\newcommand{\Gpic}{{\bq Gpic}\xspace}
+\newcommand{\groff}{{\bq groff}\xspace}
+\newcommand{\latex}{\LaTeX\xspace}
+\newcommand{\linespec}{{\sl linespec}\xspace}
+\newcommand{\MetaPost}{{\bq MetaPost}\xspace}
+\newcommand{\Mfour}{{\bq m4}\xspace}
+\newcommand{\mfpic}{{\bq mfpic}\xspace}
+\newcommand{\PDF}{{\bq PDF}\xspace}
+\newcommand{\pic}{{\bq pic}\xspace}
+\newcommand{\Pic}{{\bq Pic}\xspace}
+\newcommand{\Postscript}{{\bq Postscript}\xspace}
+\newcommand{\PSTricks}{{\bq PSTricks}\xspace}
+\newcommand{\SVG}{{\bq SVG}\xspace}
+\newcommand{\tex}{\TeX\xspace}
+\newcommand{\Textregistered}{\textregistered\xspace}
+\newcommand{\TPGF}{{\bq Ti{\it k}z~PGF}\xspace}
+\newcommand{\Tikz}{{\bq Ti{\it k}z}\xspace}
+\newcommand{\tpic}{{\bq tpic}\xspace}
+\newcommand{\xfig}{{\bq xfig}\xspace}
+\newcommand{\Xfig}{{\bq Xfig}\xspace}
+%
+\newcommand{\xection}[1]{\section[\texorpdfstring{#1\ \dotfill}{#1}]{#1}}
+\newcommand{\NVL}{\\\hspace*{\parindent}}
+\newcommand{\brtt}{\hfill\break\hspace*\parindent}
+\newcommand{\lbr}{{\tt\char123}}
+\newcommand{\rbr}{{\tt\char125}}
+\newcommand{\bsl}{{\tt\char92}}
+\newcommand{\SR}[1]{\hyperref[#1]{Section~\ref*{#1}}}
+\newcommand{\PR}[1]{\hyperref[#1]{page~\pageref*{#1}}}
+\newcommand{\FR}[1]{\hyperref[#1]{Figure~\ref*{#1}}}
+\newcommand{\FRS}[1]{\hyperref[#1]{Figures~\ref*{#1}}}
+\newcommand{\REF}[1]{\hyperref[#1]{\ref*{#1}}}
+\newcommand{\LQ}{\char96}
+\newcommand{\RQ}{\char39}
+%
+\newcommand{\Example}[1]{\vspace{\parsep}\noindent {\bf Example #1:}}
+%
+ \pdfbookmark[section]{\contentsname}{toc}
+\begin{multicols}{2}
+ \tableofcontents
+\end{multicols}
+%\enlargethispage{\baselineskip}
+%
+\xection{Introduction\label{Introduction:}}
+ \begin{quotation}\noindent
+% Before every conference, I find Ph.D.s in on weekends running back
+% and forth from their offices to the printer.
+ It appears that people
+ who are unable to execute pretty pictures with pen and paper find it
+ gratifying to try with a computer~\cite{Landauer95}.
+ \end{quotation}
+
+This manual
+%\footnote{%
+%This manual is best viewed with a reader that shows bookmarks
+%for easy navigation and for exploring the list of defined macros.}%
+describes a method for drawing electric circuits and
+other diagrams in \latex and web documents.
+The diagrams are defined in the simple \pic drawing language~\cite{KRpic}
+augmented with \Mfour macros~\cite{KRm4}, and are
+processed by \Mfour and a \pic processor to
+convert them to \TPGF, \PSTricks, other \latex-compatible code, or \SVG.
+In its basic form, the method has the advantages and disadvantages of
+\tex itself, since it is macro-based and non-WYSIWYG,
+with ordinary text input. The book from which the above quotation
+is taken correctly points out that the payoff can be in quality of
+diagrams at the price of the time spent in learning how to draw them.
+
+A collection of basic components, most based on IEEE
+standards~\cite{IEEEstd},
+and conventions for their internal
+structure are described. Macros such as these are only a starting
+point, since it is often convenient to customize elements or to package
+combinations of them for particular drawings.
+
+\xection{Using the macros\label{Using:}}
+This section describes the basic process of adding circuit diagrams to
+\latex documents to produce postscript or pdf files. On some operating
+systems, project management software with graphical interfaces can be used
+to automate the process,
+but the steps can also be performed by a script,
+makefile, or by hand for simple documents as described in~\SR{Quickstart:}.
+
+The diagram source file is preprocessed as illustrated in
+\FR{Flowdiag}. A configuration file is read by \Mfour,
+followed by the diagram source.
+The result is passed through a
+\pic interpreter to produce {\tt .tex} output that can be inserted
+into a {\tt .tex} document using the \verb|\input| command.
+
+\begin{figure}[hbt]
+ \pdftooltip{\input Flowdiag }{Flow diagram for the inclusion of figures}
+ \caption{Inclusion of figures and macros in the \latex document.
+ \label{Flowdiag}}
+ \end{figure}
+
+\noindent
+The interpreter output contains
+\TPGF~\cite{tikz} commands,
+\PSTricks~\cite{pstricks} commands,
+basic \latex graphics,
+\tpic specials, or other formats,
+depending on the chosen options.
+These variations are described in \SR{Alternative:}.
+
+There are two principal choices of \pic interpreter. One is~\dpic,
+described later in this document. A partial alternative is
+GNU {\bq gpic -t} (sometimes simply named \pic)~\cite{gpic}
+together with a printer driver
+that understands \tpic specials, typically {\bq dvips}~\cite{dvips}.
+The \dpic processor extends the pic language in small but important ways;
+consequently, some of the macros and examples in this distribution work fully
+only with \dpic.
+\Pic processors contain basic macro facilities, so some of the
+concepts applied here do not require \Mfour.
+
+\subsection{Quick start\label{Quickstart:}}
+The contents of file {\tt quick.m4} and resulting diagram are shown in
+\FR{quick} to illustrate the language
+% to show several ways for placing circuit elements,
+%and to provide sufficient information for producing
+and the production of basic labeled circuits.
+\begin{figure}[h!]
+ \parbox{\textwidth}{\small\verbatiminput{quick.m4}}%
+ \hfill\llap{\raise-1.15in\hbox{\input quick }}%
+% \hfill\llap{\raise-1.15in\hbox{\pdftooltip{\input quick }%
+% {The file {\tt quick.m4} and resulting diagram.
+% There are several ways of drawing the same picture; for example,
+% nodes (such as {\tt Origin}) can be defined and circuit branches
+% drawn between them; or absolute coordinates can be used (e.g.,
+% {\tt source(up\_ from (0,0) to (0,0.75))} ). Element sizes and styles
+% can be varied as described in later sections.}}}%
+ \vspace*{-\baselineskip}%
+ \caption{The file {\tt quick.m4} and resulting diagram.
+ There are several ways of drawing the same picture; for example,
+ nodes (such as {\tt Origin}) can be defined and circuit branches
+ drawn between them; or absolute coordinates can be used (e.g.,
+ {\tt source(up\_ from (0,0) to (0,0.75))} ). Element sizes and styles
+ can be varied as described in later sections.\label{quick}}%
+ \end{figure}
+
+\subsubsection{\protect{Using \Mfour}%
+\label{Usingmfour:}}
+The command
+
+ {\vspace*\parsep\tt
+ m4 {\sl filename \ldots}
+ \vspace*\parsep}
+
+\noindent
+causes \Mfour\ to search for the named
+files in the current directory and directories specified
+by environmental variable {\tt M4PATH}.
+Set {\tt M4PATH} to the full name (i.e., the path) of the directory containing
+{\tt libcct.m4} and the other circuit library {\tt .m4} files; otherwise
+invoke \Mfour\ as {\tt m4 -I} {\sl installdir}
+where {\sl installdir} is the path to the directory
+containing the library files.
+Now there are at least two basic possibilities as follows,
+but be sure to read \SR{Simplifications:} for simplified use.
+
+\subsubsection{\protect{Processing with \dpic and \PSTricks or \TPGF}%
+\label{Processingwithpstricks:}}
+If you are using \dpic with \PSTricks,
+put \verb|\usepackage{pstricks}| in the main \latex source file header and
+type the following commands or put them into a script:
+
+ {\vspace*\parsep\tt
+ m4 pstricks.m4 quick.m4 > quick.pic
+ \brtt
+ dpic -p quick.pic > quick.tex
+ \vspace*\parsep}
+
+
+\noindent
+To produce \TPGF code,
+the \latex header should contain \verb|\usepackage{tikz}|.
+The commands are modified to read \verb|pgf.m4|
+and invoke the {\tt-g} option of \dpic as follows:
+
+ {\vspace*\parsep\tt
+% {\tt
+ m4 pgf.m4 quick.m4 > quick.pic
+ \brtt
+ dpic -g quick.pic > quick.tex
+ \vspace*\parsep}
+
+A configuration file ({\tt pstricks.m4} and {\tt pgf.m4} in the
+above examples) is {\em always} the first file to be given to \Mfour.
+Put the following or its equivalent in the document body:
+\begin{verbatim}
+\begin{figure}[hbt]
+ \centering
+ \input quick
+ \caption{Customized caption for the figure.}
+ \label{Symbolic_label}
+\end{figure}
+\end{verbatim}
+Then for \PSTricks,
+the commands ``{\tt latex} {\sl file}{\tt;} {\tt dvips} {\sl file}''
+produce {\sl file}{\tt.ps},
+which can be printed or viewed using {\tt gsview}, for example.
+For \TPGF,
+Invoking PDFlatex on the source produces {\tt .pdf} output directly.
+%Whether or not the figure environment is used,
+%the essential line in all cases is \verb|\input quick|.
+The essential line is \verb|\input quick| whether or not the figure
+environment is used.
+
+The effect of the \Mfour command above is shown in \FR{ConfigA}.
+Configuration files {\tt pstricks.m4} or {\tt pgf.m4}
+cause library {\tt libgen.m4}
+to be read, thereby defining the macro {\tt cct\_init}.
+The diagram source file is then read and
+the circuit-element macros in {\tt libcct.m4} are defined during
+expansion of {\tt cct\_init}.
+\begin{figure}[hbt]
+ \input ConfigA
+ \caption{The command
+ {\tt m4 pstricks.m4 quick.m4 > quick.pic}.
+ \label{ConfigA}}
+ \end{figure}
+
+\subsubsection{Processing with \gpic\label{Processingwithgpic:}}
+If your printer driver understands \tpic specials and
+you are using \gpic (on some systems the \gpic command is {\tt pic}),
+the commands are
+
+ {\tt
+ m4 gpic.m4 quick.m4 > quick.pic
+ \brtt
+ gpic -t quick.pic > quick.tex
+ \vspace*\parsep}
+
+\noindent
+and the figure inclusion statements are as shown:
+\begin{verbatim}
+\begin{figure}[hbt]
+ \input quick
+ \centerline{\box\graph}
+ \caption{Customized caption for the figure.}
+ \label{Symbolic_label}
+ \end{figure}
+\end{verbatim}
+
+\subsubsection{Simplifications\label{Simplifications:}}
+M4 must read a configuration file before any other files,
+%followed by the macro definitions in one or more library files,
+either before reading the diagram source file or at the beginning of it.
+There are several ways to control the process, as follows:
+\begin{enumerate}
+\item
+The macros can be processed by \latex-specific
+project software and by graphic applications such as Cirkuit~\cite{KDEApps2009}.
+Alternatively when many files are to be processed, a facility such as
+Unix ``make,'' which is also available in PC and Mac versions, can be employed
+to automate the required commands. On systems without such
+facilities, a scripting language can be used.
+
+\item
+The \Mfour commands illustrated above can be shortened to
+
+\verb|m4 quick.m4 > quick.pic|
+
+\noindent
+by inserting {\tt include(pstricks.m4)} (assuming \PSTricks processing)
+%or {\tt include(libgen.m4)} (assuming the default processor is to be used)
+{\em immediately} after the {\tt .PS} line, the effect of which
+%The effect of the first include statement
+is shown in \FR{ConfigB}.
+However, if you then want to use \TPGF,
+the line must be changed to {\tt include(pgf.m4)}.
+%and the second in \FR{ConfigC}.
+\begin{figure}[h!]
+ \input{ConfigB}
+ \caption{The command {\tt m4 quick.m4 > quick.pic},
+ with {\tt include(pstricks.m4)} preceding {\tt cct\_init}.}
+ \label{ConfigB}
+ \end{figure}
+%\begin{figure}[h!]
+% \input{ConfigC}
+% \caption{The command {\tt m4 quick.m4 > quick.pic},
+% with {\tt include(libgen.m4)} preceding {\tt cct\_init}, causing
+% the default configuration file to be read.}
+% \label{ConfigC}
+% \end{figure}
+
+%\item
+%On some systems, setting the environment variable {\tt M4PATH} to {\sl
+%installdir} allows the {\tt -I} {\sl installdir} option of \Mfour to
+%be omitted, but it will be kept in following examples.
+
+\item
+In the absence of a need to examine the file {\tt quick.pic},
+the commands for producing the {\tt .tex} file can be reduced
+(provided the above inclusions have been made) to
+
+\verb%m4 quick.m4 | dpic -p > quick.tex%
+
+\item
+It may be desirable to invoke \Mfour and \dpic automatically from the
+document file as shown:
+
+{\tt \verb^\documentclass{article}^ \brtt
+\verb^\usepackage{tikz}^ \brtt
+\verb^\newcommand\mtotex[2]{\immediate\write18{m4 ^%-I^ {\sl installdir}
+\verb^#2.m4 | dpic -#1 > #2.tex}}%^\break
+\verb^\begin{document}^ \brtt
+\verb^\mtotex{g}{FileA} % Generate FileA.tex^ \brtt
+\verb^\input{FileA.tex} \par^ \brtt
+\verb^\mtotex{g}{FileB} % Generate FileB.tex^ \brtt
+\verb^\input{FileB.tex}^ \brtt
+\verb^\end{document}^
+ \vspace*\parsep}
+
+The first argument of \verb|\mtotex| is a {\tt p} for pstricks or
+{\tt g} for pgf.
+Sources \verb|FileA.m4| and \verb|FileB.m4| must contain any required
+\verb|include| statements,
+and the main document should be processed using
+the latex or pdflatex option \verb|-shell-escape|.
+If the {\tt M4PATH} environment variable is not set then insert
+{\tt -I }{\sl installdir} after {\tt m4} in the command definition,
+where {\sl installdir} is the absolute path to the installation directory.
+This method processes the picture source each time \latex is run, so for
+large documents containing many diagrams, the \verb|\mtotex|
+lines could be commented out after debugging the corresponding graphic.
+A derivative of this method that allows the insertion of
+\pic code into a \Tikz picture is described in \SR{Tikzwithpic:}.
+
+\item
+You can put several diagrams into a single source file.
+Make each diagram the body of a \latex macro, as shown:
+
+%\enlargethispage{\baselineskip}
+\par
+\verb|\newcommand{\diaA}{%|\NVL
+\verb|.PS|\NVL
+{\sl drawing commands}\NVL
+\verb|.PE|\NVL
+\verb|\box\graph }% \box\graph not required for dpic|\NVL
+\verb|\newcommand{\diaB}{%|\NVL
+\verb|.PS|\NVL
+{\sl drawing commands}\NVL
+\verb|.PE|\NVL
+\verb|\box\graph }% \box\graph not required for dpic|\NVL
+Produce a {\tt .tex} file using \verb|\mtotex|
+or \Mfour and \dpic or \gpic,
+insert the {\tt .tex} into the \latex source, and
+invoke the macros \verb^\diaA^ and \verb^\diaB^ at the appropriate places.
+\end{enumerate}
+
+\subsection{Including the libraries\label{Libraries:}}
+The configuration files for \dpic are as follows,
+depending on the output format (see \SR{Alternative:}):
+{\tt pstricks.m4, pgf.m4, mfpic.m4, mpost.m4, postscript.m4, psfrag.m4, svg.m4,
+ gpic.m4,} or {\tt xfig.m4}.
+The file {\tt psfrag.m4} simply defines the macro {\tt psfrag\_} and
+then reads {\tt postscript.m4}.
+For \gpic, the configuration file is {\tt gpic.m4}.
+The usual case for producing circuit diagrams is to read
+{\tt pstricks.m4} or {\tt pgf.m4} first when \dpic is the postprocessor or
+to set one of these as the default configuration file.
+
+At the top of each diagram source, put one or more initialization
+commands; that is,
+
+{\tt cct\_init, log\_init, sfg\_init, darrow\_init, threeD\_init}
+
+\noindent
+or, for diagrams not requiring specialized macros, {\tt gen\_init}.
+As shown in \FRS{ConfigA} and~\REF{ConfigB},
+each initialization command reads in the appropriate macro
+library if it hasn't already been read;
+for example, {\tt cct\_init} tests whether {\tt libcct.m4} has been
+read and includes it if necessary.
+
+A few of the distributed example files contain other experimental macros
+that can be pasted into diagram source files; see
+{\tt Flow.m4} or {\tt Buttons.m4}, for example.
+
+The libraries contain hints and explanations that might help in debugging
+or if you wish to modify any of the macros. Macros are generally named
+using the obvious circuit element names so that programming becomes something
+of an extension of the \pic language. Some macro names end in an underscore
+to reduce the chance of name clashes. These can be invoked in the
+diagram source but there is no long-term guarantee that their names and
+functionality
+will remain unchanged. Finally, macros intended only for internal use
+begin with the characters {\tt m4}.
+
+\xection{\Pic essentials\label{Pic:}}
+
+\Pic source is a sequence of lines in a file.
+The first line of a diagram begins with {\tt .PS} with optional following
+arguments, and the last line is normally {\tt .PE}.
+Lines outside of these pass through the \pic processor unchanged.
+
+The visible objects can be divided conveniently into two classes, the
+{\em linear} objects {\tt line, arrow, spline, arc,} and the
+{\em planar} objects {\tt box, circle, ellipse.}
+
+The object {\tt move} is linear but draws nothing. A compound object,
+or {\tt block,} is planar and consists of a pair of square brackets enclosing
+other objects, as described in \SR{Compoundobjects:}.
+Objects can be placed using absolute coordinates or relative to other objects.
+
+\Pic allows the definition of real-valued variables, which are alphameric
+names beginning with lower-case letters, and computations using them.
+Objects or locations on the diagram can be given symbolic names
+beginning with an upper-case letter.
+
+\subsection{Manuals\label{Manuals:}}
+The classic \pic manual~\cite{KRpic} is still a good introduction to \pic, but
+a more complete manual~\cite{Raymond95} can be found in the GNU \groff\
+package, and both are available on the web~\cite{KRpic,Raymond95}. Reading
+either will give you competence with \pic in an hour or two. Explicit mention
+of {\tt *roff} string and font constructs in these manuals should be replaced by
+their equivalents in the \latex context. A man-page language summary is
+appended to the \dpic manual~\cite{Aplevich2011}.
+
+A web search will yield good discussions of ``little languages'';
+for \pic in particular, see Chapter~9 of~\cite{Bentley88}.
+Chapter~1 of reference~\cite{Goossens97} also contains a brief
+discussion of this and other languages.
+
+\subsection{The linear objects: {\tt line, arrow, spline, arc}%
+\label{Linearobjects:}}
+A line can be drawn as follows:
+
+{\tt line from} {\sl position} {\tt to} {\sl position}
+
+\noindent
+where {\sl position} is defined below or
+
+{\tt line} {\sl direction} {\sl distance}
+
+\noindent
+where {\sl direction} is one of {\tt up,} {\tt down,} {\tt left,}
+{\tt right.} When used with the \Mfour macros described here, it is
+preferable to add an underscore: {\tt up\_,} {\tt down\_,} {\tt left\_,}
+{\tt right\_.} The {\sl distance} is a number or expression
+and the units are inches, but the assignment
+
+{\tt scale = 25.4}
+
+\noindent
+has the effect of changing the units to millimetres,
+as described in \SR{Scaling:}.
+
+Lines can also be drawn to any distance in any direction. The example,
+
+{\tt line up\_ 3/sqrt(2) right\_ 3/sqrt(2) dashed}
+
+\noindent
+draws a line 3 units long from the current location,
+at a $45^\circ$ angle above horizontal.
+Lines (and other objects) can be specified as {\tt dotted,} {\tt dashed,} or
+{\tt invisible,} as above.
+
+The construction
+
+{\tt line from A to B chop x}
+
+\noindent
+truncates the line at each end by {\tt x} (which may be negative)
+or, if {\tt x} is omitted, by
+the current circle radius, which is convenient when A and B are
+circular graph nodes, for example. Otherwise
+
+{\tt line from A to B chop x chop y}
+
+\noindent
+truncates the line by {\tt x} at the start and {\tt y} at the end.
+
+Any of the above means of specifying line (or arrow) direction and length
+will be called a \linespec.
+
+Lines can be concatenated. For example, to draw a triangle:
+
+{\tt line up\_ sqrt(3) right\_ 1 then down\_ sqrt(3) right\_ 1 then left\_ 2}
+
+\subsection{Positions\label{Positions:}}
+A {\sl position} can be defined by a coordinate pair, e.g. {\tt 3,2.5},
+more generally using parentheses by {\tt (}{\sl expression, expression}{\tt )},
+as a sum or difference as
+{\tt{\sl position} $+$ ({\sl expression, expression})},
+or by the construction {\tt (}{\sl position, position}{\tt )},
+the latter taking the $x$-coordinate from the first
+position and the $y$-coordinate from the second. A position can be
+given a symbolic name beginning with an upper-case letter,
+e.g. {\tt Top:~(0.5,4.5)}. Such a definition does not affect the calculated
+figure boundaries. The current position {\tt Here} is always defined and
+is equal to $(0,0)$ at the beginning of a diagram or block.
+The coordinates of a position are accessible, e.g. {\tt Top.x} and
+{\tt Top.y} can be used in expressions. The center, start, and end of
+linear objects (and the defined points of other objects as described below)
+are predefined positions, as shown in the following example,
+which also illustrates how to refer to a previously drawn element if it has
+not been given a name:
+
+{\tt line from last line.start to 2nd last arrow.end then to 3rd line.center}
+
+Objects can be named (using a name commencing with an upper-case letter),
+for example:
+
+{\tt Bus23: line up right}
+
+\noindent
+after which, positions associated with the object can be referenced using the
+name; for example:
+
+{\tt arc cw from Bus23.start to Bus23.end with .center at Bus23.center}
+
+An arc is drawn by specifying its rotation, starting point, end point, and
+center, but sensible defaults are assumed if any of these are omitted.
+Note that
+
+{\tt arc cw from Bus23.start to Bus23.end}
+
+\noindent
+does {\em not} define the arc uniquely; there are two arcs that satisfy this
+specification.
+This distribution includes the \Mfour macros
+
+{\tt arcr( {\sl position, radius, start radians, end radians, modifiers, ht})
+\hfill\break\indent
+ arcd( {\sl position, radius, start degrees, end degrees, modifiers, ht})
+\hfill\break\indent
+ arca( {\sl chord linespec,} ccw|cw, {\sl radius, modifiers})
+}
+
+\noindent to draw uniquely defined arcs.
+If the fifth argument of {\tt arcr} or {\tt arcd} contains {\tt ->} or {\tt <-}
+then a midpoint arrowhead of height specified by arg6 is added.
+For example,
+
+{\tt arcd((1,-1),{},0,-90,<- outlined "red") dotted}
+
+\noindent draws a red dotted arc with midpoint arrowhead,
+ centre at $(1,-1),$ and default radius.
+ The example
+
+{\tt arca(from (1,1) to (2,2),{,}1,->)}
+
+\noindent draws an acute angled arc with arrowhead on the chord defined by the
+first argument.
+
+The linear objects can be given arrowheads at the start, end, or both ends,
+for example:
+
+{\tt line dashed <- right 0.5\hfill\break
+\hspace*{\parindent}%
+arc <-> height 0.06 width 0.03 ccw from Here to Here+(0.5,0)
+ \char92\hfill\break
+\hspace*{2\parindent}%
+ with .center at Here+(0.25,0)\hfill\break
+\hspace*{\parindent}%
+spline -> right 0.5 then down 0.2 left 0.3 then right 0.4}
+
+The arrowheads on the arc above have had their shape adjusted using the
+{\tt height} and {\tt width} parameters.
+
+\subsection{The planar objects: {\tt box, circle, ellipse}, and text%
+\label{Planarobjects:}}
+Planar objects are drawn by specifying the width, height, and position, thus:
+
+{\tt A: box ht 0.6 wid 0.8 at (1,1)}
+
+\noindent
+after which, in this example, the position {\tt A.center} is defined,
+and can be referenced simply as {\tt A}.
+The compass points {\tt A.n,} {\tt A.s,} {\tt A.e,} {\tt A.w,} {\tt A.ne,}
+{\tt A.se,} {\tt A.sw,} {\tt A.nw} are automatically defined, as are
+the dimensions {\tt A.height} and {\tt A.width.}
+Planar objects can also be placed by specifying the location of a defined
+point; for example, two touching circles can be drawn as shown:
+
+{\tt circle radius 0.2\hfill\break
+\hspace*{\parindent}%
+circle diameter (last circle.width * 1.2) with .sw at last circle.ne}
+
+The planar objects can be filled with gray or colour.
+For example, either
+
+{\tt box dashed fill\_({\sl number})}\quad or\quad
+ {\tt box dashed outlined "{\sl color}" shaded "{\sl color}"}
+
+\noindent
+produces a dashed box. The first case has a gray fill determined by
+{\sl number}, with $0$ corresponding to black and $1$ to white;
+the second case allows color outline and fill, the color strings depending on
+the postprocessor.
+Postprocessor-compatible RGB color strings are produced by the macro
+{\tt rgbstring({\sl red fraction, green fraction, blue fraction})};
+to produce an orange fill for example:
+
+{\tt ... shaded rgbstring( 1, 0.645, 0)}
+
+Basic colours for lines and fills are provided by \gpic and \dpic,
+but more elaborate line and fill styles or other effects
+can be incorporated, depending on the postprocessor, using
+%by inserting postprocessor commands using
+%{\tt \char92 special} commands or
+%other lines beginning with a backslash in the drawing code. In fact,
+%arbitrary lines can be inserted into the output using
+
+{\tt command "}{\sl string}{\tt "}
+
+\noindent where {\sl string} is one or more postprocessor command lines.
+
+Arbitrary text strings, typically meant to be typeset by \latex, are
+delimited by double-quote characters and occur in two ways. The first
+way is illustrated by
+
+\verb|"\large Resonances of $C_{20}H_{42}$"|
+ \verb|wid |{\sl x}\verb| ht |{\sl y}\verb| at |{\sl position}
+
+\noindent
+which writes the typeset result, like a box, at {\sl position} and tells
+\pic its size. The default size assumed by \pic is given by parameters
+{\tt textwid} and {\tt textht} if it is not specified as above.
+The exact typeset size of formatted text can be obtained
+as described in \SR{Interaction:}. The second occurrence
+associates one or more strings with an object, e.g., the following writes
+two words, one above the other, at the centre of an ellipse:
+%\enlargethispage{\baselineskip}
+
+\verb|ellipse "\bf Stop" "\bf here"|
+
+\noindent
+The C-like \pic function
+ {\tt sprintf("{\sl format string}",{\sl numerical arguments})}
+is equivalent to a string.
+
+\subsection{Compound objects\label{Compoundobjects:}}
+A compound object is a group of statements enclosed in square
+brackets. Such an object is placed by default as if it were a box, but
+it can also be placed by specifying the final position of a defined point.
+A defined point is the center or compass corner of the bounding box
+of the compound object or one of its internal objects.
+Consider the last line of the code fragment shown:
+
+\noindent%
+\verb| Ands: [ right_|\\
+\verb| And1: AND_gate|\\
+\verb| And2: AND_gate at And1 - (0,And1.ht*3/2)|\\
+\verb| |$\ldots$\\
+\verb| ] with .And2.In1 at| {\sl position} % (K.x,IC5.Pin9.y)|
+
+The two gate macros evaluate to compound objects containing {\tt Out},
+{\tt In1}, and other locations. The final positions of all objects
+inside the square brackets are determined in the last line by
+specifying the position of {\tt In1} of gate {\tt And2}.
+
+\subsection{Other language facilities\label{Otherlanguage:}}
+
+All objects have default sizes, directions, and other characteristics,
+so part of the specification of an object can sometimes be profitably
+omitted.
+
+Another possibility for defining positions is
+
+{\sl expression} {\tt between} {\sl position}
+ {\tt and} {\sl position}
+
+\noindent%
+which means
+
+$\hbox{\sl 1st position} + \hbox{\sl expression} \times
+ (\hbox{\sl 2nd position} - \hbox{\sl 1st position})$
+
+\noindent and which can be abbreviated as
+
+{\sl expression} {\tt <} {\sl position} {\tt ,} {\sl position} {\tt >}
+
+\noindent%
+Care has to be used in processing the latter construction with \Mfour,
+since the comma may have to be put within quotes, {\tt `,'}
+to distinguish it from the {\tt m4} argument separator.
+
+Positions can be calculated using expressions containing variables.
+The scope of a position is the current block. Thus, for example,
+
+{\tt
+ theta = atan2(B.y-A.y,B.x-A.x)
+
+ line to Here+(3*cos(theta),3*sin(theta)).
+ }
+
+Expressions are the usual algebraic combinations of primary quantities:
+constants, environmental parameters such as {\tt scale,} variables,
+horizontal or vertical coordinates of terms such as
+{\sl position}{\tt.x} or {\sl position}{\tt.y},
+dimensions of \pic objects, e.g. {\tt last circle.rad}.
+The elementary algebraic operators are
+{\tt +, -, *, /, \%, =, +=, -=, *=, /=,} and {\tt \%=,}
+similar to the C language.
+
+The logical operators {\tt ==, !=, <=, >=, >,} and {\tt <} apply to
+expressions and strings. A modest selection of numerical functions is
+also provided: the single-argument functions {\tt sin, cos, log, exp,
+sqrt, int}, where {\tt log} and {\tt exp} are base-10, the two-argument
+functions {\tt atan2, max, min,} and the random-number generator {\tt
+rand()}. Other functions are also provided using macros.
+
+A \pic manual should be consulted for details, more examples, and
+other facilities, such as the branching facility
+
+\verb|if |{\sl expression}\verb| then { |{\sl anything}
+ \verb|} else { |{\sl anything}\verb| }|,
+
+\noindent%
+the looping facility
+
+\verb|for |{\sl variable}\verb| = |{\sl expression}\verb| to |%
+{\sl expression}\verb| by |{\sl expression}\verb| do { |%
+{\sl anything}\verb| }|,
+
+\noindent%
+%\enlargethispage{\baselineskip}
+operating-system commands, \pic macros, and external file inclusion.
+
+\xection{Two-terminal circuit elements\label{Basictwo:}}
+There is a fundamental difference between the two-terminal elements, each
+of which is drawn along an invisible straight-line segment,
+and other elements, which are compound objects mentioned
+in \SR{Compoundobjects:}. The two-terminal element macros follow a
+set of conventions described in this section, and other elements will
+be described in \SR{Composite:}.
+
+\subsection{Circuit and element basics\label{Basics:}}
+A list of the library macros and their arguments is in
+\SR{defines}. The arguments have default values, so that only
+those that differ from defaults need be specified.
+
+\FR{BigResistor}, which shows a resistor, also serves as
+an example of \pic commands.
+%Consider the resistor shown in \FR{BigResistor},
+%which also serves as an example of \pic commands.
+The first part of the source file for this figure is
+%as follows:
+on the left:
+
+\begin{figure}[hbt]
+ \parbox{2in}{\tt .PS\\ \hbox{}\quad cct\_init\\ \hbox{}\quad linewid = 2.0\\
+ \hbox{}\quad linethick\_(2.0)\\ R1: resistor}
+ \raisebox{-0.3in}{\hbox{\input{BigResistor.tex}}}
+ \caption{Resistor named {\tt R1}, showing the size parameters,
+ enclosing block, and predefined positions.}
+ \label{BigResistor}
+ \end{figure}
+The lines of \FR{BigResistor}
+and the remaining source lines of the file are explained below:
+\begin{itemize}
+\item The first line invokes the macro {\tt cct\_init} that
+ loads the library {\tt libcct.m4}
+ and initializes local variables needed by some circuit-element macros.
+
+\item
+ The sizes of circuit elements are proportional to the \pic environmental
+ variable {\tt linewid}, so redefining this variable changes element
+ sizes. The element body is drawn in proportion to {\tt dimen\_},
+ a macro that evaluates to {\tt linewid} unless redefined, and the default
+ element length is {\tt elen\_}, which evaluates to
+ {\tt dimen\_*3/2} unless redefined.
+ Setting {\tt linewid} to 2.0 as in the example means that the default element
+ length becomes 3.0\,in.
+ For resistors, the default length of the body is {\tt dimen\_/2,} and the
+ width is {\tt dimen\_/6.} All of these values can be customized.
+ Element scaling and the use of SI units is discussed further in
+ \SR{Scaling:}.
+
+\item The macro {\tt linethick\_} sets the default thickness of subsequent
+ lines (to 2.0\,pt in the example).
+ Macro arguments are written within parentheses
+ following the macro name, with no space between the name and the
+ opening parenthesis. Lines can be broken before macro arguments
+ because \Mfour and \dpic ignore white space immediately preceding
+ arguments. Otherwise, a long line can be continued to the next
+ by putting a backslash as the rightmost character.
+\item The two-terminal element macros expand to sequences of drawing commands
+ that begin with {\tt `line invis \linespec'},
+ where \linespec is the first argument of the macro if it
+ is non-blank, otherwise the line is drawn a distance
+ {\tt elen\_} in the current direction, which is to the right by
+ default.
+% All this is handled by the macro {\tt eleminit\_}, which also
+% calculates the length and angle of the invisible line for later use.
+ The invisible line is first drawn, then the element is drawn
+ on top of it.
+ The element---rather, the initial invisible line---can
+ be given a name, {\tt R1} in the example, so that positions
+ {\tt R1.start}, {\tt R1.centre}, and {\tt R1.end} are automatically
+ defined as shown.
+\item The element body is overlaid by a block, which can be
+ used to place labels around the element. The block
+ corresponds to an invisible rectangle with horizontal top and bottom lines,
+ regardless of the direction in which the element is drawn. A
+ dotted box has been drawn in the diagram to show the block boundaries.
+\item The last sub-element, identical to the first in two-terminal
+ elements, is an invisible line that can be referenced later to
+ place labels or other elements.
+% This might be over-kill.
+ If you create your own macros, you might choose simplicity over generality,
+ and include only visible lines.
+ \end{itemize}
+
+To produce \FR{BigResistor}, the following embellishments
+were added after the previously shown source:
+{\small \input BigResistor2.verb }
+
+\begin{itemize}
+\item The line thickness is set to the default thin value of \hbox{0.4\,pt},
+ and the box displaying the element body block is drawn. Notice how the
+ width and height can be specified, and the box centre positioned at
+ the centre of the block.
+\item The next paragraph draws two objects, a spline with an arrowhead,
+ and a string left justified at the end of the spline. Other
+ string-positioning modifiers than {\tt ljust} are {\tt rjust,}
+ {\tt above,} and {\tt below.}
+
+\item The last paragraph invokes a macro for dimensioning diagrams.
+ \end{itemize}
+
+\subsection{The two-terminal elements\label{Twoterminal:}}
+The two-terminal elements are shown in \FRS{CctTable} to~\REF{Diodes}
+and \FRS{Fuses} to~\REF{Switches}.
+Several elements are included more than once to illustrate
+some of their arguments, which are listed in \SR{defines}.
+\begin{figure}[h!]
+ \input CctTable
+ \ifpdf\vspace*{-0.5\baselineskip}\fi%
+ \caption{Basic two-terminal elements, showing some variations.}
+ \label{CctTable}
+ \end{figure}
+
+The first macro argument specifies
+the invisible line segment along which the element is drawn.
+If the argument is blank,
+the element is drawn from the current position in the current drawing
+direction along a default length.
+The other arguments produce variants of the default elements.
+\begin{figure}[t!]
+ \input Sources
+ \ifpdf\vspace*{-0.5\baselineskip}\fi%
+ \caption{Sources and source-like elements.}
+ \label{Sources}
+ \end{figure}
+\begin{figure}[t!]
+ \input Diodes
+ \caption{The macro
+ {\tt diode(\linespec,B|CR|D|L|LE[R]|P[R]|S|T|V|v|w|Z|{\sl chars},[R][E])}.
+ Appending {\tt K} to the second argument draws an open arrowhead.}
+ \label{Diodes}
+ \end{figure}
+Thus, for example,
+
+{\tt resistor(up\_ 1.25,7)}
+
+\noindent%
+draws a resistor 1.25 units long up from the current position, with $7$
+vertices per side.
+The macro {\tt up\_} evaluates to {\tt up} but also resets the current
+directional parameters to point up.
+
+\FR{Emarrows} contains radiation-effect arrows for embellishing two-terminal
+and other macros.
+The arrow stems are named {\sl A1}, {\sl A2},
+and each pair is drawn in a \verb|[]| block, with
+the names {\sl Head} and {\sl Tail} defined to
+aid placement near another device. The second argument specifies
+absolute angle in degrees (default 135 degrees).
+\begin{figure}[h!t]
+ \input Emarrows
+ \caption{Radiation arrows: {\tt em\_arrows({\sl type, angle, length})}}
+ \label{Emarrows}
+ \end{figure}
+The arrows are drawn relative to the diode direction by the {\tt LE}
+option in \FR{Diodes}. For absolute arrow directions, one can
+define a wrapper (see \SR{Writing:}) for the {\tt diode} macro to draw arrows
+at 45 degrees, for example:
+
+{\tt define(`myLED',`diode(`\$1'); em\_arrows(N,45)
+ with .Tail at last [].ne')}
+
+\begin{figure}[t!]
+ \input Fuses
+ \caption{Variations of the macros
+ {\tt fuse(\linespec, A|dA|B|C|D|E|S|HB|HC, {\sl wid}, {\sl ht})}
+ and {\tt cbreaker(\linespec,L|R,D|T|TS)}.}
+ \label{Fuses}
+ \end{figure}
+\begin{figure}[t!]
+ \input AmpTable
+ \caption{Amplifier, delay, and integrator.}
+ \label{AmpTable}
+ \end{figure}
+\begin{figure}[t!]
+ \input Switches
+ \caption{The
+ {\tt switch(\linespec,L|R,{\sl chars},L|B|D)}
+ macro is a wrapper for the macros
+ {\tt lswitch(\linespec,[L|R],[O|C][D][K][A])},
+ {\tt bswitch(\linespec,[L|R],[O|C])},
+ and the many-optioned
+ {\tt dswitch(\linespec,R,W[ud]B[K] {\sl chars})} shown.
+ The switch is drawn in the current drawing direction.
+ A second-argument {\tt R} produces a mirror
+ image with respect to the drawing direction.}
+ \label{Switches}
+ \end{figure}
+Most of the two-terminal elements are oriented; that is, they have
+a defined direction or polarity. Several element macros include an argument
+that reverses polarity, but there is also a more general mechanism,
+as follows.
+
+The first argument of the macro
+
+{\tt reversed(`}{\sl macro name}{\tt',}{\sl macro arguments}{\tt )}
+
+\noindent
+is the name of a two-terminal element in quotes, followed by the
+element arguments. The element is drawn with reversed direction.
+Thus,
+
+{\tt diode(right\_ 0.4); reversed(`diode',right\_ 0.4)}
+
+\noindent
+draws two diodes to the right, but the second one points left.
+
+Similarly, the macro
+
+{\tt resized(}{\sl factor},`{\sl macro name}',{\sl macro arguments}{\tt )}
+
+\noindent
+can be used to resize the body of an element by temporarily multiplying
+the {\tt dimen\_} macro by {\sl factor}. More general resizing should be
+done by redefining {\tt dimen\_} as described in \SR{Circuitscaling:}.
+These two macros can be nested; the following scales the above example
+by 1.8, for example
+
+{\tt resized(1.8,`diode',right\_ 0.4);}
+{\tt resized(1.8,`reversed',`diode',right\_ 0.4)}
+
+\FR{Variable} shows some two-terminal elements with
+arrows or lines overlaid to indicate variability using the macro
+
+{\tt variable(`}{\sl element}{\tt',{\sl type},{\sl angle},{\sl length})},
+
+\noindent
+where {\sl type} is one of {\tt A, P, L, N,} with {\tt C} or {\tt S}
+optionally appended to indicate continuous or stepwise variation.
+Alternatively, this macro
+can be invoked similarly to the label macros in
+\SR{Labels:} by specifying an empty first argument;
+thus, the following line draws the resistor in \FR{Variable}:
+
+ {\tt resistor(down\_ dimen\_); variable(,uN)}
+
+\begin{figure}[h!t]
+\vspace*{-\baselineskip}
+ \input Variable
+ \caption{Illustrating
+{\tt variable(`{\sl element}',%
+[A|P|L|[u]N][C|S],{\sl angle},{\sl length})}.
+ For example,\break {\tt variable(`capacitor(down\_ dimen\_)')} draws
+ the leftmost capacitor shown above, and {\tt variable(`resistor(down\_
+ dimen\_)',uN)} draws the resistor. The default angle is
+ 45${}^{\circ}$, regardless of the direction of the element. The array
+ on the right shows the effect of the second argument.}
+ \label{Variable}
+ \end{figure}
+
+\subsection{Branch-current arrows\label{Branchcurrent:}}
+Arrowheads and labels can be added to conductors using basic
+\pic statements. For example, the following line adds a labeled
+arrowhead at a distance {\tt alpha} along a horizontal line that has
+just been drawn. Many variations of this are possible:
+
+ \verb|arrow right arrowht from last line.start+(alpha,0) "$i_1$" above|
+
+%\enlargethispage{\baselineskip}
+Macros have been defined to simplify labelling two-terminal
+elements, as shown in \FR{currents}.
+The macro
+
+ {\tt b\_current({\sl label,} above\_|below\_, In|O[ut], Start|E[nd],
+ {\sl frac})}
+
+\noindent
+draws an arrow from the start of the last-drawn two-terminal element
+{\sl frac} of the way toward the body.
+\begin{figure}[h!t]
+ \ifpdf\vspace*{-0.5\baselineskip}\fi%
+ \input currents
+ \caption{Illustrating {\tt b\_current, larrow,} and {\tt rarrow}.
+ The drawing direction is to the right.}
+ \label{currents}
+ \end{figure}
+
+If the fourth argument is {\tt End}, the arrow is drawn from the end
+toward the body.
+If the third element is {\tt Out}, the arrow is drawn outward from the body.
+The first argument is the desired label, of which the default position is
+the macro {\tt above\_,} which evaluates to {\tt above} if the current
+direction is right or to {\tt ljust, below, rjust} if the current
+direction is respectively down, left, up. The label is assumed to be
+in math mode unless it begins with {\tt sprintf} or a double quote, in which
+case it is copied literally. A non-blank second argument specifies the
+relative position of the label with respect to the arrow, for example
+{\tt below\_,} which places the label below with respect to the current
+direction. Absolute positions, for example {\tt below} or {\tt ljust},
+also can be specified.
+
+For those who prefer a separate arrow to indicate the reference
+direction for current, the macros {\tt larrow({\sl label}, ->|<-,{\sl dist})}
+and {\tt rarrow({\sl label}, ->|<-,{\sl dist})} are provided. The label is
+placed outside the arrow as shown in \FR{currents}. The first
+argument is assumed to be in math mode unless
+it begins with {\tt sprintf} or a double
+quote, in which case the argument is copied literally. The third argument
+specifies the separation from the element.
+%\begin{figure}[hbt]
+% \input lrarrows
+% \caption{The {\tt larrow} and {\tt rarrow} macros draw
+% reference-direction arrows adjacent to the element.}
+% \label{lrarrows}
+% \end{figure}
+
+\pagebreak%
+\subsection{Labels\label{Labels:}}
+ Special macros for labeling two-terminal elements are included:
+\par
+{\tt
+ llabel(} {\sl arg1,arg2,arg3} {\tt )
+ \hfill\break\hspace*{\parindent}%
+ clabel(} {\sl arg1,arg2,arg3} {\tt )
+ \hfill\break\hspace*{\parindent}%
+ rlabel(} {\sl arg1,arg2,arg3} {\tt )
+ \hfill\break\hspace*{\parindent}%
+ dlabel(} {\sl long,lat,arg1,arg2,arg3,}{\tt[X][A|B][L|R])}
+
+The first macro places the three arguments, which are treated as math-mode
+strings, on the left side of the element block {\em with respect to the
+current direction:} {\tt up, down, left, right.}
+The second places the arguments along the centre, and the third along the
+right side.
+A simple circuit example with labels is shown in \FR{Loop}.
+The macro {\tt dlabel} performs these functions for an
+obliquely drawn element, placing the three macro arguments at
+{\tt vec\_(-long,lat),} {\tt vec\_(0,lat),} and {\tt vec\_(long,lat)}
+respectively relative to the centre of the element.
+In the fourth argument, an {\tt X} aligns the labels with respect to the line
+joining the two terminals rather than the element body, and
+{\tt A, B, L, R} use absolute {\tt above, below, left,} or {\tt right} alignment
+respectively for the labels.
+Labels beginning
+with {\tt sprintf} or a double quote are copied literally rather than
+assumed to be in math mode.
+
+ Arbitrary \latex including {\bsl\tt includegraphics,} for example,
+ can also be placed on a diagram using
+
+ {\tt "}{\sl \latex text}{\tt" wid {\sl width} ht {\sl height}
+ at {\sl position}}
+
+\begin{figure}[ht]
+ \vspace*{-\baselineskip}
+ \parbox{4in}{\small \verbatiminput{Loop.m4}}%
+ \hfill\raise-0.5in\hbox{\input Loop }
+ \vspace*{-\baselineskip}
+ \caption{A loop containing labeled elements, with its source code.}
+ \label{Loop}
+ \end{figure}
+
+\xection{Placing two-terminal elements\label{Placing:}}
+The length and position of a two-terminal element
+are defined by a straight-line segment and, possibly, a direction, so
+four numbers are required to place the element as in the following example:
+
+{\tt resistor(from (1,1) to (2,1))}.
+
+\noindent
+However, \pic has a very useful concept of the current point (explicitly
+named {\tt Here}); thus,
+
+{\tt resistor(to (2,1))}
+
+\noindent
+is equivalent to
+
+{\tt resistor(from Here to (2,1)).}
+
+Any defined position can be used; for example, if {\sl C1} and {\sl L2}
+are names of previously defined two-terminal elements,
+then, for example, the following places the resistor:
+
+{\tt resistor(from L2.end to C1.start)}
+
+A line segment starting at the current position can also be defined using
+a direction and length.
+To draw a resistor up $d$ units from the current position, for example:
+
+{\tt resistor(up\_ d)}
+
+\noindent
+\Pic stores the current drawing direction,
+the latter unfortunately limited to {\tt up, down, left, right,}
+which is assumed when necessary.
+The circuit macros need to know the current direction, so
+whenever {\tt up, down, left, right} are used they should be written
+respectively as the macros {\tt up\_, down\_, left\_, right\_} as in
+the above example.
+
+To allow drawing circuit objects in other than the standard four directions,
+a transformation matrix
+is applied at the macro level to generate the required \pic code.
+Potentially, the matrix can be used for other transformations.
+The macro
+
+{\tt setdir\_({\sl direction, default direction})}
+
+\noindent
+is preferred when setting drawing direction. The {\sl direction} arguments
+are of the form
+
+{\tt R[ight] | L[eft] | U[p] | D[own] | {\sl degrees}},
+
+\noindent
+but the macros
+{\tt Point\_(}{\sl degrees}{\tt ),}
+{\tt point\_(}{\sl radians}{\tt ),}
+and {\tt rpoint\_(}{\sl relative linespec}{\tt )} are employed in many macros
+to re-define the entries
+of the matrix
+(named {\tt m4a\_}, {\tt m4b\_}, {\tt m4c\_}, and {\tt m4d\_})
+for the required rotation.
+The macro {\tt eleminit\_} in the two-terminal elements invokes
+{\tt rpoint\_} with a specified or default {\sl linespec}
+to establish element length and direction.
+
+As shown in \FR{Oblique},
+``{\tt Point\_(-30); resistor}'' draws a resistor
+along a line with slope of~-30 degrees, and ``{\tt rpoint\_(to Z)}'' sets
+the current direction cosines to point from the current location to location Z.
+Macro {\tt vec\_(x,y)}
+evaluates to the position {\tt (x,y)} rotated as defined by the
+argument of the previous
+{\tt setdir\_, Point\_, point\_} or {\tt rpoint\_} command.
+The principal device used to define relative locations in the circuit macros
+is {\tt rvec\_(x,y)}, which evaluates to position {\tt Here + vec\_(x,y)}.
+Thus, {\tt line to rvec\_(x,0)} draws a line of length {\tt x} in the current
+direction.
+
+\FR{Oblique} illustrates that some hand placement of labels
+using {\tt dlabel} may be useful when elements are drawn obliquely.
+The figure also illustrates that any commas within \Mfour arguments must
+be treated specially because the arguments are separated by commas.
+Argument commas are protected either by parentheses as in
+{\tt inductor(from Cr to Cr+vec\_(elen\_,0))}, or by multiple single quotes
+as in {\tt ``,'',} as necessary.
+Commas also may be avoided by writing
+{\tt 0.5 between L and T} instead of {\tt 0.5<L,T>.}
+\begin{figure}[h!t]
+\vspace{-\baselineskip}
+ \parbox{4.5in}{\small \verbatiminput{Oblique.m4}}%
+ \hfill\raise-0.7in\llap{\hbox{\input Oblique }}%
+ \vspace{-\baselineskip}
+ \caption{Illustrating elements drawn at oblique angles.}
+ \label{Oblique}
+ \end{figure}
+
+\subsection{Series and parallel circuits\label{Seriesandparallel:}}
+
+To draw elements in series, each element can be placed by specifying
+its line segment as described previously, but the \pic language
+makes some geometries particularly simple. Thus,
+
+{\tt setdir\_(Right)\\ \hspace*{\parindent}%
+ resistor; llabel(,R); capacitor; llabel(,C);
+ inductor; llabel(,L)}
+
+\noindent
+draws three elements in series
+as shown in the top line of \FR{Series}.
+\begin{figure}[h!t]
+\vspace{-\baselineskip}
+ \input Series
+ \caption{Three ways of drawing basic elements in series.}
+ \label{Series}
+ \end{figure}
+However, the default length {\tt elen\_}
+appears too long for some diagrams. It can be redefined temporarily
+(to {\tt dimen\_}, say),
+by enclosing the above line in the pair
+
+{\tt pushdef(`elen\_',dimen\_)
+ resistor$\ldots$ popdef(`elen\_')}
+
+\noindent
+with the result shown in the middle row of the figure.
+
+Alternatively, the length of each element can be tuned individually; for
+example, the capacitor in the above example can be shortened as shown,
+producing the bottom line of \FR{Series}:
+
+{\tt resistor; llabel(,R)\\
+ \hspace*{\parindent}%
+ capacitor(right\_ dimen\_/4); llabel(,C)\\
+ \hspace*{\parindent}%
+ inductor; llabel(,L)}
+
+If a macro that takes care of common cases automatically is to be preferred,
+you can use the macro {\tt series\_({\sl elementspec, elementspec, $\ldots$})}.
+This macro draws elements of length {\tt dimen\_} from the current
+position in the current drawing
+direction, enclosed in a {\tt [ ]} block. The internal names
+{\tt Start}, {\tt End}, and {\tt C} (for centre) are defined, along with
+any element labels. An {\sl elementspec} is of the form
+{\tt[{\sl Label}:] {\sl element}; [{\sl attributes}]},
+where an attribute is zero or more of
+ {\tt llabel($\ldots$), rlabel($\ldots$)}, or {\tt b\_current($\ldots$)}.
+
+Drawing elements in parallel requires a little more effort but, for example,
+three elements can be drawn in parallel using the code snippet shown,
+producing the left circuit in \FR{ParSeries}:
+\begin{verbatim}
+ define(`elen_',dimen_)
+ L: inductor(right_ 2*elen_,W); llabel(+,L,-)
+ R1: resistor(right elen_ from L.start+(0,-dimen_)); llabel(,R1)
+ R2: resistor; llabel(,R2)
+ C: capacitor(right 2*elen_ from R1.start+(0,-dimen_)); llabel(,C)
+ line from L.start to C.start
+ line from L.end to C.end
+\end{verbatim}
+
+\begin{figure}[h!t]
+% \vspace*{-\baselineskip}
+ \input ParSeries
+ \vspace*{-\baselineskip}
+ \caption{Illustrating the macros {\tt parallel\_} and {\tt series\_},
+ with {\tt Start} and {\tt End} points marked.}
+ \label{ParSeries}
+ \end{figure}
+
+A macro that produces the same effect automatically is
+
+{\tt parallel\_({\LQ {\sl elementspec}\RQ, \LQ {\sl elementspec}\RQ,}
+ $\ldots$)}
+
+The arguments {\em must be quoted} to delay expansion, unless an argument
+is a nested {\tt parallel\_} or {\tt series\_} macro,
+in which case it is not quoted.
+The elements are drawn in a {\tt [ ]} block with defined points
+{\tt Start}, {\tt End}, and {\tt C}.
+An {\sl elementspec} is of the form
+
+{\tt [Sep={\sl val};][{\sl Label}:] {\sl element}; [{\sl attributes}]}
+
+\noindent
+where an {\sl attribute} is of the form
+
+{\tt [llabel($\ldots$);] | [rlabel($\ldots$)] | [b\_current($\ldots$);]}
+
+Putting {\tt Sep={\sl val};} in the first branch sets the default
+separation of all branches to {\sl val}; in a later
+element, {\tt Sep={\sl val}}; applies only to that branch.
+An element may have normal arguments but should
+not change the drawing direction.
+
+%\pagebreak%
+\xection{Composite circuit elements\label{Composite:}}
+Many basic elements are not two-terminal. These elements are usually enclosed in
+a \verb|[ ]| \pic block, and contain named interior locations and components.
+The block must be placed by using its compass corners, thus:
+ {\sl element} {\tt with} {\sl corner} {\tt at} {\sl position}
+or, when the block contains a predefined location, thus:
+ {\sl element} {\tt with} {\sl location} {\tt at} {\sl position}.
+A few macros are positioned with the first argument;
+the {\tt ground} macro, for example:
+ {\tt ground(}{\tt at} {\sl position}{\tt ).}
+In some cases, an invisible line can be specified by the first argument
+to determine length and direction (but not position) of the block.
+
+Nearly all elements drawn within blocks can be customized by adding an
+extra argument, which is executed as the last item within the block.
+
+The macro {\tt
+ potentiometer(\linespec,{\sl cycles},{\sl fractional pos},{\sl length},
+ $\ldots$)},
+shown in \FR{Potentiometers},
+first draws a resistor along the specified line, then adds arrows for taps
+at fractional positions along the body, with default or specified length.
+A negative length draws the arrow from the right of the current drawing
+direction.
+\begin{figure}[h!t]
+ \input Potentiometers
+ \caption{Default and multiple-tap potentiometer.}
+ \label{Potentiometers}
+ \end{figure}
+
+The macro {\tt
+ addtaps([{\sl arrowhd} | type={\sl arrowhd};name={\sl Name}],
+ {\sl fraction, length, fraction, length,}
+ $\ldots$)},
+shown in \FR{Taps}, will add taps to the
+immediately preceding two-terminal element.
+\begin{figure}[h!t]
+ \input Taps
+ \caption{Macros for adding taps to two-terminal elements.}
+ \label{Taps}
+ \end{figure}
+However, the default names
+{\tt Tap1, Tap2} $\ldots$ may not be unique in the current scope. An
+alternative name for the taps can be specified or, if preferable, the
+tapped element can be drawn in a [ ] block using the macro {\tt
+ tapped(`{\sl two-terminal element}',
+ [{\sl arrowhd} | type={\sl arrowhd};name={\sl Name}],
+ {\sl fraction, length, fraction, length,} $\ldots$)}.
+ Internal names {\tt .Start, .End,} and {.C} are defined automatically,
+ corresponding to the drawn element. These and the tap names can be used
+ to place the block.
+These two macros require the two-terminal element to be drawn either up,
+down, to the left, or to the right; they are not designed for obliquely
+drawn elements.
+
+A few composite symbols derived from two-terminal elements
+are shown in \FR{Composite}.
+\begin{figure}[h!t]
+ \vspace*{-0.5ex}
+ \input Composite
+ \vspace*{-0.5ex}
+ \caption{Composite elements {\tt KelvinR({\sl cycles},[R],{\sl cycle wid})}
+ and {\tt FTcap({\sl chars})} .}
+ \label{Composite}
+ \end{figure}
+
+The ground symbol is shown in \FR{Grounds}.
+The first argument specifies position; for example, the two lines shown
+have identical effect:
+
+{\tt move to (1.5,2); ground
+
+ground(at (1.5,2)) }
+
+\noindent The second argument truncates
+the stem, and the third defines the symbol type.
+The fourth argument specifies the angle at which the symbol is drawn,
+with D (down) the default.
+This macro is one of several in which a temporary drawing direction
+is set using the
+ {\tt setdir\_( U|D|L|R|{\sl degrees, default} R|L|U|D|{\sl degrees} )}
+macro and reset at the end using {\tt resetdir\_}.
+\begin{figure}[ht!]
+ \input Grounds
+ \caption{The
+ {\tt ground( at }{\sl position}{\tt,
+ T, N|F|S|L|P|E, U|D|L|R|{\sl degrees} )}
+ macro.}
+ \label{Grounds}
+ \end{figure}
+
+The arguments of the macro
+{\tt antenna( at }{\sl position}{\tt,
+ T, A|L|T|S|D|P|F, U|D|L|R|{\sl degrees} )}
+shown in \FR{Antennas} are similar to those of {\tt ground}.
+\begin{figure}[h!t]
+ \input Antennas
+ \caption{Antenna symbols, with macro arguments shown above and
+ terminal names below.}
+ \label{Antennas}
+ \end{figure}
+
+\FR{Opamp} illustrates the macro
+{\tt opamp({\sl\linespec, - label, + label, size, chars})\label{OPAMP}}.
+\begin{figure}[b!t]
+ \ifpdf\vspace*{-0.5\baselineskip}\fi%
+ \input Opamp
+ \caption{Operational amplifiers. The {\tt P} option adds
+ power connections. The second and third arguments can be used
+ to place and rotate arbitrary text at {\tt In1} and {\tt In2}.}
+ \label{Opamp}
+ \end{figure}
+The element is enclosed in a block
+containing the predefined internal locations shown.
+These locations can be referenced in later
+commands, for example as ``{\tt last [].Out}.''
+The first argument defines the direction and length of the opamp, but the
+position is determined either by the enclosing block of the opamp,
+or by a construction such as ``{\tt opamp with .In1 at Here}'', which places
+the internal position {\sl In1} at the specified location.
+There are optional second and third arguments for which the defaults
+are {\tt \char92{}scriptsize\$-\$} and {\tt \char92{}scriptsize\$+\$}
+respectively, and the fourth argument changes the size of the opamp.
+The fifth argument is a string of characters. {\tt P}
+adds a power connection, {\tt R} exchanges the second and
+third entries, and {\tt T} truncates the opamp point.
+
+Typeset text associated with circuit elements is not rotated by default,
+as illustrated by the second and third opamps in \FR{Opamp}.
+The {\tt opamp} labels can be rotated if necessary by
+using postprocessor commands (for example \PSTricks \verb|\rput|)
+as second and third arguments.
+
+The code in \FR{oax} places an opamp with three connections.
+\begin{figure}[h!t]
+ \parbox{4in}{\small \verbatiminput{oaxbody.m4}}%
+ \quad\raise-0.2in\hbox{\input oax }%
+ \vspace{-\baselineskip}
+ \caption{A code fragment invoking the
+ {\tt opamp(\linespec,-,+,{\sl size},[R][P])} macro.}
+ \label{oax}
+ \end{figure}
+
+\FR{Xform} shows variants of the transformer macro,
+which has predefined internal locations
+{\sl P1,} {\sl P2,} {\sl S1,} {\sl S2,} {\sl TP,} and {\sl TS.}
+The first argument
+specifies the direction and distance from {\sl P1} to {\sl P2}, with
+position determined by the enclosing block as for opamps. The second
+argument places the secondary side of the transformer to the left
+or right of the drawing direction. The optional third and fifth arguments
+specify the number of primary and secondary arcs respectively.
+If the fourth argument string contains an {\tt A}, the iron core
+is omitted;
+if a {\tt P}, the core is dashed (powder);
+and if it contains a {\tt W}, wide windings are drawn.
+A {\tt D1} puts phase dots at the {\sl P1, S1} end, {\tt D2} at the
+{\sl P2, S2} ends, and {\tt D12} or {\tt D21} puts dots at opposite ends.
+\begin{figure}[h!t]
+ \ifpdf\vspace*{-\baselineskip}\fi%
+ \input Xform
+ \vspace{-\baselineskip}
+ \caption{The {\tt transformer(\linespec,L|R,{\sl np},%
+[A|P][W|L][D1|D2|D12|D21],{\sl ns})}
+ macro (drawing direction {\tt down}), showing predefined terminal
+ and centre-tap points.}
+ \label{Xform}
+ \end{figure}
+\iffalse
+A transformer with four connections is illustrated
+in \FR{tran}.
+\begin{figure}[hbt]
+ \parbox{4in}{\small \verbatiminput{tranbody.m4}}%
+ \quad\raise-0.2in\hbox{\input tran }%
+ \vspace{-\baselineskip}
+ \caption{Showing the
+ {\tt transformer(\linespec,L|R,np,A,ns)} macro.}
+ \label{tran}
+ \end{figure}
+\fi
+
+%\enlargethispage{\baselineskip}
+\FR{Audio} shows some audio devices, defined in {\tt []} blocks,
+with predefined internal locations as shown.
+\begin{figure}[h!t]
+ \ifpdf\vspace*{-\baselineskip}\fi%
+ \input Audio
+ \ifpdf\vspace*{-\baselineskip}\fi%
+ \caption{Audio components:
+ {\tt speaker(U|D|L|R|{\sl degrees},{\sl size},{\sl type}),
+ bell, microphone, buzzer,
+ earphone}, with their internally named positions and components.}
+ \label{Audio}
+ \end{figure}
+The first argument specifies the device orientation.
+
+Thus,
+
+{\tt S: speaker(U) with .In2 at Here}
+
+\noindent
+%\enlargethispage{\baselineskip}
+places an upward-facing speaker with input {\sl In2} at the
+current location.
+
+The {\tt nport({\sl box specs {\tt[;} other commands{\tt]},
+ nw, nn, ne, ns, space ratio, pin lgth, style})}
+macro is shown in \FR{Nport}.
+\begin{figure}[h!t]
+ \ifpdf\vspace*{-\baselineskip}\fi
+ \input Nport
+ \ifpdf\vspace*{-\baselineskip}\fi
+ \caption{The {\tt nport} macro draws a sequence of pairs of named pins
+ on each side of a box. The pin names are shown. The default is a twoport.
+ The {\tt nterm} macro draws single pins instead of pin pairs.}
+ \label{Nport}
+ \end{figure}
+The macro begins with the line
+ \verb|define(`nport',`[Box: box `$1'|,
+so the first argument is a box specification such as size, fill,
+or text.
+The second to fifth arguments specify the number of ports
+(pin pairs) to be drawn respectively on the west, north, east, and south
+sides of the box. The end of each pin is named according to the
+side, port number, and $a$ or $b$ pin, as shown.
+The sixth argument
+specifies the ratio of port width to inter-port space, the seventh is
+the pin length, and setting the eighth argument to {\tt N} omits the pin
+dots.
+The macro ends with \verb|`$9']')|, so that a ninth argument can be used
+to add further customizations within the enclosing block.
+
+The {\tt nterm({\sl box specs, nw, nn, ne, ns, pin lgth, style})} macro
+illustrated in \FR{Nport} is similar to the {\tt nport} macro but
+has one fewer argument, draws single pins instead of pin pairs, and
+defaults to a 3-terminal box.
+
+Many custom labels or added elements may be required, particularly for
+2-ports\label{Nports:}. These elements can be added using the first
+argument and the ninth of the {\tt nport} macro.
+For example, the following code adds a pair of labels to the box
+immediately after drawing it but within the enclosing block:
+
+{\tt nport(; {`"${}0$"'\ at Box.w ljust; `"$\infty$"'\ at
+ Box.e rjust})}
+
+If this trick were to be used extensively, then the following custom wrapper
+would save typing, add the labels, and pass all arguments to
+{\tt nport}:
+
+\begin{verbatim}
+define(`nullor',`nport(`$1'
+ {`"${}0$"' at Box.w ljust
+ `"$\infty$"' at Box.e rjust},shift($@))')
+\end{verbatim}
+
+The above example and the related gyrator macro are illustrated in
+\FR{NLG}.
+\begin{figure}[h!t]
+ \input NLG
+ \ifpdf\vspace*{-1.5\baselineskip}\fi%
+ \caption{The {\tt nullor} example and the {\tt gyrator}
+ macro are customizations of the {\tt nport} macro.}
+ \label{NLG}
+ \end{figure}
+
+A basic winding macro for magnetic-circuit sketches and similar figures
+is shown in \FR{Windings}.
+\begin{figure}[h!t]
+ \vspace*{-\baselineskip}%
+% \ifpdf\vspace*{-2\baselineskip}\else \vspace{-\baselineskip}\fi
+ \input Windings
+ \ifpdf\vspace*{-\baselineskip}\else\vspace*{-1ex}\fi
+ \caption{The {\tt winding(L|R, diam, pitch, turns, core wid, core color)}
+ macro draws a coil with axis along the current drawing direction.
+ Terminals {\tt T1} and {\tt T2} are defined.
+ Setting the first argument to {\tt R} draws a right-hand winding.}
+ \label{Windings}
+ \end{figure}
+For simplicity, the complete spline
+is first drawn and then blanked in appropriate places using the background
+(core) color (\verb!lightgray! for example, default \verb!white!).
+
+\FR{Relay} shows the macro {\tt contact({\sl chars})},
+which contains predefined locations {\sl P, C, O}
+for the armature and normally closed and normally
+open terminals.
+An {\tt I} in the first argument draws open circles for contacts.
+The macro {\tt relay({\sl poles, chars})}
+defines coil terminals {\sl V1, V2} and contact
+terminals {\sl P$_i$, C$_i$, O$_i$.}
+\begin{figure}[ht]
+ \ifpdf\vspace*{-\baselineskip}\else\vspace*{-0.5\baselineskip}\fi%
+ \input Relay
+ \vspace{-1ex}
+ \caption{The {\tt contact({\sl chars})}
+ and {\tt relay({\sl poles, chars})}
+ macros (default direction right).}
+ \label{Relay}
+ \end{figure}
+
+The double-throw switches shown in \FR{NPDT} are drawn in the
+current drawing direction like the two-terminal elements, but are
+composite elements that must be placed accordingly.
+\begin{figure}[h!t]
+ \ifpdf\vspace*{-0.5\baselineskip}\fi%
+ \input NPDT
+ \ifpdf\vspace*{-0.5\baselineskip}\fi%
+ \caption{Multipole double-throw switches drawn by
+ {\tt NPDT({\sl npoles}, [R])}.}
+ \label{NPDT}
+ \end{figure}
+
+The {\tt jack} and {\tt plug} macros and their defined points are
+ illustrated in \FR{Jack}.
+\begin{figure}[h!t]
+ \input Jack
+ \vspace{-1ex}
+ \caption{The {\tt jack(U|D|L|R|{\sl degrees}, {\sl chars})}
+ and {\tt plug(U|D|L|R|{\sl degrees},[2|3][R])} components
+ and their defined points.}
+ \label{Jack}
+ \end{figure}
+ The first argument of both macros
+ establishes the drawing direction. The second argument is a string of
+ characters defining drawn components.
+ An {\tt R} in the string specifies a
+ right orientation with respect to the drawing direction.
+ The two principal terminals of
+ the jack are included by putting \hbox{{\tt L} {\tt S}}
+%
+% This is a kludge to put a blank line on the bottom
+\phantom{or both into the string with associated make ({\tt M})
+or break ({\tt B}) points. Thus, {\tt LMB} within the third}\hfill\break
+\phantom{or both into the string with associated make ({\tt M})
+or break ({\tt B}) points. Thus, {\tt LMB} within the third}\hfill\break
+%
+%
+ or both into the string with associated make ({\tt M})
+ or break ({\tt B}) points. Thus, {\tt LMB} within the third
+ argument draws the {\tt L} contact with
+ associated make and break points. Repeated {\tt L[M|B]}
+ or {\tt S[M|B]} substrings add auxiliary contacts with
+ specified make or break points.
+
+%\pagebreak
+A macro for drawing headers is in \FR{Headers},
+and some experimental connectors are shown in \FR{Conn} and \FR{Pconn}.
+The {\tt tstrip} macro allows {\sl key}{\tt =}{\sl value}{\tt ;} arguments
+\begin{figure}[h!t]
+ \ifpdf\vspace*{-0.5\baselineskip}\fi%
+ \input Headers
+ \ifpdf{\vspace*{-0.5ex}}\fi%
+ \caption{Macro {\tt Header(1|2, {\sl rows, wid, ht, type})}.}
+ \label{Headers}
+ \end{figure}
+for width and height.
+\begin{figure}[h!t]
+ \input Conn
+ \ifpdf{\vspace*{-0.5ex}}\fi%
+ \caption{Macros {\tt tstrip(R|L|U|D|{\sl degrees}, {\sl chars})},
+ {\tt ccoax(at} {\sl location}, {\tt M|F, {\sl diameter})},
+ {\tt tconn(\linespec, >|>>|<|<<|O[F], {\sl wid})}, and
+ {\tt tbox({\sl text, wid, ht}, <|>|<>,{\sl type})}. }
+ \label{Conn}
+ \ifpdf{\vspace*{-1ex}}\fi%
+ \end{figure}
+\begin{figure}[h!t]
+ \ifpdf{\vspace*{-1ex}}\fi%
+ \input Pconn
+ \ifpdf{\vspace*{-0.5ex}}\fi%
+ \caption{A small set of power connectors drawn by
+ {\tt pconnex(R|L|U|D|}{\sl degrees, chars}{\tt)}. Each connector has
+ an internal {\tt H}, {\tt N}, and where applicable, a {\tt G} shape.}
+ \label{Pconn}
+ \end{figure}
+
+\subsection{Semiconductors\label{Semiconductors:}}%
+\FR{Bip} shows the variants of bipolar transistor macro
+{\tt bi\_tr(\linespec,L|R,P,E)}
+which contains predefined internal locations {\sl E},
+{\sl B}, {\sl C}.
+The first argument defines the distance and direction
+from {\sl E} to {\sl C,} with location determined by the enclosing
+block as for other elements, and the base placed
+\begin{figure}[h!b]
+ \ifpdf\vspace*{-0.5\baselineskip}\fi%
+ \input Bip
+ \ifpdf\vspace*{-0.5\baselineskip}\fi%
+ \caption{Bipolar transistor variants (current direction upward).}
+ \label{Bip}
+ \end{figure}
+to the left or right of the
+current drawing direction according to the second argument. Setting the third
+argument to {\tt P} creates a PNP device instead of NPN, and setting the
+fourth to {\tt E} draws an envelope around the device.
+\FR{Darlington} shows a composite macro with several optional internal elements.
+\begin{figure}[h!t]
+ \input Darlington
+ \caption{Macro {\tt Darlington(L|R,[E][P][B1][E1|R1][E2|R2][D][Z])},
+ drawing direction {\tt up\_}.}
+ \label{Darlington}
+ \end{figure}
+
+The code fragment example in \FR{bitr} places a bipolar transistor,
+connects a ground to the emitter, and connects a resistor to the collector.
+\begin{figure}[h!t]
+\vspace*{-\baselineskip}
+ \quad\quad\parbox{4in}{\small \verbatiminput{bitrbody.m4}}%
+ \quad\raise-0.4in\hbox{\input bitr }%
+ \vspace{-\baselineskip}
+ \caption{The {\tt bi\_tr(\linespec,L|R,P,E)} macro.}
+ \label{bitr}
+ \end{figure}
+
+The {\tt bi\_tr} and {\tt igbt} macros are wrappers for
+the macro {\tt bi\_trans(\linespec, L|R, {\sl chars}, E)}, which
+draws the components of the transistor according to the characters in its
+third argument. For example, multiple emitters and collectors can be
+specified as shown in \FR{bitrans}.
+\begin{figure}[h!t]
+\vspace*{-0.5\baselineskip}
+ \input bi_trans
+ \caption{The {\tt bi\_trans(\linespec,L|R,{\sl chars},E)} macro.
+ The sub-elements are specified by the third argument. The substring
+ {\tt E}{\sl n} creates multiple emitters {\sl E0} to {\sl En}.
+ Collectors are similar.}
+ \label{bitrans}
+ \end{figure}
+
+A UJT macro with predefined internal locations {\sl B1,} {\sl B2,}
+and {\sl E} is shown in \FR{ujt},
+and a thyristor macro with predefined internal locations
+ {\sl G} and {\sl T1,} {\sl T2,} or
+ {\sl A,} {\sl K} is in \FR{thyristor}.
+Except for the {\sl G} terminal, a thyristor (the {\tt IEC} variant excluded)
+\begin{figure}[h!t]
+ \ifpdf\vspace*{-\baselineskip}\else\vspace*{-0.5\baselineskip}\fi%
+ \input ujt
+ \ifpdf\vspace*{-0.5\baselineskip}\fi%
+ \caption{UJT devices, with current drawing direction {\tt up\_}. }
+ \label{ujt}
+ \end{figure}
+\begin{figure}[h!t]
+ \ifpdf\vspace*{-\baselineskip}\else\vspace*{-0.5\baselineskip}\fi%
+ \input thyristor
+ \vspace*{-1ex}
+ \caption{The top two rows illustrate use of the
+ {\tt thyristor({\sl linespec, chars})} macro,
+ drawing direction {\tt down\_}, and the bottom row shows wrapper
+ macros (drawing direction {\tt right\_}) that place
+ the thyristor like a two-terminal element. Append {\tt K}
+ to the second argument to draw open arrowheads.}
+ \label{thyristor}
+ \end{figure}
+is much like an two-terminal element. The wrapper macro
+{\tt scr({\sl linespec, chars, label})} and similar macros
+{\tt scs, sus,} and {\tt sbs} place thyristors
+using {\sl linespec} as for a two-terminal element,
+but require a third argument for the label for the compound block; thus,
+
+{\tt scr(from A to B,{,}Q3); line right from Q3.G}
+
+\noindent
+draws the element from position {\sl A} to position {\sl B} with label
+{\sl Q3}, and draws a line from {\sl G}.
+
+Some FETs with predefined internal locations {\sl S,} {\sl D,} and {\sl G} are
+also included, with similar arguments to those of {\tt bi\_tr,} as shown in
+\FR{fet}.
+In all cases the first argument is a linespec,
+and entering
+{\tt R} as the second argument orients the {\sl G} terminal to the right of the
+current drawing direction.
+The macros in the top three rows of the figure are wrappers for the
+general macro {\tt mosfet(\linespec,R,{\sl characters},E)}.
+The third argument of this macro is a subset of the characters
+$\{${\tt BDEFGLMQRSTXZ}$\}$, each letter corresponding to
+a diagram component as shown in the bottom row of the figure.
+Preceding the characters {\tt B}, {\tt G}, and {\tt S} by {\tt u} or {\tt d}
+adds an up or down arrowhead to the pin, preceding {\tt T} by {\tt d}
+negates the pin, and preceding {\tt M} by {\tt u} or {\tt d} puts the pin
+at the drain or source end respectively of the gate.
+The obsolete letter {\tt L} is equivalent to {\tt dM} and has been kept
+temporarily for compatibility.
+This system allows considerable freedom in choosing or customizing components,
+as illustrated in \FR{fet}.
+\begin{figure}[h!t]
+ \ifpdf\vspace*{-\baselineskip}\fi%
+ \input fet
+ \ifpdf\vspace*{-\baselineskip}\fi%
+ \caption{JFET, insulated-gate enhancement and depletion MOSFETs,
+ and simplified versions.
+ These macros are wrappers that invoke the {\tt mosfet}
+ macro as shown in the middle and bottom rows.
+ The two lower-right examples show custom devices, the first
+ defined by omitting the substrate connection, and the second
+ defined using a wrapper macro.}
+ \label{fet}
+ \end{figure}
+
+\pagebreak
+The number of possible semiconductor symbols is very
+large, so these macros must be regarded as prototypes.
+Often an element is a minor modification of existing elements. For example,
+the {\tt thyristor(\linespec, {\sl chars})} macro illustrated in
+\FR{thyristor} is derived from the diode and bipolar transistor macros.
+Another example is the {\tt tgate} macro shown in \FR{Tgate}, which
+also shows a pass transistor.
+\begin{figure}[h!t]
+ \ifpdf\vspace*{-\baselineskip}\fi%
+ \input Tgate
+ \caption{The {\tt tgate({\sl linespec,} [B][R|L])} element, derived from
+ a customized diode and {\tt ebox}, and the
+ {\tt ptrans(\linespec, [R|L])} macro.
+ These are not two-terminal elements, so the {\sl linespec} argument
+ defines the direction and length of the line from $A$ to $B$ but not
+ the element position.}
+ \label{Tgate}
+ \end{figure}
+
+Some other non-two-terminal macros are {\tt dot}, which has an
+optional argument ``{\tt at} {\sl location}'', the line-thickness
+macros, the {\tt fill\_} macro, and {\tt crossover}, which is a useful if
+archaic method to show non-touching conductor crossovers, as in
+\FR{bistable}.
+\begin{figure}[h!t]
+ \input bistable
+ \vspace{-1ex}
+ \caption{Bipolar transistor circuit, illustrating {\tt crossover}
+ and colored elements.}
+ \label{bistable}
+ \end{figure}
+
+This figure also illustrates how elements and labels can be colored
+using the macro
+
+{\tt rgbdraw({\sl r}, {\sl g}, {\sl b}, {\sl drawing commands})}
+
+\noindent
+where the {\sl r, g, b} values are in the range 0 to 1
+(integers from 0 to 255 for \SVG)
+ to specify the rgb color.
+This macro is a wrapper for the following, which may be more convenient
+if many elements are to be given the same color:
+
+ {\tt setrgb({\sl r}, {\sl g}, {\sl b})}
+ \hfill\break\hspace*{\parindent}%
+ {\sl drawing commands}
+ \hfill\break\hspace*{\parindent}%
+ {\tt resetrgb}
+
+A macro is also provided for colored fills:
+
+{\tt rgbfill({\sl r}, {\sl g}, {\sl b}, {\sl drawing commands})}
+
+\noindent%
+These macros depend heavily on the postprocessor and are intended only for
+\PSTricks, \TPGF, \MetaPost, \SVG, and the Postscript or PDF output of \dpic.
+
+\xection{Corners\label{Corners:}}%
+If two straight lines meet at an angle then, depending on the postprocessor,
+the corner may not be mitred or rounded unless the two lines belong to
+a multisegment line, as illustrated in \FR{Corners}.
+\begin{figure}[ht]
+ \input Corners
+ \caption{Producing mitred angles and corners.}
+ \label{Corners}
+ \end{figure}
+This is normally
+not an issue for circuit diagrams unless the figure is magnified or thick
+lines are drawn. Rounded corners can be obtained by setting post-processor
+parameters, but the figure shows the effect of
+macros {\tt round} and {\tt corner}.
+The macros
+{\tt mitre\_({\sl Position1,Position2,Position3,length,attributes})}
+and
+{\tt Mitre\_({\sl Line1,Line2,length,attributes})}
+may assist as shown.
+Otherwise, a right-angle line can be extended
+by half the line thickness (macro {\tt hlth}) as shown on the upper row
+of the figure,
+or a two-segment line can be overlaid at the corner to produce the same effect.
+
+\xection{Looping\label{Looping:}}
+Sequential actions can be performed using either the
+ \dpic command
+
+{\tt for {\sl variable}={\sl expression} to {\sl expression}
+ [by {\sl expression}] do $\lbrace$ {\sl actions} $\rbrace$}
+
+\noindent
+or at the
+\Mfour processing stage. The {\tt libgen} library defines the macro
+
+{\tt for\_({\sl start}, {\sl end}, {\sl increment}, `{\sl actions}')}
+
+\noindent
+for this and other purposes. Nested loops are allowed and the innermost loop
+index variable is {\tt m4x.}
+The first three arguments must be
+integers and the {\sl end} value must be reached exactly; for example,
+\verb|for_(1,3,2,`print In`'m4x')| prints locations {\sl In1} and {\sl In3},
+but \verb|for_(1,4,2,`print In`'m4x')| does not terminate since the
+index takes on values 1, 3, 5, $\ldots$.
+
+Repetitive actions can also be performed with the {\tt libgen} macro
+
+{\tt Loopover\_(`{\sl variable}', {\sl actions}, {\sl value1},
+ {\sl value2}, $\ldots$)}
+
+\noindent
+which evaluates {\sl actions} for each instance of {\sl variable} set
+to {\sl value1, value2, $\ldots$}.
+
+\xection{Logic gates\label{Logicgates:}}
+\FR{Logic} shows the basic logic gates included in
+library {\tt liblog.m4}.
+The first argument of the gate macros can be an integer $N$ from $0$ to $16,$
+specifying the number of input
+locations {\tt In1,} $\ldots$ {\tt In}$N,$ as illustrated for
+the NOR gate in the figure.
+By default, $N=2$ except for macros {\tt NOT\_gate} and {\tt BUFFER\_gate},
+which have one input {\tt In1} unless they are given a
+first argument, which is treated as the line specification of a
+two-terminal element.
+\begin{figure}[h!t]
+ \input Logic
+ \caption{Basic logic gates. The input and output locations of
+ a three-input NOR gate are shown. Inputs are negated by
+ including an {\tt N} in the second argument letter sequence. A {\tt B}
+ in the second argument produces a box shape as shown in the rightmost
+ column, where the second example has AND functionality and
+ the bottom two are examples of exclusive OR functions.}
+ \label{Logic}
+ \end{figure}
+
+Input locations retain their positions relative to the gate body
+regardless of gate orientation, as in \FR{FF}.
+\begin{figure}[h!t]
+ \vspace*{-\baselineskip}
+ \parbox{4.75in}{\small \verbatiminput{FF.m4}}%
+ \input FF
+ \vspace*{-\baselineskip}
+ \caption{$SR$ flip-flop.}
+ \label{FF}
+ \end{figure}
+\begin{figure}[h!t]
+ \input mplex
+ \caption{Eight-input multiplexer, showing a gate with wings.}
+ \label{exVIII}
+ \end{figure}
+Beyond a default number (6) of inputs, the
+gates are given wings as in \FR{exVIII}.
+\pagebreak
+Negated inputs or outputs are marked by circles drawn using the
+\verb|NOT_circle| macro. The name marks the point at the outer edge of the
+circle and the circle itself has the same name prefixed by~{\tt N\_}.
+For example, the output circle of a nand gate is named
+{\tt N\_Out} and the outermost point of the circle is named {\tt Out.}
+Instead of a number, the first argument can be a sequence of letters {\tt P}
+or {\tt N} to define normal or negated inputs; thus for example,
+{\tt NXOR\_gate(NPN)} defines a 3-input nxor gate with not-circle
+inputs {\tt In1} and {\tt In3} and normal input {\tt In2}
+as shown in the figure.
+The macro {\tt IOdefs} can also be used to create a sequence of custom
+named inputs or outputs.
+
+Gates are typically not two-terminal elements and are normally drawn
+horizontally or vertically (although arbitrary directions may be set
+with e.g. {\tt Point\_({\sl degrees})}).
+Each gate is contained in a
+block of typical height {\tt 6*L\_unit} where {\tt L\_unit} is a macro
+intended to establish line separation for an imaginary grid on which
+the elements are superimposed.
+
+Including an \verb|N| in the second
+argument character sequence of any gate negates the inputs, and including
+\verb|B| in the second argument invokes the
+general macro {\tt BOX\_gate([P|N]...,[P|N],{\sl horiz size},{\sl
+vert size},{\sl label})}, which draws box gates. Thus, {\tt
+BOX\_gate(PNP,N,,8,\char92 geq 1)} creates a gate of default width,
+eight {\tt L\_unit}s height, negated output, three inputs with the
+second negated, and internal label ``$\geq1$''.
+If the fifth argument begins with {\tt sprintf} or a double quote then
+the argument is copied literally; otherwise it is treated as scriptsize
+mathematics.
+
+The macro {\tt BUFFER\_gate(\linespec,[N|B],{\sl wid},{\sl ht},%
+ [N|P]\char42,[N|P]\char42)}
+is a wrapper for the composite element {\tt BUFFER\_gen}.
+If the second argument is {\tt B}, then a box gate is drawn; otherwise
+the gate is triangular. Arguments 5 and 6 determine the number of defined
+points along the northeast and southeast edges respectively, with an {\tt N}
+adding a NOT circle.
+If the first argument is non-blank however, then the buffer is drawn along
+an invisible line like a two-terminal element, which is convenient sometimes
+but requires internal locations of the block to be referenced using
+{\tt last []}, as shown in \FR{Buffer}.
+\begin{figure}[h!t]
+ \input Buffer
+ \caption{The {\tt BUFFER\_gate} and {\tt BUFFER\_gen} macros.
+ The bottom two examples show how the gate can be drawn as a two-terminal
+ macro but internal block locations must be referenced using
+ {\tt last []}.}
+ \label{Buffer}
+ \end{figure}
+
+\pagebreak
+A good strategy for drawing complex logic circuits might be summarized
+as follows:
+\begin{itemize}\itemsep=0pt
+\item Establish the absolute locations of gates and other major components
+ (e.g. chips) relative to a grid of mesh size commensurate with
+ {\tt L\_unit}, which is an absolute length.
+\item Draw minor components or blocks relative to the major ones, using
+ parameterized relative distances.
+\item Draw connecting lines relative to the components and previously drawn
+ lines.
+\item Write macros for repeated objects.
+\item Tune the diagram by making absolute locations relative, and by tuning
+ the parameters.
+ Some useful macros for this are the following, which are in units of
+ {\tt L\_unit}:
+ \begin{itemize}
+ \item[] {\tt AND\_ht, AND\_wd}: the height and width of basic AND and
+ OR gates
+ \item[] {\tt BUF\_ht, BUF\_wd}: the height and width of basic buffers
+ \item[] {\tt N\_diam}: the diameter of NOT circles
+ \end{itemize}
+ \end{itemize}
+
+\FR{Multiplexer} shows a multiplexer block with variations, and
+ \FR{Demultiplexer} shows
+the very similar demultiplexer.
+\begin{figure}[h!t]
+ \input Multiplexer
+ \caption{The {\tt Mux({\sl input count}, {\sl label},
+ [L][B|H|X][N[$n$]|S[$n$]][[N]OE],{\sl wid},{\sl ht})} macro.}
+ \label{Multiplexer}
+ \end{figure}
+\begin{figure}[h!t]
+ \input Demultiplexer
+ \caption{The {\tt Demux({\sl input count}, {\sl label},
+ [L][B|H|X][N[$n$]|S[$n$]][[N]OE],{\sl wid},{\sl ht})} macro.}
+ \label{Demultiplexer}
+ \end{figure}
+
+\FR{FlipFlops} shows
+the macro {\tt FlipFlop(D|T|RS|JK, {\sl label, boxspec})}, which is a
+wrapper for the more general macro {\tt FlipFlopX(}{\sl boxspec, label,
+leftpins, toppins, rightpins, bottompins}{\tt )}.
+\begin{figure}[h!t]
+ \input FlipFlop
+ \caption{The {\tt FlipFlop} and {\tt FlipFlopX} macros, with variations.}
+ \label{FlipFlops}
+ \end{figure}
+Each of arguments 3 to 6 is null or a string of {\sl pinspecs} separated
+by semicolons ({\tt;}). {\sl Pinspecs} are either empty (null) or of the form
+{\tt[}{\sl pinopts}{\tt]:[}{\sl label}{\tt[:}{\sl Picname}{\tt]]}.
+The first colon draws the pin.
+Pins are placed top to bottom or left to right along the box edges with
+null pinspecs counted for placement. Pins are named by side and number
+by default; eg {\tt W1, W2, ..., N1, N2, ..., E1, ..., S1, ...} ; however,
+if {\tt:}{\sl Picname} is present in a {\sl pinspec} then {\sl Picname}
+replaces the default name. A {\sl pinspec} label is text placed at the pin
+base. Semicolons are
+not allowed in labels; use eg \verb|\char59{}| instead, and to put a bar over
+a label, use {\tt lg\_bartxt(}{\sl label}{\tt)}.
+The {\sl pinopts} are {\tt [L|M|I|O][N][E]} as for the \verb|lg_pin| macro.
+
+Customized gates can be defined simply.
+For example, the following code defines the custom flipflops in \FR{ShiftR}.
+\begin{figure}[h!t]
+ \input ShiftR
+ \caption{A 5-bit shift register.}
+ \label{ShiftR}
+ \end{figure}
+\begin{verbatim}
+define(`customFF',`FlipFlopX(wid 10*L_unit ht FF_ht*L_unit,,
+ :S;NE:CK;:R, N:PR, :Q;;ifelse(`$1',1,:lg_bartxt(Q)), N:CLR) ')
+\end{verbatim}
+This definition makes use of macros \verb|L_unit| and
+\verb|FF_ht| that predefine dimensions.
+There are three pins on the right side; the centre pin is null and
+the bottom is null if the first macro argument is 1.
+
+For hybrid applications, the \verb|dac| and \verb|adc| macros are
+illustrated in \FR{Dac}.
+The figure shows the default and predefined internal locations, the number
+of which can be specified as macro arguments.
+\begin{figure}[h!t]
+ \ifpdf\vspace*{-\baselineskip}\fi%
+ \input Dac
+ \ifpdf\vspace*{-\baselineskip}\fi%
+ \caption{The {\tt dac({\sl width,height},nIn,nN,nOut,nS)}
+ and {\tt adc({\sl width,height},nIn,nN,nOut,nS)} macros.}
+ \label{Dac}
+ \end{figure}
+
+In addition to the logic gates described here, some experimental
+IC chip diagrams are included with the distributed example files.
+
+\pagebreak
+\xection{Element and diagram scaling\label{Scaling:}}
+
+There are several issues related to scale changes. You may wish to use
+millimetres, for example, instead of the default inches. You may wish
+to change the size of a complete diagram while keeping the relative
+proportions of objects within it. You may wish to change the sizes or
+proportions of individual elements within a diagram. You must take
+into account that line widths are scaled separately from drawn objects,
+and that the size of typeset text is independent of the \pic language.
+
+The scaling of circuit elements will be described first, then
+the \pic scaling facilities.
+
+\subsection{Circuit scaling\label{Circuitscaling:}}
+The circuit elements all have default dimensions
+that are multiples of the \pic environmental parameter {\tt linewid,}
+so changing this parameter changes default element dimensions.
+The scope of a \pic variable is the current block; therefore, a sequence
+such as
+
+\begin{verbatim}
+ resistor
+T: [linewid = linewid*1.5; up_; Q: bi_tr] with .Q.B at Here
+ ground(at T.Q.E)
+ resistor(up_ dimen_ from T.Q.C)
+\end{verbatim}
+
+\noindent%
+connects two resistors and a ground to an enlarged transistor.
+Alternatively, you may redefine the default length {\tt elen\_}
+or the body-size parameter {\tt dimen\_.} For example, adding the line
+
+{\tt define(`dimen\_',(dimen\_*1.2))}
+
+\noindent%
+after the {\tt cct\_init} line of {\tt quick.m4} produces slightly
+larger body sizes for all circuit elements. For logic elements, the
+equivalent to the {\tt dimen\_} macro is {\tt L\_unit}, which has
+default value {\tt (linewid/10)}.
+
+The macros {\tt capacitor, inductor,} and {\tt resistor} have arguments
+that allow the body sizes to be adjusted individually. The macro
+{\tt resized} mentioned previously can also be used.
+
+\subsection{Pic scaling\label{Picscaling:}}
+There are at least three kinds of graphical elements to be considered:
+\begin{enumerate}
+\item When generating final output after reading the {\tt.PE} line,
+ \pic processors divide distances and sizes by the value of the
+ environmental parameter {\tt scale}, which is 1 by default. Therefore,
+ the effect of assigning a value to {\tt scale} at the beginning of the
+ diagram is to change the drawing unit (initially 1 inch) throughout
+ the figure. For example, the file {\tt quick.m4} can be modified to
+ use millimetres as follows:
+ \begin{verbatim}
+ .PS # Pic input begins with .PS
+ scale = 25.4 # mm
+ cct_init # Set defaults
+
+ elen = 19 # Variables are allowed
+ ...
+ \end{verbatim}
+\vspace*{-1.5\baselineskip}
+ The default sizes of \pic objects
+ are redefined by assigning new values to the environmental parameters
+ {\tt arcrad,} {\tt arrowht,} {\tt arrowwid,} {\tt boxht,} {\tt boxrad,}
+ {\tt boxwid,} {\tt circlerad,} {\tt dashwid,} {\tt ellipseht,}
+ {\tt ellipsewid,} {\tt lineht,} {\tt linewid,} {\tt moveht,}
+ {\tt movewid,}
+ {\tt textht,} and {\tt textwid.}
+ The $\ldots${\tt ht} and $\ldots${\tt wid} parameters refer to the
+ default sizes of vertical and horizontal lines, moves, etc., except for
+ {\tt arrowht} and {\tt arrowwid}, which are arrowhead dimensions.
+ The {\tt boxrad} parameter can be used to put rounded corners on boxes.
+ Assigning a new value to {\tt scale} also multiplies all of these
+ parameters except {\tt arrowht,} {\tt arrowwid,} {\tt textht,} and
+ {\tt textwid} by the new value of {\tt scale} (\gpic multiplies them all).
+ Therefore, objects drawn to default sizes are unaffected by changing
+ {\tt scale} at the beginning of the diagram.
+ To change default sizes, redefine the appropriate parameters explicitly.
+
+\item The {\tt .PS} line can be used to scale the entire drawing, regardless
+ of its interior. Thus, for example, the line {\tt.PS 100/25.4}
+ scales the entire drawing to a width of 100$\,$mm.
+ Line thickness, text size, and \dpic arrowheads are unaffected by
+ this scaling.
+
+ If the final picture width exceeds {\tt maxpswid}, which
+ has a default value of 8.5, then the picture is scaled to this size.
+ Similarly, if the height exceeds {\tt maxpsht} (default 11), then the
+ picture is scaled to fit. These parameters can be assigned
+ new values as necessary, for example, to accommodate landscape figures.
+
+\item The finished size of typeset text is independent of \pic variables,
+ but can be determined as in \SR{Interaction:}. Then,
+ {\tt "text" wid $x$ ht $y$} tells \pic the size of {\tt text},
+ once the printed width $x$ and height $y$ have been found.
+
+\item Line widths are independent of diagram and text scaling, and have
+ to be set explicitly. For example,
+ the assignment {\tt linethick = 1.2} sets the default line width to 1.2\,pt.
+ The macro {\tt linethick\_({\sl points})} is also provided, together
+ with default macros {\tt thicklines\_} and {\tt thinlines\_}.
+
+\end{enumerate}
+
+\xection{Writing macros\label{Writing:}}
+The \Mfour language is quite simple and is
+described in numerous documents such as the original reference~\cite{KRm4}
+or in later manuals~\cite{Seindal94}. If a new circuit
+or other element is required, then it may suffice to modify and rename one of
+the library definitions or simply add an option to it.
+Hints for drawing general two-terminal elements are given in
+{\tt libcct.m4}. However, if an element or block is to be drawn in
+only one orientation then most of the elaborations used for general
+two-terminal elements in \SR{Basictwo:} can be dropped.
+If you develop a library of custom macros in the installation
+directory then the statement {\tt include(}{\sl mylibrary}{\tt.m4)}
+can bring its definitions into play.
+
+It may not be necessary to define your own macro if all that is needed is
+a small addition to an existing element that is defined in an enclosing
+\verb|[ ]| block. After the element arguments are expanded,
+one argument beyond the normal list is automatically expanded before
+exiting the block, as mentioned near the beginning of \SR{Composite:}.
+This extra argument can be used to embellish the element.
+
+A macro is defined using quoted name and replacement text as follows:
+
+{\tt define(`}{\sl name}{\tt',`}{\sl replacement text}{\tt ')}
+
+After this line is read by the \Mfour processor, then whenever {\sl name}
+is encountered as a separate string, it is replaced by its replacement
+text, which may have multiple lines. The quotation characters are used
+to defer macro expansion. Macro arguments are referenced inside a
+macro by number; thus {\tt \$1} refers to the first argument.
+A few examples will be given.
+
+%\enlargethispage{\baselineskip}
+%\noindent\hbox{}\\ {\bf Example 1:}
+%\par\noindent {\bf Example 1:}
+\Example{1}
+Custom two-terminal elements can often be defined by writing a wrapper
+for an existing element. For example, an enclosed thermal switch
+can be defined as shown in \FR{Thermal}.
+\begin{figure}[h!]
+ \parbox{4.2in}{\tt define(`thermalsw',\hfill\break
+ \hbox{}\space`dswitch(`\$1',`\$2',WDdBT)\hfill\break
+ \hbox{}\space\space circle rad distance(M4T,last line.c)
+ at last line.c ') }%
+ \hfill\raise-0.15in\hbox{\input Thermal }
+ \caption{A custom thermal switch defined from the {\tt dswitch} macro.}
+ \label{Thermal}
+ \end{figure}
+
+%\par\noindent {\bf Example 2:}
+\Example{2}
+In the following,
+two macros are defined to simplify the repeated drawing
+of a series resistor and series inductor, and the macro {\tt tsection} defines
+a subcircuit that is replicated several times to generate \FR{Tline}.
+{\small \verbatiminput{Tline.m4}}
+\begin{figure}[h!]
+ \ifpdf\vspace*{-\baselineskip}\fi%
+ \input Tline
+ \caption{A lumped model of a transmission line, illustrating the
+ use of custom macros.}
+ \label{Tline}
+ \end{figure}
+
+\Example{3}
+%\par\noindent {\bf Example 3:}
+Composite elements containing several basic elements may be
+required. \FR{HybridPi} shows a circuit that can be drawn in
+any reference direction prespecified by {\tt Point\_({\sl degrees})},
+containing labels that always appear in their natural horizontal orientation.
+\begin{figure}[h!t]
+ \vspace*{-0.5ex}
+ \input HybridPi
+ \vspace*{-0.5ex}
+ \caption{A composite element containing several basic elements}
+ \label{HybridPi}
+ \end{figure}
+Two flags in the argument determine the circuit orientation with respect to
+the current drawing direction and whether a mirrored circuit is drawn.
+The key to writing such a macro is to observe that the \pic language
+allows two-terminal elements to change the current drawing direction,
+so the value of {\tt rp\_ang} should be saved and restored as necessary
+after each internal two-terminal element has been drawn.
+A draft of such a macro follows:
+\begin{verbatim}
+# `Point_(degrees)
+# hybrid_PI_BJT([L][M])
+# L=left orientation; M=mirror'
+define(`hybrid_PI_BJT',
+`[ # Size (and direction) parameters:
+ hunit = ifinstr(`$1',M,-)dimen_
+ vunit = ifinstr(`$1',L,-)dimen_*3/2
+ hp_ang = rp_ang # Save the reference direction
+
+ Rpi: resistor(to rvec_(0,-vunit)); point_(hp_ang) # Restore direction
+ DotG: dot(at rvec_(hunit*5/4,0))
+ Gm: consource(to rvec_(0,vunit),I,R); point_(hp_ang) # Restore direction
+ dot(at rvec_(hunit*3/4,0))
+ Ro: resistor(to rvec_(0,-vunit)); point_(hp_ang) # Restore direction
+ line from Rpi.start to Rpi.start+vec_(-hunit/2,0) chop -lthick/2 chop 0
+ Base: dot(,,1)
+ line from Gm.end to Ro.start+vec_(hunit/2,0) chop -lthick/2 chop 0
+ Collector: dot(,,1)
+ line from Rpi.end to Ro.end chop -lthick/2
+ DotE: dot(at 0.5 between Rpi.end and DotG)
+ line to rvec_(0,-vunit/2)
+ Emitter: dot(,,1)
+ # Labels
+ `"$\mathrm{r_\pi}$"' at Rpi.c+vec_(hunit/4,0)
+ `"$ + $"' at Rpi.c+vec_(-hunit/6, vunit/4)
+ `"$ - $"' at Rpi.c+vec_(-hunit/6,-vunit/4)
+ `"$\mathrm{v_\pi}$"' at Rpi.c+vec_(-hunit/4,0)
+ `"$\mathrm{g_m}$$\mathrm{v_\pi}$"' at Gm.c+vec_(-hunit*3/8,-vunit/4)
+ `"$\mathrm{r_o}$"' at Ro.c+vec_(hunit/4,0)
+ `$2' ] ')
+\end{verbatim}
+
+\pagebreak
+\Example{4}
+%\par\noindent {\bf Example 4:}
+A number of elements have arguments meant explicitly for customization.
+\FR{Sinus} customizes the {\tt source} macro to show a cycle of a horizontal
+sinusoid with adjustable phase given by argument 2 in degrees,
+as might be wanted for a 3-phase circuit:
+\begin{figure}[ht]
+\hfill\input Sinus
+ \vspace*{-0.5in}
+\begin{verbatim}
+define(`phsource',`source($1,
+#`Set angle to 0, draw sinusoid, restore angle'
+ m4smp_ang = rp_ang; rp_ang = 0
+ sinusoid(m4h/2,twopi_/(m4h),
+ ifelse(`$2',,,`($2)/360*twopi_+')pi_/2,-m4h/2,m4h/2) with .Origin at Here
+ rp_ang = m4smp_ang,
+$3,$4,$5)')
+\end{verbatim}
+\vspace*{-\baselineskip}
+ \caption{A source element customized using its second argument.}
+ \label{Sinus}
+ \end{figure}
+
+\Example{5}
+%\par\noindent {\bf Example 5:}
+Repeated subcircuits might have different orientations
+% but the potential orientations often
+that
+include only the element and its mirror image, for example, so the
+power of the \verb|vec_()| and \verb|rvec_()| macros is not required.
+Suppose that an optoisolator is to be drawn with left-right or right-left
+orientation as shown in \FR{Opto}.
+%\vspace*{-0.5em}
+\begin{figure}[h!t]
+ \input Opto
+ \caption{Showing {\tt opto} and {\tt opto(BR)} with defined labels.}
+ \label{Opto}
+ \end{figure}
+
+The macro interface could be something like the following:
+
+{\tt opto( [L|R][A|B] )},
+
+\noindent where an {\tt R} in the argument string signifies a right-left
+(mirrored) orientation and the element is of either {\tt A} or {\tt B} type;
+that is, there are two related elements that might be drawn in either
+orientation, for a total of four possibilities.
+Those who find such an interface to be too cryptic might prefer to
+invoke the macro as
+
+{\tt opto(orientation=Rightleft;type=B)},
+
+\noindent
+which includes semantic sugar surrounding the {\tt R} and {\tt B} characters
+for readability; this usage is made possible by testing the argument string
+using the {\tt ifinstr()} macro rather than requiring an exact match.
+A draft of the macro follows, and the file {\tt Optoiso.m4} in the examples
+directory adds a third type option.
+\begin{verbatim}
+# `opto([R|L][A|B])'
+define(`opto',`[{u = dimen_/2
+ Q: bi_trans(up u*2,ifinstr(`$1',R,R),ifinstr(`$1',B,B)CBUdE)
+ E: Q.E; C: Q.C; A:ifinstr(`$1',R,Q.e+(u*3/2,u),Q.w+(-u*3/2,u)); K: A-(0,u*2)
+ ifinstr(`$1',B,line from Q.B to (Q.B,E); B: Here)
+ D: diode(from A to K)
+ arrow from D.c+(0,u/6) to Q.ifinstr(`$1',R,e,w)+(0,u/6) chop u/3 chop u/4
+ arrow from last arrow.start-(0,u/3) to last arrow.end-(0,u/3)
+ Enc: box rad u wid abs(C.x-A.x)+u*2 ht u*2 with .c at 0.5 between C and K
+ `$2' }]')
+\end{verbatim}
+Two instances of this subcircuit are
+drawn and placed by the following code, with the result
+shown in \FR{Opto}.
+\begin{verbatim}
+Q1: opto
+Q2: opto(type=B;orientation=Rightleft) with .w at Q1.e+(dimen_,0)
+\end{verbatim}
+
+
+\iffalse
+\noindent {\bf Example 4:}
+Repeated subcircuits might have different orientations.
+Suppose that a simple opamp subcircuit might have to be drawn in any direction.
+The subcircuit will be placed in a {\tt [} {\tt ]} block, with
+internal points {\sl In}, {\sl Out}, and {\sl G}.
+The macro interface could be something like the following:
+
+{\tt fbfilter( U|D|L|R|{\sl degrees}, [L|R], {\sl opamp label},
+ {\sl C label}, {\sl R label} )}
+
+\noindent The first argument specifies the drawing direction as for the
+{\tt antenna} macro, for example. Setting the second argument to {\tt
+R} specifies right orientation with respect to the drawing direction,
+and the last three arguments are labels
+for three internal elements. Two instances of this subcircuit are
+drawn and placed by the following code, with the result
+shown in \FR{fbfilter}.
+\begin{verbatim}
+F1: fbfilter(,,K_3,C_{24},R_4)
+ ground(at F1.G)
+ dot(at F1.In); line up_ elen_/4
+F2: fbfilter(L,R,K_2,C_{23},R_3) with .In at F1.In
+ ground(at F2.G)
+\end{verbatim}
+\vspace*{-0.5em}
+\begin{figure}[h!t]
+ \input fbfilter
+ \caption{Showing the result of two invocations of the {\tt fbfilter} macro,
+ with labels.}
+ \label{fbfilter}
+ \end{figure}
+A draft macro for the subcircuit follows:
+\begin{verbatim}
+define(`fbfilter',
+`[ setdir_(ifelse(`$1',,0,`$1')) # Process arg 1, default to the right
+ eleminit_ # Assign rp_ang, rp_len
+ tmpang = rp_ang # Save rp_ang
+ hunit = elen_ # Dimension parameters
+ vunit = ifinstr(`$2',R,-)elen_/2
+ K: opamp(,,,,`$2')
+ move to K.In`'ifinstr(`$2',R,2,1); line to rvec_(-hunit/4,0)
+ J: dot
+ R: resistor(to rvec_(-elen_,0)); point_(tmpang) # Reset rp_ang
+ In: Here
+ move to K.In`'ifinstr(`$2',R,1,2); line to rvec_(-hunit/4,0)
+ G: Here
+ dot(at K.Out)
+ { line to rvec_(hunit/4,0)
+ Out: Here }
+ line to rvec_(0,vunit)
+ C: capacitor(to rvec_(-distance(K.Out,0.5 between J and G),0)); point_(tmpang)
+ line to J
+ ifelse(`$3',,,"$`$3'$" at K.C) # Add the labels if non-blank.
+ ifelse(`$4',,,"$`$4'$" at C+vec_(0,-vunit/3))
+ ifelse(`$5',,,"$`$5'$" at R+vec_(0,-vunit/4))
+ resetdir_
+ ]')
+\end{verbatim}
+The drawing direction is unknown when the macro is defined, so the
+macros {\tt vec\_} and {\tt rvec\_} are used for drawing lines and
+elements.
+Thus, {\tt (vec\_({\sl x,y}))} is position {\tt ({\sl x,y})} rotated
+by angle {\tt rp\_ang}.
+A side effect of drawing a two-terminal element is to change the
+drawing direction (in conformity with the \pic language), so the angle must
+be saved and reset as needed. Normally, the {\tt fbfilter} block will be
+placed by specifying the position of one of its defined points; by
+default it will be placed as if it were a box.
+\fi
+
+\xection{Interaction with \latex\label{Interaction:}}
+The sizes of typeset labels and other \tex boxes are generally unknown
+prior to processing the diagram by \latex.
+Although they are not needed for many circuit diagrams,
+these sizes may be required explicitly for calculations or implicitly
+for determining the diagram bounding box.
+The following example shows how text sizes can affect the overall size of
+a diagram:
+
+\begin{verbatim}
+.PS
+B: box
+ "Left text" at B.w rjust
+ "Right text: $x^2$" at B.e ljust
+.PE
+\end{verbatim}
+
+The \pic interpreter cannot know the size of the text to the left
+and right of the box, and the diagram is generated using
+default text values. One solution to this problem is to measure the
+text sizes by hand and include them literally, thus:\hfill\break
+\hbox{}\quad%
+\verb|"Left text" wid 38.47pt__ ht 7pt__ at B.w rjust|\hfill\break
+but this is tedious.
+
+Often, a better solution is to process the diagram twice. The
+diagram source is processed as usual by \Mfour and a \pic processor, and the
+main document source is \latex{}ed to input the diagram and format the
+text, and also to write the text dimensions into a supplementary file.
+Then the diagram source is processed again, reading the required
+dimensions from the supplementary file and producing a diagram ready
+for final \latex{}ing. This hackery is summarized below, with an example
+in \FR{stringdim}.
+\begin{itemize}
+\item Put \verb|\usepackage{boxdims}| into the document source.
+\item Insert the following at the beginning of the diagram source,
+ where {\sl jobname} is the name of the main \latex file:\hfill\break
+ \quad{\tt sinclude({\sl jobname}.dim)\hfill\break
+ \quad s\_init({\sl unique name})}
+\item Use the macro {\tt s\_box({\sl text})} to produce
+ typeset text of known size, or alternatively, invoke the macros
+ \verb|\boxdims| and \verb|boxdim| described later.
+ The argument of {\tt s\_box} need not be text exclusively; it can
+ be anything that produces a \TeX\ box.
+\end{itemize}
+\begin{figure}[h!t]
+ \parbox{3.5in}{\small\tt.PS\\
+ gen\_init\\
+ sinclude(Circuit\_macros.dim)\\
+ s\_init(stringdims)\\
+ B: box\\
+ \hbox{}\quad s\_box(Left text) at B.w rjust\\
+ \hbox{}\quad s\_box(Right text: \$x\^{}{\%g}\$,2) at B.e ljust\\
+ .PE}%
+ \hfill\llap{\raise-0.25in\hbox{\input stringdims }}%
+ \caption{The macro {\tt s\_box} sets string dimensions automatically
+ when processed twice. If two or more arguments are
+ given to {\tt s\_box}, they
+ are passed through {\tt sprintf}. The dots show the figure bounding box.}
+ \label{stringdim}
+ \end{figure}
+
+\noindent The macro \verb|s_box(|{\sl text}\verb|)| evaluates initially to
+
+ \verb|"\boxdims{|{\sl name}\verb|}{|{\sl text}\verb|}"|
+ \verb|wid boxdim(|{\sl name}\verb|,w) ht boxdim(|{\sl name}\verb|,v)|
+
+\noindent
+On the second pass, this is equivalent to
+
+ {\tt "{\sl text}" wid {\sl x} ht {\sl y}}
+
+ \noindent
+ where {\sl x} and {\sl y} are the typeset dimensions of the
+ \latex input text. If {\tt s\_box} is given two or more arguments
+ as in \FR{stringdim}
+ then they are processed by {\tt sprintf}.
+
+The argument of {\tt s\_init}, which should be unique within {\tt{\sl
+jobname}.dim}, is used to generate a unique \verb|\boxdims| first
+argument for each invocation of \verb|s_box| in the current file. If
+\verb|s_init| has been omitted, the symbols ``{\bf !!}'' are inserted
+into the text as a warning. Be sure to quote any commas in the
+arguments. Since the first argument of {\tt s\_box} is \latex source,
+make a rule of quoting it to avoid comma and name-clash problems. For
+convenience, the macros {\tt s\_ht}, {\tt s\_wd}, and {\tt s\_dp}
+evaluate to the dimensions of the most recent {\tt s\_box} string or to
+the dimensions of their argument names, if present.
+
+The file \verb|boxdims.sty| distributed with this package should be installed
+where \latex can find it.
+The essential idea is to define a two-argument \latex macro
+\verb|\boxdims| that writes out definitions for the width, height and
+depth of its typeset second argument into file {\sl jobname.}\verb|dim|,
+where {\sl jobname} is the name of the main source file.
+The first argument of \verb|\boxdims| is used to construct unique symbolic
+names for these dimensions.
+Thus, the line
+
+{\tt box \verb|"\boxdims{Q}{\Huge Hi there!}"| }
+
+\noindent has the same effect as
+
+{\tt box \verb|"\Huge Hi there!"|}
+
+\noindent except that the line
+
+{\tt define(`Q\_w',77.6077pt\_\_)define(`Q\_h',17.27779pt\_\_)%
+define(`Q\_d',0.0pt\_\_)dnl}
+
+\noindent is written into file {\sl jobname.}\verb|dim|
+(and the numerical values depend on the current font).
+These definitions are required by the \verb|boxdim| macro
+described below.
+
+The \latex macro
+
+\verb|\boxdimfile{|{\sl dimension file}\verb|}|
+
+\noindent is used to specify an alternative to {\sl jobname.}\verb|dim| as the
+dimension file to be written. This simplifies cases where {\sl jobname}
+is not known in advance or where an absolute path name is required.
+
+Another simplification is available. Instead of the
+{\tt sinclude({\sl dimension file})} line
+above, the dimension file can be read by \Mfour before reprocessing the source
+for the second time:
+
+{\tt m4 {\sl library files} {\sl dimension file} {\sl diagram source file} ...}
+
+Here is a second small example. Suppose that the file {\tt tsbox.m4} contains
+the following:
+\begin{verbatim}
+\documentclass{article}
+\usepackage{boxdims,ifpstricks(pstricks,tikz)}
+\begin{document}
+.PS
+cct_init s_init(unique) sinclude(tsbox.dim)
+[ source(up_,AC); llabel(,s_box(AC supply)) ]; showbox_
+.PE
+\end{document}
+\end{verbatim}
+The file is processed twice as follows:
+
+{\tt m4 pgf.m4 tsbox.m4 | dpic -g > tsbox.tex; pdflatex tsbox}
+\par
+{\tt m4 pgf.m4 tsbox.m4 | dpic -g > tsbox.tex; pdflatex tsbox}
+
+\noindent
+The first command line produces a file {\tt tsbox.pdf} with
+incorrect bounding box. The second command reads the data in {\tt tsbox.dim}
+to size the label correctly. The equivalent pstricks commands (note
+the {\tt ifpstricks} macro in the second source line) are
+
+{\tt m4 pstricks.m4 tsbox.m4 | dpic -p > tsbox.tex; latex tsbox}
+\par
+{\tt m4 pstricks.m4 tsbox.m4 | dpic -p > tsbox.tex; latex tsbox; dvips tsbox}
+
+\hbox{}
+
+Objects can be taylored to their attached text by invoking
+\verb|\boxdims| and \verb|boxdim| explicitly.
+The small source file in \FR{boxdims}, for example,
+produces the box in the figure.
+%\vspace*{-\baselineskip}%
+\begin{figure}[h!t]
+ \parbox{4.2in}{\small \input eboxdims.verb }%
+ \hfill\llap{\raise-0.35in\hbox{\input eboxdims }}%
+ \vspace{-\baselineskip}
+ \caption{Fitting a box to typeset text.}
+ \label{boxdims}
+ \end{figure}
+
+The figure is processed twice, as described previously.
+The line \verb|sinclude(|{\sl jobname}\verb|.dim)| reads the named file
+if it exists. The macro \verb|boxdim(|{\sl
+name,suffix,default}\verb|)| from {\tt libgen.m4} expands the
+expression \verb|boxdim(Q,w)| to the value of \verb|Q_w| if it is
+defined, else to its third argument if defined, else to 0, the latter
+two cases applying if {\sl jobname.}\verb|dim| doesn't exist yet. The
+values of \verb|boxdim(Q,h)| and \verb|boxdim(Q,d)| are similarly
+defined and, for convenience, \verb|boxdim(Q,v)| evaluates to the sum
+of these. Macro \verb|pt__| is defined as \verb|*scale/72.27| in {\tt
+libgen.m4}, to convert points to drawing coordinates.
+
+Sometimes a label needs a plain background in order to blank
+out previously drawn components overlapped by the label,
+as shown on the left of \FR{fbox}.
+The technique illustrated in \FR{boxdims} is automated by the
+macro
+{\tt f\_box(}{\sl boxspecs}, {\sl label arguments}{\tt )}.
+For the special case of only one argument,
+e.g., {\tt f\_box(Wood chips),} this macro
+simply overwrites the label on a white box of identical size.
+Otherwise, the first argument specifies the box characteristics
+(except for size), and the macro evaluates to
+
+{\tt box }{\sl boxspecs} {\tt s\_box(}{\sl label arguments}{\tt)}.
+
+\noindent%
+For example, the result of the following command
+is shown on the right of \FR{fbox}.
+
+\verb|f_box(color "lightgray" thickness 2 rad 2pt__,"\huge$n^{%g}$",4-1)|
+\begin{figure}[h!b]
+%\begin{figure}[b!]
+ \input woodchips
+ \vspace{-0.5\baselineskip}
+ \caption{Illustrating the {\tt f\_box} macro.}
+ \label{fbox}
+ \end{figure}
+
+More tricks can be played. The example
+
+\verb|Picture: s_box(`\includegraphics{|{\it file}\verb|.eps}') with .sw at|
+{\sl location}
+
+\noindent shows a nice way of including eps graphics in a diagram. The
+included picture (named {\tt Picture} in the example) has known position and
+dimensions, which can be used to add vector graphics or text to the
+picture. To aid in overlaying objects, the macro {\tt boxcoord(}{\sl
+object name, x-fraction, y-fraction}{\tt)} evaluates to a position,
+with {\tt boxcoord(}{\sl object name}{\tt,0,0)} at the lower left
+corner of the object, and {\tt boxcoord(}{\sl object name}{\tt,1,1)} at
+its upper right.
+
+\xection{\PSTricks and other tricks\label{Pstricks:}}
+This section applies only to a \pic processor (\dpic) that is
+capable of producing output compatible with
+\PSTricks, \TPGF, or in principle, other graphics postprocessors.
+
+By using {\tt command} lines,
+or simply by inserting \latex graphics directives along with strings to
+be formatted, one can mix
+arbitrary \PSTricks (or other) commands with \Mfour input
+to create complicated effects.
+
+Some commonly required effects are particularly simple. For example,
+the rotation of text by \PSTricks postprocessing is illustrated by the file
+
+{\small \verbatiminput{Axes.m4}}
+
+\noindent%
+which contains both horizontal text and text rotated $90^\circ$ along the
+vertical line.
+This rotation of text is also implemented by the macro
+{\tt rs\_box}, which is similar
+to {\tt s\_box} but rotates its text argument by $90^\circ,$ a default angle
+that can be changed by preceding invocation with
+\verb|define(`text_ang',|{\sl degrees}{\tt )}. The {\tt rs\_box} macro
+requires either \PSTricks or \TPGF and, like {\tt s\_box}, it calculates the
+size of the resulting text box but requires the diagram to be
+processed twice.
+
+Another common requirement is the filling of arbitrary shapes, as
+illustrated by the following lines within a {\tt .m4} file:
+
+\vspace{\parsep}
+\noindent%
+\verb|command "`\pscustom[fillstyle=solid,fillcolor=lightgray]{'"|
+\hfill\break
+{\sl drawing commands for an arbitrary closed curve}
+\hfill\break
+\verb|command "`}%'"|
+\vspace{\parsep}
+
+For colour printing or viewing, arbitrary
+colours can be chosen, as described in the \PSTricks manual.
+\PSTricks parameters can be set by inserting the line
+
+\vspace{\parsep}
+\noindent\verb|command "`\psset{|{\sl option=value,}$\;\ldots$\verb|}'"|
+\vspace{\parsep}
+
+\noindent%
+in the drawing commands or by using the macro
+{\tt psset\_(}{\sl PSTricks options}{\tt )}.
+
+The macros
+ {\tt shade(}{\sl gray value},{\sl closed line specs}{\tt )}
+and
+ {\tt rgbfill(}{\sl red value, green value, blue value, closed line specs}%
+ {\tt )}
+can be invoked to accomplish the same effect as the above fill example, but
+are not confined to use only with \PSTricks.
+
+Since arbitrary \latex can be output, either in ordinary strings or by
+use of {\tt command} output, complex examples such as found in
+reference~\cite{Girou94},
+for example, can be included. The complications
+are twofold: \latex and \dpic may not know the dimensions of the formatted
+result, and the code is generally unique to the postprocessor.
+Where postprocessors are capable of equivalent results, then
+macros such as {\tt rs\_box}, {\tt shade}, and {\tt rgbfill} mentioned
+previously can be used to hide code differences.
+
+\subsection{\Tikz\ with pic}\label{Tikzwithpic:}
+%The line
+%
+%\vspace{\parsep}
+%\noindent{\tt command "}{\sl string}{\tt "}
+%\vspace{\parsep}
+%
+%\noindent
+%allows arbitrary postprocessor code to be embedded in \pic output. However,
+%one can also embed
+Arbitrary \pic output can be inserted into a {\tt \bsl{}tikzpicture}
+environment. The trick is to keep the \pic and \Tikz coordinate systems
+the same.
+The lines
+
+\vspace{\parsep}
+\noindent\verb|\begin{tikzpicture}[scale=2.54]|\\
+\noindent\verb|\end{tikzpicture}|
+\vspace{\parsep}
+
+\noindent in the {\tt dpic -g} output must be changed to
+
+\vspace{\parsep}
+\noindent\verb|\begin{scope}[scale=2.54]|\\
+\noindent\verb|\end{scope}|
+\vspace{\parsep}
+
+This is accomplished, for example, by adapting the {\tt \bsl{}mtotex}
+macro of \SR{Simplifications:} as follows:
+
+\vspace{\parsep}
+\noindent
+\verb^\newcommand\mtotikz[1]{\immediate\write18{m4 pgf.m4 #1.m4 | dpic -g^\\
+\verb^ | sed -e "/begin{tikzpicture}/s/tikzpicture/scope/"^\\
+\verb^ -e "/end{tikzpicture}/s/tikzpicture/scope/" > #1.tex}\input{./#1.tex}}%^\break
+%\verb^ -e "/end{tikzpicture}/s/tikzpicture/scope/"^\\
+%\verb^ > #1.tex}\input{./#1.tex}}%^\break
+
+Then, from within a \Tikz pictdure,
+{\tt \bsl{}mtotikz\lbr{}{\sl filename}\rbr}
+will create {\sl filename}{\tt .tex} from {\sl filename}{\tt .m4}
+and read the result into the \Tikz code.
+
+In addition, the \Tikz code may need to refer to nodes defined in
+the \pic diagram.
+The included \Mfour macro
+{\tt tikznode(}{\sl tikz node name,[position],[string]}{\tt)}
+defines a zero-size \Tikz node at the given \pic position, which is
+{\tt Here} by default.
+This macro must be
+invoked in the outermost scope of a pic diagram, and the
+{\tt .PS} {\sl value} scaling construct may not be used.
+
+\xection{Web documents, {\ttfamily pdf}, and alternative output formats%
+\label{Alternative:}}
+
+Circuit diagrams contain graphics and symbols, and the issues related to
+web publishing are similar to those for other mathematical documents.
+Here the important factor is that \gpic\ {\tt -t} generates output
+containing \tpic \verb|\special| commands, which must be converted
+to the desired output, whereas \dpic can generate several alternative
+formats, as shown in \FR{Workflow}.
+One of the easiest methods
+for producing web documents is to generate postscript as usual and to
+convert the result to pdf format with Adobe
+Distiller
+%\Textregistered
+or equivalent.
+
+PDFlatex produces pdf without first creating a postscript file
+but does not handle \tpic \verb|\special|s, so \dpic must be
+installed.
+
+%\enlargethispage{\baselineskip}
+Most PDFLatex distributions are not directly compatible with \PSTricks, but
+the \TPGF output of \dpic is compatible with both \latex and PDFLatex.
+Several alternative \dpic output formats such as
+\mfpic and \MetaPost also work well.
+To test \MetaPost, create a file {\sl filename}{\tt .mp}
+containing appropriate header lines, for example:
+%\pagebreak
+\begin{verbatim}
+ verbatimtex
+ \documentclass[11pt]{article}
+ \usepackage{times,boxdims,graphicx}
+ \boxdimfile{tmp.dim}
+ \begin{document} etex
+\end{verbatim}
+Then append one or more diagrams by using the equivalent of
+
+{\tt m4 <}{\sl installdir}{\tt >mpost.m4 {\sl library files}
+ {\sl diagram}.m4 | dpic -s >> {\sl filename}.mp}
+
+The command ``{\tt mpost --tex=latex } {\sl filename}{\tt .mp end}''
+processes this file, formatting the diagram text by creating a
+temporary {\tt .tex} file, \latex{}ing it, and recovering the {\tt .dvi}
+output to create {\sl filename}{\tt .1} and other files. If the {\tt boxdims}
+macros are being invoked, this process must be repeated to handle
+formatted text correctly as described in \SR{Interaction:}.
+In this case, either put {\tt sinclude(tmp.dim)} in the diagram {\tt .m4}
+source or read the {\tt .dim} file at the second invocation of
+\Mfour as follows:
+
+{\tt m4 <}{\sl installdir}{\tt >mpost.m4 {\sl library files} tmp.dim
+ {\sl diagram}.m4 | dpic -s >> {\sl filename}.mp}
+
+On some operating systems, the absolute path name for {\tt tmp.dim} has
+to be used to ensure that the correct dimension file is written and
+read. This distribution includes a {\tt Makefile} that simplifies the
+process; otherwise a script can automate it.
+
+Having produced {\sl filename}{\tt .1}, rename it to {\sl filename}{\tt .mps}
+and, {\it voil\`a,} you can now run PDFlatex on a {\tt .tex} source
+that includes the diagram using
+\verb|\includegraphics{|{\sl filename}\verb|.mps}|
+as usual.
+
+The \dpic processor is capable of other output formats, as illustrated in
+\FR{Workflow} and in example files included with the distribution.
+The \latex drawing commands alone or with {\tt eepic} or {\tt pict2e}
+extensions are suitable only for simple diagrams.
+\begin{figure}[h!b]
+% \ifpdf\vspace*{-\baselineskip}\fi%
+ \input Workflow
+ \ifpdf\vspace*{-\baselineskip}\fi%
+ \caption{Output formats produced by \gpic {\tt -t} and \dpic.
+ SVG output can be read by Inkscape or used directly in web documents.}
+ \label{Workflow}
+ \end{figure}
+
+\xection{Developer's notes\label{Developersnotes:}}
+Years ago in the course of writing a book, I took a few days off to
+write a \pic-like interpreter (\dpic) to automate the tedious
+coordinate calculations required by \latex picture objects. The
+macros in this distribution and the interpreter are the result of that
+effort, drawings I have had to produce since, and suggestions received from
+others. The interpreter has been upgraded over time to generate
+\mfpic, \MetaPost~\cite{metapost}, raw \Postscript, \Postscript with
+{\tt psfrag} tags, raw PDF, \PSTricks, and
+Ti{\it k}Z PGF output, the latter two my preference
+because of their quality and flexibility, including facilities for colour
+and rotations, together with simple font selection.
+\Xfig{}-compatible output was introduced early on to allow the creation of
+diagrams both by programming and by interactive graphics.
+\SVG output was added relatively recently, and seems suitable for
+producing web diagrams directly and for further editing by the
+Inkscape interactive graphics editor. The latest addition
+is raw PDF output, which has very basic text capability and is most
+suitable for creating diagrams without labels, but on which sophisticated
+text can be overlaid. \Dpic can write the coordinates of selected
+locations to an external file to be used in overlaying text or other
+items on the diagram.
+
+Instead of using \pic macros, I preferred the equally simple
+but more powerful \Mfour macro processor, and therefore \Mfour is
+required here, although \dpic now supports \pic-like macros. Free
+versions of \Mfour are available for Unix, Windows, and other
+operating systems.
+
+If starting over today would I not just use one of the other drawing
+packages available these days? It would depend on the context, but
+\pic remains a good choice for line drawings because it is easy to learn
+and read but powerful enough for coding the geometrical calculations
+required for precise component sizing and placement. It would be nice
+if arbitrary rotations and scaling were simpler and if a general path
+element with clipping were available as in \Postscript. However, all the
+power of \Postscript or \TPGF, for example, remains available,
+as arbitrary postprocessor code can be included with \pic code.
+
+The main value of this distribution is not in the use of a specific
+language but in the element data encoded in the macros, which have been
+developed with reference to standards and refined over two decades.
+Some of them have become less readable as more options and flexibility
+have been added, and if starting over today, perhaps I would change
+some details. Compromises have been made in order to retain reasonable
+compatibility with the variety of postprocessors. No choice of tool
+is without compromise, and producing good graphics seems to be time
+consuming, no matter how it is done, especially for circuits
+or other diagrams that contain random detail.
+
+The \dpic interpreter has several output-format options that may be
+useful. The {\tt eepicemu} and {\tt pict2e} extensions of the
+primitive \latex picture objects are supported. The \mfpic output
+allows the production of Metafont alphabets of circuit elements or
+other graphics, thereby essentially removing dependence on device
+drivers, but with the complication of treating every alphabetic
+component as a \tex box. The \xfig output allows elements to be
+precisely defined with \dpic and interactively placed with \xfig.
+Similarly, the SVG output can be read directly by the Inkscape graphics
+editor, but SVG can also be used directly for web pages.
+\Dpic will also generate low-level \MetaPost or \Postscript code, so
+that diagrams defined using \pic can be manipulated and combined with
+others. The \Postscript output can be imported into
+CorelDraw
+%\Textregistered
+and Adobe Illustrator
+%\Textregistered
+for further processing.
+With raw \Postscript, \PDF, and \SVG output, the user is
+responsible for ensuring that the correct fonts are provided and for
+formatting the text.
+
+Many thanks to the people who continue to send comments, questions,
+and, occasionally, bug fixes. What began as a tool for my own use changed
+into a hobby that has persisted, thanks to your help and advice.
+
+\xection{Bugs\label{Bugs:}}
+This section provides hints and a list of common errors.
+
+The distributed macros are not written for maximum robustness.
+Arguments could be entered in a key--value style (for example, {\tt
+resistor(up\_ elen\_,style=N;cycles=8}) instead of by positional
+parameters, but it was decided early on
+to keep macro usage as close as possible to \pic\ conventions.
+Macro arguments could be tested for correctness and
+explanatory error messages could be written as necessary, but that
+would make the macros more difficult to read and to write. You will
+have to read them when unexpected results are obtained or when you wish
+to modify them.
+
+Maintaining reasonable compatibility with both \gpic\ and \dpic
+and, especially, for different postprocessors, has
+resulted in some macros becoming more complicated than is preferable.
+
+Here are some hints, gleaned from experience and from comments I have
+received.
+\newcommand{%
+ \bflistitem}[2]{\phantomsection\pdfbookmark[subsection]{#1}{#2}{\bf #1: }}
+\begin{enumerate}
+
+%\item {\bf Misconfiguration:}
+\item
+\bflistitem{Misconfiguration}{misconfig}%
+ One of the configuration files
+ listed in \SR{Libraries:} and {\tt libgen.m4}
+ {\em must} be read by \Mfour before any other library macros.
+ Otherwise, the macros assume default configuration.
+ To aid in detecting the default condition, a {\tt WARNING}
+ comment line is inserted into the {\tt pic} output.
+ If only \PSTricks is to be used, for example, then
+ the simplest strategy is to set it as the default processor by
+ typing ``make psdefault'' in the installation directory to
+ change the mention of {\tt gpic} to {\tt pstricks}
+ near the top of {\tt libgen.m4}.
+ Similarly if only \TPGF will be used, change {\tt gpic} to {\tt pgf}
+ using the Makefile.
+ The package default is to read {\tt gpic.m4} for historical compatibility.
+ The processor options must be chosen correspondingly,
+ {\tt gpic -t} for {\tt gpic.m4} and, most often,
+ {\tt dpic -p} or {\tt dpic -g} when \dpic is employed.
+ For example, the pipeline for \PSTricks output from file {\tt quick.m4} is
+
+ {\tt m4 -I {\sl installdir} pstricks.m4 quick.m4 | dpic -p > quick.tex}
+
+ \noindent%
+ but for \TPGF processing, the configuration file and \dpic option have to
+ be changed:
+
+ {\tt m4 -I {\sl installdir} pgf.m4 quick.m4 | dpic -g > quick.tex}
+
+ Any non-default configuration file must appear explicitly in the command
+ line or in an {\tt include()} statement.
+
+\iffalse
+\item
+\bflistitem{Initialization}{initialization}
+If the first element macro evaluated is not two-terminal or is within a
+\Pic block, then later macros evaluated outside the block may produce
+the error message
+
+{\tt there is no variable `rp\_ang'}
+
+\noindent because {\tt rp\_ang} is not defined in the outermost scope of the
+diagram. To cure this problem, make sure that the line
+
+{\tt cct\_init}
+
+\noindent appears immediately after the .PS line or prior to the first block.
+It is entirely permissible to modify {\tt cct\_init} to include customized
+diagram initializations such as the {\tt thicklines\_} statement.
+One way to do this is to define a macro {\tt local\_init} in
+{\tt libgen.m4}.
+\fi
+
+\item
+\bflistitem{Pic objects versus macros}{objects}%
+ A common error is to write something like
+
+{\tt line from A to B; resistor from B to C; ground at D}
+
+\noindent when it should be
+
+{\tt line from A to B; resistor(from B to C); ground(at D)}
+
+\noindent This error is caused by an unfortunate inconsistency between
+\pic object attributes and the way \Mfour and \pic pass macro arguments.
+
+\item
+\bflistitem{Commas}{commas}
+Macro arguments are separated by commas, so any comma that is
+part of an argument must be protected by parentheses or quotes. Thus,
+
+{\tt shadebox(box with .n at w,h)}
+
+\noindent produces an error, whereas
+
+{\tt shadebox(box with .n at w`,'h)}
+
+\noindent and
+
+{\tt shadebox(box with .n at (w,h))}
+
+\noindent do not. The parentheses are preferred.
+For example,
+a macro invoked by circuit elements contained the line
+
+\verb|command "\pscustom[fillstyle=solid`,'fillcolor=m4fillv]{%"|
+
+\noindent which includes a comma, duly quoted. However, if such an
+element is an argument of another macro, the quotes are removed and the
+comma causes obscure ``too many arguments'' error messages.
+Changing this line to
+
+\verb|command sprintf("\pscustom[fillstyle=solid,fillcolor=m4fillv]{%%")|
+
+\noindent
+cured the problem because the protecting parentheses are not stripped away.
+
+\item
+\bflistitem{Default directions and lengths}{defaultdir}
+The \linespec argument of element
+macros defines a straight-line segment, which requires
+the equivalent of four parameters to be specified uniquely.
+If information is omitted, default values are used. Writing
+
+{\tt source(up\_)}
+
+\noindent draws a source up a distance equal to the current
+{\tt lineht} value, which may cause confusion.
+Writing
+
+{\tt source(0.5)}
+
+\noindent draws a source of length 0.5 units
+in the current \pic default direction, which is one of
+{\tt right,} {\tt left,} {\tt up,} or {\tt down.}
+The best practice is
+to specify both the direction and length of an element, thus:
+
+{\tt source(up\_ elen\_).}
+
+The effect of a \linespec argument is independent of any direction
+set using the {\tt Point\_} or similar macros.
+To draw an element at an obtuse angle (see \SR{Corners:}) try,
+for example,
+
+{\tt Point\_(45); source(to rvec\_(0.5,0))}
+
+\item
+\bflistitem{Processing sequence}{sequence}
+It is easy to forget that \Mfour finishes before \pic processing
+begins. Consequently, it may be puzzling that the following mix of
+a \pic loop and the \Mfour macro {\tt s\_box} does not appear to produce
+the required result:
+
+{\tt for i=1 to 5 do \lbr s\_box(A[i]); move \rbr}
+
+\noindent In this example, the {\tt s\_box} macro is expanded only once
+and the index {\tt i} is not a number. This particular example can be
+repaired by using an \Mfour loop:
+
+{\tt for\_(1,5,1,`s\_box(A[m4x]); move')}
+
+\item
+\bflistitem{Quotes}{quotes}
+ Single quote characters are stripped in pairs by \Mfour, so the string
+
+{\tt "{`}{`}inverse{'}{'}"}
+
+\noindent will become
+
+{\tt "{`}inverse{'}".}
+
+\noindent The cure is to add single quotes in pairs as necessary.
+
+ The only subtlety required in writing
+ \Mfour macros is deciding when to quote macro arguments. In the context
+ of circuits it seemed best to assume that arguments would not
+ be protected by quotes at the level of macro invocation, but should
+ be quoted inside each macro. There may be cases where this rule is
+ not optimal or where the quotes could be omitted, and there are
+ rare exceptions such as the {\tt parallel\_} macro.
+
+\item
+\bflistitem{Dollar signs}{dollarsigns}
+The $i$-th argument of an \Mfour macro is {\tt \$}$i,$ where $i$ is
+an integer, so the following construction can cause an error when it
+is part of a macro,
+
+{\tt "\$0\$" rjust below}
+
+\noindent since {\tt \$0} expands to the name of the macro itself.
+To avoid this problem, put the string in quotes or write
+ {\tt "\$`'0\$".}
+
+\item
+\bflistitem{Name conflicts}{conflicts}
+ Using the name of a macro as part of a comment or string is a
+ simple and common error. Thus,
+
+{\tt arrow right \verb|"$\dot x$"| above}
+
+\noindent produces an error message because {\tt dot} is a macro
+name. Macro expansion can be avoided by adding quotes, as follows:
+
+{\tt arrow right `\verb|"$\dot x$"|'\ above}
+
+Library macros intended only for internal use have names that begin
+with {\tt m4} or {\tt M4} to avoid name clashes, but in addition,
+a good rule is to quote all \latex in the diagram input.
+
+If extensive use of strings
+that conflict with macro names is required, then one possibility is
+to replace the strings by macros to be expanded by \latex, for example
+the diagram
+
+{\tt
+.PS\hfill\break
+ \hspace*{\parindent} box \verb|"\stringA"|\hfill\break
+.PE
+}
+
+\noindent with the \latex macro
+
+{\tt
+ \verb|\newcommand{\stringA}{|%
+
+ \verb|Circuit containing planar inductor and capacitor}|
+}
+
+\item
+\bflistitem{Current direction}{currdir}
+ Some macros, particularly those for labels, do
+unexpected things if care is not taken to preset the current direction
+using macros {\tt right\_,} {\tt left\_,} {\tt up\_,} {\tt down\_,}
+or {\tt rpoint\_($\cdot$).}
+Thus for two-terminal macros it is good practice to write, e.g.
+
+{\tt resistor(up\_ from A to B); rlabel(,R\_1)}
+
+\noindent%
+rather than
+
+{\tt resistor(from A to B); rlabel(,R\_1),}
+
+\noindent%
+which produce different results if the last-defined drawing direction is not
+{\tt up}. It might be possible to change the label macros to avoid this problem
+without sacrificing ease of use.
+
+\item
+\bflistitem{Position of elements that are not 2-terminal}{nottwoterm}
+ The \linespec argument of elements defined in {\tt[} {\tt]}
+ blocks must be understood as defining a direction and length, but
+ not the position of the resulting block.
+ In the \pic language, objects inside these brackets are placed by
+ default {\em as if the block were a box}. Place the
+ element by its compass corners or defined interior points
+ as described in the first paragraph of \SR{Composite:} on
+ \PR{Composite:}, for example
+
+{\tt igbt(up\_ elen\_) with .E at (1,0)}
+
+\item
+\bflistitem{Pic error messages}{errormessages}
+ Some errors are detected only after scanning
+ beyond the end of the line containing the error. The semicolon
+ is a logical line end, so putting a semicolon at the end of lines may
+ assist in locating bugs.
+
+\item
+\bflistitem{Line continuation}{continuation}
+ A line is continued to the next if the
+ rightmost character is a backslash or, with \dpic, if the backslash is
+ followed immediately by the {\tt \#} character.
+ A blank after the backslash, for example, produces a \pic error.
+
+\item
+\bflistitem{Scaling}{scaling}
+ \Pic and these macros provide several ways to scale
+ diagrams and elements within them, but subtle unanticipated effects
+ may appear. The line {\tt.PS} $x$ provides a convenient way to force
+ the finished diagram to width $x.$ However, if \gpic is the
+ \pic processor then all scaled parameters are affected, including those
+ for arrowheads and text parameters, which may not be the desired
+ result. A good general rule is to use the {\tt scale} parameter for
+ global scaling unless the primary objective is to specify overall
+ dimensions.
+
+\item
+\bflistitem{Buffer overflow}{overflow}
+ For some \Mfour implementations,
+ the error message {\tt pushed back more than 4096 chars}
+ results from expanding large macros or macro arguments, and can be
+ avoided by enlarging the buffer. For example, the option {\tt
+ -B16000} enlarges the buffer size to 16000 bytes. However, this
+ error message could also result from a syntax error.
+
+\item
+\bflistitem{\PSTricks anomaly}{anomaly}
+ If you are using \PSTricks and
+ you get the error message {\tt Graphics parameter `noCurrentPoint'
+ not defined..} then your version of \PSTricks is older than
+ August 2010. You can do the following:
+\begin{enumerate}
+\item Update your \PSTricks package.
+\item Instead, comment out the second definition of {\tt M4PatchPSTricks} in
+ {\tt pstricks.m4}. The first definition works for some older
+ \PSTricks distributions.
+\item Insert {\tt define(`M4PatchPSTricks',)} immediately after the
+ {\tt .PS} line of your diagram.
+ This change prevents the line
+ \verb|\psset{noCurrentPoint}| from being added to the {\tt .tex}
+ code for the diagram. This line is a workaround for a ``feature''
+ of the current \PSTricks \verb|\psbezier| command that changes its
+ behaviour within the \verb|\pscustom| environment. This situation
+ occurs rarely and so the line is unnecessary for many diagrams.
+\item For very old versions of \PSTricks such as pstricks97, disable the
+ workaround totally by changing the second definition in {\tt pstricks.m4}
+ to {\tt define(`M4PatchPSTricks',)}. Undo the change if you later update
+ \PSTricks.
+ \end{enumerate}
+
+\item
+\bflistitem{m4 {\tt -I} error}{mfourerror}\label{Mfourerror:}
+ Some old versions of m4 may not implement
+ the {\tt -I} option or the {\tt M4PATH} environment variable that
+ simplify file inclusion.
+ The simplest course of action is probably to install GNU m4, which is
+ free and widely available.
+ Otherwise, all {\tt include({\sl filename})} statements in the libraries and
+ calling commands have to be given absolute {\sl filename} paths.
+ You can define the {\tt HOMELIB\_} macro in {\tt libgen.m4} to the
+ path of the installation directory and change the library
+ include statements to the form {\tt include(HOMELIB\_`'{\sl filename})}.
+
+\end{enumerate}
+
+\xection{List of macros\label{Listofmacros:}}
+\label{defines}
+The following table lists macros in the libraries, configuration
+files, and selected macros from example diagrams. Some of the sources
+in the {\tt examples} directory contain
+additional macros, such as for flowcharts, Boolean logic, and binary
+trees.
+
+Internal macros defined within the libraries begin with the characters
+m4 or M4 and, for the most part, are not listed here.
+
+The library in which each macro is found is given, and a brief description.
+\input defines
+\endinput
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ I think you want the pdfcomment package. This includes a \pdftooltip command.
+
+ This lets you add a tool tip to the PDF using
+ \pdftooltip{item}{tooltip},
+ where the item can be almost anything
+ (e.g. \pdftooltip{\includegraphics[]{}}{description of my figure}).
+
+ In your case, you could use
+
+ \pdftooltip{abbreviation}{what that TLA means}
+
+ But with pdfcomment, the tool tip cannot be anything but plain,
+ unformatted text.
+
+ Try the \pdfcomment package. There's an option to add a tool tip to
+ the PDF using \pdftooltip{item}{tooltip}, where the item can be a float
+ (e.g. \pdftooltip{\includegraphics[]{}}{description of my figure}).
+
+ The overall process that I've settled on to produce 508-compliant
+ documents is to
+
+ Produce a high-quality PDF from \latex which includes all of the tooltips
+ Run the PDF through the tagging tool that is provided by Adobe Acrobat X
+ (Adobe how-to).
+
+
diff --git a/graphics/circuit_macros/doc/currents.m4 b/graphics/circuit_macros/doc/currents.m4
new file mode 100644
index 0000000000..5b2e20fa54
--- /dev/null
+++ b/graphics/circuit_macros/doc/currents.m4
@@ -0,0 +1,52 @@
+.PS
+# `currents.m4'
+cct_init
+ del = 0.75
+[
+ {right_
+ resistor; b_current(i)
+ {"\tt b\_current(i)" at last line + (0,-0.20)}
+ move right_ del
+ resistor; b_current(i,below_)
+ {"\tt $\ldots$(i,below\_)" at last line + (0,-0.20)}
+ move right_ del
+ resistor; b_current(i,,O)
+ {"\tt $\ldots$(i,{,}O)" at last line + (0,-0.20)}
+ move right_ del
+ resistor; b_current(i,below_,O)
+ {"\tt $\ldots$(i,below\_,O)" at last line + (0,-0.20)}
+ }
+
+ move down_ 0.60
+ {right_
+ resistor; b_current(i,,,E)
+ {"\tt b\_current(i,{,},E)" wid 1.2 at last line + (0,-0.20)}
+ move right_ del
+ resistor; b_current(i,below_,,E)
+ {"\tt $\ldots$(i,below\_,{,}E)" at last line + (0,-0.20)}
+ move right_ del
+ resistor; b_current(i,,O,E,0.2)
+ {"\tt $\ldots$(i,{,}O,E,0.2)" at last line + (0,-0.20)}
+ move right_ del
+ resistor; b_current(i,below_,O,E)
+ {"\tt $\ldots$(i,below\_,O,E)" at last line + (0,-0.20)}
+ }
+
+ move down_ 0.60
+ {right_
+ del = 0.55
+ inductor; larrow(i)
+ {"`\tt larrow(i)'" at last line + (0,-0.20)}
+ move up 0.1 right_ del
+ inductor; rarrow(i)
+ {"`\tt rarrow(i)'" at last line + (0,-0.30)}
+ move down 0.1 right_ del
+ inductor; larrow(i,<-)
+ {"`\tt larrow(i,<-)'" at last line + (0,-0.20)}
+ move up 0.1 right_ del
+ inductor; rarrow(i,<-)
+ {"`\tt rarrow(i,<-)'" at last line + (0,-0.30)}
+ }
+]
+#showbox_
+.PE
diff --git a/graphics/circuit_macros/doc/defines.tex b/graphics/circuit_macros/doc/defines.tex
new file mode 100644
index 0000000000..84634c5862
--- /dev/null
+++ b/graphics/circuit_macros/doc/defines.tex
@@ -0,0 +1,1892 @@
+%
+\newdimen{\leftwid}\setlength{\leftwid}{2in}
+\newdimen{\libwid}\setlength{\libwid}{0.5in}
+\newdimen\rightwid
+\setlength{\rightwid}{\textwidth}
+\addtolength{\rightwid}{-\leftwid}
+\addtolength{\rightwid}{-\libwid}
+%
+\newbox\Defbox
+
+\newcommand{\macx}[2]{%
+ \phantomsection\pdfbookmark[subsection]{#1}{#2}#1}
+
+\newcommand{\macrodef}[5]{%\begin{samepage}%
+\phantomsection\pdfbookmark[subsection]{#1}{#2}%
+\setbox\Defbox=\hbox{\tt #1#3}%
+ \ifdim\wd\Defbox>\textwidth%
+ \setbox\Defbox=\hbox{\parbox{\textwidth}{\tt #1#3}}\fi
+ \ifdim\wd\Defbox>\leftwid%
+ \box\Defbox\hfill\break\hspace*{\leftwid}%
+ \else\hbox to \leftwid{\box\Defbox\hfill}\fi%
+ \hbox to \libwid{#4\hfill}\parbox[t]{\rightwid}%
+ {\raggedright #5}%
+% \end{samepage}%
+ \vspace{\parsep}\\}
+
+\newcommand{\seesect}[1]{ (\SR{#1})}
+
+\vspace{\abovedisplayskip}
+\noindent
+\macrodef{above\_}{above_}{}
+ {gen}
+ {string position above relative to current direction}
+\macrodef{abs\_}{abs_}{({\sl number})}
+ {gen}
+ {absolute value function}
+\macrodef{adc}{adc}{({\sl width,height,nIn,nN,nOut,nS})}
+ {cct}
+ {ADC with defined width, height, and number of inputs {\tt In$i$},
+ top terminals {\tt N$i$}, ouputs {\tt Out$i$},
+ and bottom terminals~{\tt S$i$}}
+\macrodef{addtaps}{addtaps}{[{\sl arrowhd}
+ | type={\sl arrowhd};name={\sl Name}],
+ {\sl fraction, length, fraction, length,} $\cdots$)}
+ {cct}
+ {Add taps to the previous two-terminal element.
+ {\sl arrowhd} = blank or one of {\tt . - <- -> <->}.
+ Each fraction determines the position along the element body of the tap.
+ A negative length draws the tap to the right of the current
+ direction; positive length to the left.
+ Tap names are Tap1, Tap2, $\cdots$ by default or
+ Name1, Name2, $\cdots$ if specified
+ \seesect{Composite:}}
+\macrodef{along\_}{along_}{({\sl linear object name})}
+ {gen}
+ {short for {\tt between {\sl name}.start and {\sl name}.end}}
+\macrodef{Along\_}{Along_}{({\sl LinearObj,distance,}[R])}
+ {gen}
+ {Position arg2 (default all the way) along a linear object
+ from {\tt .start} to {\tt .end}
+ (from {\tt .end} to {\tt .start} if arg3={\tt R}) }
+\macrodef{amp}{amp}{(\linespec,{\sl size})}
+ {cct}
+ {amplifier\seesect{Twoterminal:}}
+\macrodef{And, Or, Not, Nand, Nor, Xor, Nxor, Buffer}%
+ {And, Or, Not, Nand, Nor, Xor, Nxor, Buffer}{}
+ {log}
+ {Wrappers of {\tt AND\_gate}, $\ldots$ for use in the {\tt Autologix}
+ macro}
+\macrodef{AND\_gate}{AND_gate}{({\sl n},N)}
+ {log}
+ {basic `and' gate, 2 or {\sl n\/} inputs; {\tt N}=negated input.
+ Otherwise, arg1 can be a sequence of letters {\tt P|N}
+ to define normal or negated inputs
+ \seesect{Logicgates:}}
+\macrodef{AND\_gen}{AND_gen}{($n$,{\sl chars},[{\sl wid},[{\sl ht}]])}
+ {log}
+ {general AND gate: $n$=number of inputs $(0\leq n\leq 16)$;
+ {\sl chars:}
+ B=base and straight sides; A=Arc;
+ [N]NE,[N]SE,[N]I,[N]N,[N]S=inputs or circles;
+ [N]O=output; C=center.
+ Otherwise, arg1 can be a sequence of letters {\tt P|N}
+ to define normal or negated inputs.}
+\macrodef{AND\_ht}{AND_ht}{}
+ {log}
+ {height of basic `and' and `or' gates in {\tt L\_unit}s}
+\macrodef{AND\_wd}{AND_wd}{}
+ {log}
+ {width of basic `and' and `or' gates in {\tt L\_unit}s}
+\macrodef{antenna}{antenna}{%
+ (at {\sl location}, T, A|L|T|S|D|P|F, U|D|L|R|{\sl degrees})}
+ {cct}
+ {antenna, without stem for nonblank 2nd arg; {\tt A}=aerial,
+ {\tt L}=loop, {\tt T}=triangle, {\tt S}=diamond, {\tt D}=dipole,
+ {\tt P}=phased, {\tt F}=fork;
+ up, down, left, right, or angle from horizontal (default 90)
+ \seesect{Composite:}}
+\macrodef{arca}{arca}{({\sl absolute chord linespec}, ccw|cw, {\sl radius},
+ {\sl modifiers}) }
+ {gen}
+ {arc with acute angle (obtuse if radius is negative), drawn in a [ ] block}
+\macrodef{arcd}{arcd}{({\sl center},
+ {\sl radius},{\sl start degrees},{\sl end degrees}) }
+ {gen}
+ {Arc definition (see {\tt arcr}), angles in degrees
+ \seesect{Positions:}}
+\macrodef{arcdimension\_}{arcdimension_}{({\sl arcspec},{\sl offset},%
+{\sl label},
+ D|H|W|{\sl blank width},{\sl tic offset},{\sl arrowhead })}
+ {gen}
+ {like {\tt dimension\_}, for drawing arcs for dimensioning diagrams;
+ {\sl arrowhead=}{\tt -> | <-}. Uses the first argument as the attributes
+ of an invisible arc: {\tt arc invis }{\sl arg1}. {\sl Arg2} is the
+ radial displacement (possibly negative) of the dimension arrows.
+ If {\sl arg3} is {\tt s\_box(\ldots)} or {\sl rs\_box(\ldots)} and
+ {\sl arg4=}{\tt D|H|W} then {\sl arg4} means:
+ {\tt D:} blank width is the diagonal length of {\sl arg3};
+ {\tt H:} blank width is the height of {\sl arg3} + {\tt textoffset*2};
+ {\tt W:} blank width is the width of {\sl arg3} + {\tt textoffset*2};
+ otherwise {\sl arg4} is the absolute blank width}
+\macrodef{arcr}{arcr}{({\sl center},{\sl radius},{\sl start angle},{\sl
+ end angle,modifiers,ht}) }
+ {gen}
+ {Arc definition. If arg5 contains {\tt <-} or {\tt ->} then a midpoint
+ arrowhead of height equal to arg6 is added. Arg5 can contain modifiers
+ (e.g. outlined "red"), for the arc and arrowhead. Modifiers following
+ the macro affect the arc only,
+ e.g., {\tt arcr(A,r,0,pi\_/2,->) dotted ->}
+ \seesect{Positions:}}
+\macrodef{arcto}{arcto}{({\sl position 1},{\sl position 2},{\sl
+ radius},[dashed|dotted])}
+ {gen}
+ {line toward position 1 with rounded corner toward position 2}
+\macrodef{arrowline}{arrowline}{(\linespec)}
+ {cct}
+ {line (dotted, dashed permissible) with centred arrowhead
+ \seesect{Twoterminal:}}
+\macrodef{AutoGate}{AutoGate}{}
+ {log}
+ {Draw the tree for a gate as in the {\tt Autologix} macro. No inputs
+ or external connections are drawn. The names of the internal gate
+ inputs are stacked in {\tt `AutoInNames'}}
+\macrodef{Autologix}{Autologix}%
+ {({\sl Boolean function sequence},%
+ [N[oconnect]][L[eftinputs]][R][V][M][;offset={\sl value}]}
+ {log}
+ {Draw the Boolean expressions defined in function notation
+ using {\tt And, Or, Not, Buffer, Xor, Nand, Nor, Nxor}
+ and variables, e.g.,
+ {\tt Autologix(And(Or(x1,~x2),Or(~x1,x2)));}.
+ The Boolean functions are separated by semicolons (;). Function
+ outputs are aligned vertically but appending
+ {\tt:}{\sl location attribute} to a function can be used to place it.
+ Each unique variable {\sl var} causes an input point {\tt In}{\sl var}
+ to be defined. Preceding the variable by a {\tt \~{}} causes a not gate
+ to be drawn at the input.
+ The inputs are drawn in a row at the upper left by default.
+ An {\tt L} in arg2 draws the inputs in a column at the left;
+ {\tt R} reverses the order of the drawn inputs;
+ {\tt V} scans the expression from right to left
+ when listing inputs;
+ {\tt M} draws the left-right mirror image of the diagram;
+ and {\tt N} draws only the function tree without the input array.
+ The inputs are labelled {\tt In1}, {In2}, \ldots and the function
+ outputs are {\tt Out1}, {Out2}, \dots.
+ Each variable {\sl var} corresponds also to one of the input array
+ points with label {\tt In}{\sl var}.
+ Setting {\tt offset=}{\sl value} displaces the
+ drawn input list in order to disambiguate the input connections when {\tt L}
+ is used}
+\macrodef{b\_}{b_}{}
+ {gen}
+ {blue color value}
+\macrodef{b\_current}{b_current}{({\sl label},{\sl pos},In|Out,Start|End,{\sl
+ frac})}
+ {cct}
+ {labelled branch-current arrow to {\sl frac} between branch end and body
+ \seesect{Branchcurrent:}}
+\macrodef{basename\_}{basename_}{({\sl string sequence, separator})}
+ {gen}
+ {Extract the rightmost name from a sequence of names separated by arg2
+ (default dot ``.'')}
+\macrodef{battery}{battery}{(\linespec,{\sl n},R)}
+ {cct}
+ {n-cell battery: default 1 cell,
+ R=reversed polarity\seesect{Twoterminal:}}
+\macrodef{beginshade}{beginshade}{({\sl gray value})}
+ {gen}
+ {begin gray shading, see {\tt shade}
+ e.g., {\tt beginshade(.5);} {\sl closed line specs}; {\tt endshade}}
+\macrodef{bell}{bell}{( U|D|L|R|{\sl degrees}, {\sl size})}
+ {cct}
+ {bell, {\sl In1} to {\sl In3} defined
+ \seesect{Composite:}}
+\macrodef{below\_}{below_}{}
+ {gen}
+ {string position relative to current direction}
+\macrodef{bi\_tr}{bi_tr}{(\linespec,L|R,P,E)}
+ {cct}
+ {left or right, N- or P-type bipolar transistor, without or with envelope
+ \seesect{Semiconductors:}}
+\macrodef{bi\_trans}{bi_trans}{(\linespec,L|R,{\sl chars},E)}
+ {cct}
+ { bipolar transistor, core left or right; chars:
+ {\tt BU}=bulk line,
+ {\tt B}=base line and label,
+ {\tt S}=Schottky base hooks,
+ {\tt uEn|dEn}=emitters E0 to En,
+ {\tt uE|dE}=single emitter,
+ {\tt Cn|uCn|dCn}=collectors C0 to Cn; {\tt u} or {\tt d} add an arrow,
+ {\tt C}=single collector; {\tt u} or {\tt d} add an arrow,
+ {\tt G}=gate line and location,
+ {\tt H}=gate line; {\tt L}=L-gate line and location,
+ {\tt [d]D}=named parallel diode,
+ {\tt d}=dotted connection,
+ {\tt [u]T}=thyristor trigger line;
+ arg 4 = E: envelope
+ \seesect{Semiconductors:}}
+\macrodef{binary\_}{binary_}{($n$, [$m$])}
+ {gen}
+ {binary representation of $n,$ left padded to $m$ digits if the second
+ argument is nonblank}
+\macrodef{BOX\_gate}{BOX_gate}{({\sl inputs,output,swid,sht,label})}
+ {log}
+ {output=[{\tt P|N}], inputs=[{\tt P|N}]$\ldots$, sizes swid and sht
+ in {\tt L\_unit}s (default {\tt AND\_wd} = 7)
+ \seesect{Logicgates:}}
+\macrodef{boxcoord}{boxcoord}{({\sl planar obj},{\sl x fraction},{\sl y
+ fraction})}
+ {gen}
+ {internal point in a planar object}
+\macrodef{boxdim}{boxdim}{({\sl name},h|w|d|v,{\sl default})}
+ {gen}
+ {evaluate, e.g.\ {\sl name}{\tt \_w} if defined, else {\sl default\/}
+ if given, else 0 {\tt v} gives sum of {\tt d} and {\tt h} values
+ \seesect{Interaction:}}
+\macrodef{bp\_\_}{bp__}{}
+ {gen}
+ {big-point-size factor, in scaled inches, ({\tt *scale/72})}
+\macrodef{bswitch}{bswitch}{(\linespec, [L|R],chars)}
+ {cct}
+ {pushbutton switch R=right orientation (default L=left);
+ chars: O= normally open, C=normally closed }
+\macrodef{BUF\_ht}{BUF_ht}{}
+ {log}
+ {basic buffer gate height in {\tt L\_unit}s}
+\macrodef{BUF\_wd}{BUF_wd}{}
+ {log}
+ {basic buffer gate width in {\tt L\_unit}s}
+\macrodef{BUFFER\_gate}{BUFFER_gate}{(\linespec, [N|B],
+ {\sl wid, ht,} [N|P]\char42, [N|P]\char42, [N|P]\char42)}
+ {log}
+ {basic buffer, dfault 1 input or as a 2-terminal element,
+ arg2: {\tt N}=negated input, {\tt B}=box gate; arg 5:
+ normal ({\tt P}) or negated {\tt N}) inputs labeled In1
+ \seesect{Logicgates:}}
+\macrodef{BUFFER\_gen}{BUFFER_gen}{({\sl chars,wd,ht},[N|P]*,[N|P]*,[N|P]*)}
+ {log}
+ {general buffer, {\sl chars:} {\tt T}=triangle,
+ {\tt [N]O}=output location {\tt Out}
+ ({\tt NO} draws circle {\tt N\_Out});
+ {\tt [N]I, [N]N, [N]S, [N]NE, [N]SE}
+ input locations; {\tt C}=centre location.
+ Args 4-6 allow alternative
+ definitions of respective {\tt In, NE,}
+ and {\tt SE} argument sequences }
+\macrodef{buzzer}{buzzer}{( U|D|L|R|{\sl degrees, size,}[C])}
+ {cct}
+ {buzzer, {\sl In1} to {\sl In3} defined, C=curved
+ \seesect{Composite:}}
+\macrodef{c\_fet}{c_fet}{(\linespec,L|R,P)}
+ {cct}
+ {left or right, plain or negated pin simplified MOSFET}
+\macrodef{capacitor}{capacitor}{(\linespec,{\sl char}[+[L]],R,
+ {\sl height}, {\sl wid})}
+ {cct}
+ {capacitor, {\sl char}: F or none=flat plate, C=curved-plate,
+ E=polarized boxed plates,
+ K=filled boxed plates,
+ M=unfilled boxes,
+ M=one rectangular plate,
+ P=alternate polarized; + adds a polarity sign;
+ +L polarity sign to the left of drawing direction;
+ arg3: R=reversed polarity,
+ arg4 = height (defaults F: {\tt dimen\_}$/3$,
+ C,P: {\tt dimen\_}$/4$, E,K: {\tt dimen\_}$/5$)
+ arg5 = wid (defaults F: {\sl height}*0.3,
+ C,P: {\sl height}*0.4, E,K: {\sl height}) \seesect{Twoterminal:}}
+\macrodef{cbreaker}{cbreaker}{(\linespec,L|R,D|T|TS)}
+ {cct}
+ {circuit breaker to left or right, {\tt D}=with dots; {\tt T}=thermal;
+ {\tt TS}=squared thermal\seesect{Twoterminal:}}
+\macrodef{ccoax}{ccoax}{(at {\sl location}, M|F, {\sl diameter})}
+ {cct}
+ {coax connector, {\tt M}=male, {\tt F}=female
+ \seesect{Composite:}}
+\macrodef{cct\_init}{cct_init}{}
+ {cct}
+ {initialize circuit-diagram environment (reads {\tt libcct.m4})}
+\macrodef{centerline\_}{centerline_}{({\sl linespec, thickness{\tt|}color,
+ minimum long dash len, short dash len, gap len}}
+ {gen}
+ {Technical drawing centerline}
+\macrodef{Cintersect}{Cintersect}{({\sl Pos1, Pos2, rad1, rad2,} [R])}
+ {gen}
+ {Upper (lower if arg5={\tt R}) intersection of circles at
+ {\sl Pos1} and {\sl Pos2}, radius {\sl rad1} and {\sl rad2}}
+\macrodef{clabel}{clabel}{({\sl label},{\sl label},{\sl label})}
+ {cct}
+ {centre triple label \seesect{Labels:}}
+\macrodef{cm\_\_}{cm__}{}
+ {gen}
+ {absolute centiimetres}
+\macrodef{consource}{consource}{(\linespec,V|I|v|i,R)}
+ {cct}
+ {voltage or current controlled source with alternate forms;
+ {\tt R}=reversed polarity\seesect{Twoterminal:}}
+\macrodef{contact}{contact}{({\sl chars})}
+ {cct}
+ {single-pole contact: {\tt P}= three position, {\tt O}= normally open,
+ {\tt C}= normally closed, {\tt I}= circle contacts, {\tt R}= right
+ orientation
+ \seesect{Composite:}}
+\macrodef{contline}{contline}{({\sl line})}
+ {gen}
+ {evaluates to {\tt continue}
+ if processor is {\bf dpic}, otherwise to first arg (default {\tt line})}
+\macrodef{corner}{corner}{({\sl line thickness,attributes,turn radians})}
+ {gen}
+ { Mitre (default filled square) drawn at end of last line or at a
+ given position.
+ arg1 default: current line thickness;
+ arg2: e.g. {\tt outlined} {\sl string}; if arg2 starts with
+ {\tt at} {\sl position} then a manhattan (right-left-up-down) corner
+ is drawn;
+ arg3= radians (turn angle, +ve is ccw, default $\pi/2$).
+ The corner is enclosed in braces
+ in order to leave {\tt Here} unchanged unless arg2 begins with {\tt at}
+ \seesect{Corners:}}
+\macrodef{Cos}{Cos}{({\sl integer})}
+ {gen}
+ {cosine function, {\sl integer\/} degrees}
+\macrodef{cosd}{cosd}{({\sl arg})}
+ {gen}
+ {cosine of an expression in degrees}
+\macrodef{Cosine}{Cosine}{( {\sl amplitude}, {\sl freq}, {\sl time},
+ {\sl phase} )}
+ {gen}
+ {function $a\times\cos(\omega t + \phi)$ }
+\macrodef{cross}{cross}{(at {\sl location})}
+ {gen}
+ {plots a small cross}
+\macrodef{cross3D}{cross3D}{({\sl x1,y1,z1,x2,y2,z2})}
+ {3D}
+ {cross product of two triples}
+\macrodef{crossover}{crossover}{(\linespec, L|R, Line1, ...)}
+ {cct}
+ {line jumping left or right over named lines\seesect{Semiconductors:}}
+\macrodef{crosswd\_}{crosswd_}{}
+ {gen}
+ {cross dimension}
+\macrodef{csdim\_}{csdim_}{}
+ {cct}
+ {controlled-source width}
+\macrodef{d\_fet}{d_fet}{(\linespec,L|R,P,S,E|S)}
+ {cct}
+ {left or right, N or P depletion MOSFET, normal or simplified,
+ without or with envelope or thick channel
+ \seesect{Semiconductors:}}
+\macrodef{dabove}{dabove}{(at {\sl location})}
+ {darrow}
+ {above (displaced dlinewid/2)}
+\macrodef{dac}{dac}{({\sl width,height,nIn,nN,nOut,nS})}
+ {cct}
+ {DAC with defined width, height, and number of inputs {\tt In$i$},
+ top terminals {\tt N$i$}, ouputs {\tt Out$i$},
+ and bottom terminals~{\tt S$i$} \seesect{Logicgates:}}
+\macrodef{darc}{darc}{({\sl center position},
+ {\sl radius}, {\sl start radians}, {\sl end radians}, {\sl dline thickness},
+ {\sl arrowhead wid}, {\sl arrowhead ht},
+ {\sl terminals})}
+ {darrow}
+ {See also {\tt Darc}.
+ CCW arc in {\tt dline} style, with closed ends or (dpic only) arrowheads.
+ Permissible {\sl terminals}:
+ {\sl x}{\tt -},
+ {\tt -}{\sl x}, {\sl x}{\tt -}{\sl x}, {\tt ->}, {\sl x}{\tt ->},
+ {\tt <-}, {\tt <-}{\sl x}, {\tt <->}
+ where {\sl x} means {\tt |} or (half-thickness line) {\tt !}.}
+\macrodef{Darc}{Darc}{({\sl center position},
+ {\sl radius}, {\sl start radians}, {\sl end radians},
+ {\sl parameters})}
+ {darrow}
+ {Wrapper for {\tt darc}.
+ CCW arc in {\tt dline} style, with closed ends or (dpic only) arrowheads.
+ Semicolon-separated {\sl parameters}:
+ {\tt thick=}{\sl value}, {\tt wid=}{\sl value}, {\tt ends=}
+ {\sl x}{\tt -},
+ {\tt -}{\sl x}, {\sl x}{\tt -}{\sl x}, {\tt ->}, {\sl x}{\tt ->},
+ {\tt <-}, {\tt <-}{\sl x}, {\tt <->}
+ where {\sl x} means {\tt |} or (half-thickness line) {\tt !}.}
+\macrodef{Darlington}{Darlington}{(L|R,{\sl chars})}
+ {cct}
+ {Composite Darlington pair Q1 and Q2 with internal locations E, B, C;
+ Characters in {\sl arg2:}
+ E= envelope,
+ P= P-type,
+ B1= internal base lead,
+ D= damper diode,
+ R1= Q1 bias resistor; E1= ebox,
+ R2= Q2 bias resistor; E1= ebox,
+ Z= zener bias diode
+ \seesect{Semiconductors:}}
+\macrodef{darrow\_init}{darrow_init}{}
+ {darrow}
+ {initialize darrow drawing parameters (reads {\tt darrow.m4})}
+\macrodef{Darrow}{Darrow}{(\linespec, {\sl parameters})}
+ {darrow}
+ {Wrapper for {\tt darrow}.
+ Semicolon-separated {\sl parameters}:
+ {\tt S}, {\tt E} truncate at start or end by dline thickness/2;
+ {\tt thick=}{\sl val} (total thicknes, ie width);
+ {\tt wid=}{\sl val} (arrowhead width);
+ {\tt ht=}{\sl val} (arrowhead height);
+ {\tt ends=}
+ {\sl x}{\tt -}{\sl x} or
+ {\tt -}{\sl x} or
+ {\sl x}{\tt -} where {\sl x} is {\tt !} (half-width line)
+ or {\tt |} (full-width line).}
+\macrodef{darrow}{darrow}{(\linespec,
+ t,t,{\sl width},{\sl arrowhd wd},{\sl arrowhd ht},{\sl parameters})}
+ {darrow}
+ {See also {\tt Darrow}.
+ double arrow, truncated at beginning or end, specified sizes,
+ with arrowhead or closed stem.
+ {\sl parameters=}
+ {\tt {\sl x}-} or {\tt ->} or {\tt {\sl x}->} or {\tt <-} or {\tt <-{\sl x}}
+ or {\tt <->} where {\sl x} is {\tt |} or {\tt !}.
+ The {\tt !-} or {\tt -!} parameters close
+ the stem with half-thickness lines to simplify butting to other objects. }
+\macrodef{dashline}{dashline}{(\linespec,{\sl thickness}|{\sl color}|<->,
+ {\sl dash len, gap len},G)}
+ {gen}
+ {dashed line with dash at end ({\tt G} ends with gap)}
+\macrodef{dbelow}{dbelow}{(at {\sl location})}
+ {darrow}
+ {below (displaced dlinewid/2)}
+\macrodef{dcosine3D}{dcosine3D}{({\sl i,x,y,z})}
+ {3D}
+ {extract i-th entry of triple x,y,z}
+\macrodef{delay\_rad\_}{delay_rad_}{}
+ {cct}
+ {delay radius}
+\macrodef{delay}{delay}{(\linespec,{\sl size})}
+ {cct}
+ {delay element\seesect{Twoterminal:}}
+\macrodef{deleminit\_}{deleminit_}{}
+ {darrow}
+ {sets drawing direction for dlines}
+\macrodef{Demux}{Demux}{({\sl n},{\sl label},
+ {\tt [L][B|H|X][N[{\sl n}]|S[{\sl n}]][[N]OE],
+ {\sl wid},{\sl ht}})}
+ {log}
+ {binary multiplexer, $n$ inputs,
+ {\tt L} reverses input pin numbers,
+ {\tt B} displays binary pin numbers,
+ {\tt H} displays hexadecimal pin numbers,
+ {\tt X} do not print pin numbers,
+ {\tt N[{\sl n}]} puts Sel or Sel$0$ .. Sel$n$ at the top
+ (i.e., to the left of the drawing direction),
+ {\tt S[{\sl n}]} puts the Sel inputs at the bottom (default)
+ {\tt OE} ({\tt N=}negated) {\tt OE} pin
+ \seesect{Logicgates:}}
+\macrodef{dend}{dend}{(at {\sl location})}
+ {darrow}
+ {close (or start) double line}
+\macrodef{dfillcolor}{dfillcolor}{}
+ {darrow}
+ {dline fill color (default white)}
+\macrodef{diff\_}{diff_}{({\sl a},{\sl b})}
+ {gen}
+ {difference function}
+\macrodef{diff3D}{diff3D}{({\sl x1,y1,z1,x2,y2,z2})}
+ {3D}
+ {difference of two triples}
+\macrodef{dimen\_}{dimen_}{}
+ {cct}
+ {size parameter for circuit elements \seesect{Circuitscaling:}}
+\macrodef{dimension\_}{dimension_}{(\linespec,{\sl offset},{\sl label},
+ D|H|W|{\sl blank width},{\sl tic offset},{\sl arrowhead })}
+ {gen}
+ {macro for dimensioning diagrams;
+ {\sl arrowhead=}{\tt -> | <-}}
+\macrodef{diode}{diode}{(\linespec,%
+B|CR|D|G|L|LE[R]|P[R]|S|Sh|T|V|v|w|Z|chars,%
+[R][E])}
+ {cct}
+ {diode:
+ {\tt B}=bi-directional,
+ {\tt CR}=current regulator,
+ {\tt D}=diac,
+ {\tt G}=Gunn,
+ {\tt L}=open form with centre line,
+ {\tt LE[R]}=LED [right],
+ {\tt P[R]}=photodiode [right],
+ {\tt S}=Schottky,
+ {\tt Sh}=Shockley,
+ {\tt T}=tunnel,
+ {\tt V}=varicap,
+ {\tt v}=varicap (curved plate),
+ {\tt w}=varicap (reversed polarity),
+ {\tt Z}=zener;
+ appending {\tt K} to arg 2 draws open arrowheads;
+ arg 3: {\tt R}=reversed polarity, {\tt E}=enclosure \seesect{Twoterminal:}}
+\macrodef{dir\_}{dir_}{}
+ {darrow}
+ {used for temporary storage of direction by darrow macros}
+\macrodef{distance}{distance_}{({\sl Position 1}, {\sl Position2})}
+ {gen}
+ {distance between named positions}
+\macrodef{distance}{distance}{({\sl position}, {\sl position})}
+ {gen}
+ {distance between positions}
+\macrodef{dlabel}{dlabel}{({\sl long},{\sl lat},{\sl label},{\sl
+ label},{\sl label},{\sl chars})}
+ {cct}
+ {general triple label; {\sl chars:}
+ X displacement is from the centre of the last
+ line rather than the centre of the last {\tt [ ]};
+ L,R,A,B align labels ljust, rjust, above,
+ or below (absolute) respectively \seesect{Labels:}}
+\macrodef{dleft}{dleft}{}
+ {darrow}
+ {double line left turn}
+\macrodef{Dline}{Dline}{(\linespec, {\sl parameters})}
+ {darrow}
+ {Wrapper for {\tt dline}.
+ Semicolon-separated {\sl parameters}:
+ {\tt S}, {\tt E} truncate at start or end by dline thickness/2;
+ {\tt thick=}{\sl val} (total thicknes, ie width);
+ {\tt ends=}
+ {\sl x}{\tt -}{\sl x} or
+ {\tt -}{\sl x} or
+ {\sl x}{\tt -} where {\sl x} is {\tt !} (half-width line)
+ or {\tt |} (full-width line).}
+\macrodef{dline}{dline}{(\linespec,t,t,{\sl width},{\sl parameters})}
+ {darrow}
+ {See also {\tt Dline}.
+ Double line, truncated by half width at either end, closed
+ at either or both ends.
+ {\sl parameters=}
+ {\sl x}{\tt -}{\sl x} or
+ {\tt -}{\sl x} or
+ {\sl x}{\tt -} where {\sl x} is {\tt !} (half-width line)
+ or {\tt |} (full-width line).}
+\macrodef{dlinewid}{dlinewid}{}
+ {darrow}
+ {width of double lines}
+\macrodef{dljust}{dljust}{(at {\sl location})}
+ {darrow}
+ {ljust (displaced dlinewid/2)}
+\macrodef{dn\_}{dnx}{}
+ {gen}
+ {down with respect to current direction}
+\macrodef{dna\_}{dna_}{}
+ {cct}
+ {internal character sequence that specifies which subcomponents are drawn}
+%\macrodef{dnm\_}{dnm_}{}
+% {cct}
+% {similar to dna\_}
+\macrodef{dot}{dot}{(at {\sl location},{\sl radius},{\sl fill})}
+ {gen}
+ {filled circle (third arg= gray value: 0=black, 1=white)}
+\macrodef{dot3D}{dot3D}{({\sl x1,y1,z1,x2,y2,z2})}
+ {3D}
+ {dot product of two triples}
+\macrodef{dotrad\_}{dotrad_}{}
+ {gen}
+ {dot radius}
+\macrodef{down\_}{down_}{}
+ {gen}
+ {sets current direction to down \seesect{Placing:}}
+\macrodef{dright}{dright}{}
+ {darrow}
+ {double arrow right turn}
+\macrodef{drjust}{drjust}{(at {\sl location})}
+ {darrow}
+ {rjust (displaced dlinewid/2)}
+\macrodef{dswitch}{dswitch}{(\linespec,L|R,W[ud]B[K]{\sl chars})}
+ {cct}
+ {SPST switch left or right, W=baseline, B=contact blade,
+ dB=contact blade to the right of drawing direction,
+ K=vertical closing contact line,
+ C = external operating mechanism,
+ D = circle at contact and hinge,
+ (dD = hinge only, uD = contact only)
+ E = emergency button,
+ EL = early close
+ (or late open),
+ LE = late close (or early open),
+ F = fused,
+ H = time delay closing,
+ uH = time delay opening,
+ HH = time delay
+ opening and closing,
+ K = vertical closing contact,
+ L = limit,
+ M = maintained (latched),
+ MM = momentary contact on make,
+ MR = momentary contact on release,
+ MMR = momentary contact
+ on make and release,
+ O = hand operation button,
+ P = pushbutton,
+ T = thermal control linkage,
+ Y = pull switch,
+ Z = turn switch
+ \seesect{Twoterminal:}}
+\macrodef{dtee}{dtee}{([L|R])}
+ {darrow}
+ {double arrow tee junction with tail to left,
+ right, or (default) back along current direction }
+\macrodef{dtor\_}{dtor_}{}
+ {gen}
+ {degrees to radians conversion constant}
+\macrodef{dturn}{dturn}{({\sl degrees ccw})}
+ {darrow}
+ {turn dline arg1 degrees left (ccw)}
+\macrodef{E\_\_}{E__}{}
+ {gen}
+ {the constant $e$}
+\macrodef{e\_}{e_}{}
+ {gen}
+ {.e relative to current direction}
+\macrodef{e\_fet}{e_fet}{(\linespec,L|R,P,S,E|S)}
+ {cct}
+ {left or right, N or P enhancement MOSFET, normal
+ or simplified, without or with envelope or thick channel
+ \seesect{Semiconductors:}}
+\macrodef{earphone}{earphone}{( U|D|L|R|{\sl degrees, size})}
+ {cct}
+ {earphone, {\sl In1} to {\sl In3} defined
+ \seesect{Composite:}}
+\macrodef{ebox}{ebox}{(\linespec,{\sl length},{\sl ht},{\sl fill value})}
+ {cct}
+ { two-terminal box element with adjustable dimensions and fill
+ value 0 (black) to 1 (white). {\sl length} and {\sl ht} are relative
+ to the direction of \linespec\seesect{Twoterminal:}}
+\macrodef{elchop}{elchop}{({\sl Name1,Name2})}
+ {gen}
+ {{\tt chop} for ellipses: evaluates to {\tt chop} $r$ where $r$ is
+ the distance from the centre of ellipse Name1 to the intersection of
+ the ellipse with a line to location Name2;
+ e.g., {\tt line from A to E elchop(E,A)}}
+\macrodef{eleminit\_}{eleminit_}{(\linespec)}
+ {cct}
+ {internal line initialization}
+\macrodef{elen\_}{elen_}{}
+ {cct}
+ {default element length}
+\macrodef{em\_arrows}{em_arrows}{([N|I|E][D],{\sl angle,length})}
+ {cct}
+ {radiation arrows, N=nonionizing, I=ionizing, E=simple;
+ D=dot\seesect{Twoterminal:}}
+\macrodef{endshade}{endshade}{}
+ {gen}
+ {end gray shading, see {\tt beginshade}}
+\macrodef{Equidist3}{Equidist3}{({\sl Pos1, Pos2, Pos3, Result})}
+ {gen}
+ {Calculates location named {\sl Result} equidistant from the first three
+ positions, i.e.\ the centre of the circle passing through the three
+ positions}
+\macrodef{expe}{expe}{}
+ {gen}
+ {exponential, base $e$}
+\macrodef{f\_box}{f_box}{({\sl boxspecs},{\sl text},{\sl expr1},$\cdots$)}
+ {gen}
+ {like {\tt s\_box} but the text is overlaid on a box of identical size.
+ If there is only one argument then the default box
+ is invisible and filed white
+ \seesect{Interaction:}}
+\macrodef{Fector}{Fector}{({\sl x1,y1,z1,x2,y2,z2})}
+ {3D}
+ {vector projected on current view plane with top face
+ of 3-dimensonal arrowhead normal to x2,y2,z2 }
+\macrodef{FF\_ht}{FF_ht}{}
+ {cct}
+ {flipflop height parameter in {\tt L\_unit}s}
+\macrodef{FF\_wid}{FF_wid}{}
+ {cct}
+ {flipflop width parameter in {\tt L\_unit}s}
+\macrodef{fill\_}{fill_}{({\sl number})}
+ {gen}
+ {fill macro, 0=black, 1=white\seesect{Semiconductors:}}
+\macrodef{fitcurve}{fitcurve}{(V,n,[e.g. dotted],m (default 0))}
+ {gen}
+ {Draw a spline through positions V[m], $ldots$ V[n]: Works only with dpic.}
+\macrodef{FlipFlop}{FlipFlop}{(D|T|RS|JK,{\sl label},{\sl boxspec})}
+ {log}
+ {flip-flops,
+ {\sl boxspec}=e.g.\ ht x wid y \seesect{Logicgates:}}
+\macrodef{FlipFlop6}{FlipFlop6}{({\sl label},{\sl spec},{\sl boxspec})}
+ {log}
+ {{\em This macro (6-input flip-flops)
+ has been superseded by {\tt FlipFlopX} and may be deleted
+ in future}.
+ {\sl spec}={\tt [[n]NQ][[n]Q][[n]CK][[n]PR][lb]}
+ {\tt [[n]CLR][[n]S][[n].|D|T|R]} to include and negate pins,
+ {\tt lb} to print labels }
+\macrodef{FlipFlopJK}{FlipFlopJK}{({\sl label}, {\sl spec},{\sl boxspec})}
+ {log}
+ {{\em This macro (JK flip-flop)
+ has been superseded by {\tt FlipFlopX} and may be deleted
+ in future}.
+ Similar to {\tt FlipFlop6}.}
+\macrodef{FlipFlopX}{FlipFlopX}{({\sl boxspec, label, leftpins, toppins,
+ rightpins, bottompins})}
+ {log}
+ {General flipflop. Each of args 3 to 6 is null or a string of {\sl pinspecs}
+ separated by semicolons ({\tt;}). {\sl Pinspecs} are either empty
+ or of the form
+ {\tt[}{\sl pinopts}{\tt]:[}{\sl label}{\tt[:}{\sl Picname}{\tt]]}.
+ The first colon draws the pin.
+ Pins are placed top to bottom or left to right along the box edges with
+ null {\sl pinspecs} counted for placement. Pins are named by side and number
+ by default; eg {\tt W1, W2, ..., N1, N2, ..., E1, ..., S1, ...} ; however,
+ if {\tt:}{\sl Picname} is present in a {\sl pinspec} then {\sl Picname}
+ replaces the default name.
+ A {\sl pinspec} label is text placed at the pin base. Semicolons are
+ not allowed in labels; use, e.g., {\tt \char92{}char59\char123\char125}
+ instead,
+ and to put a bar over a label, use {\tt lg\_bartxt(}{\sl label}{\tt)}.
+ The {\sl pinopts} are {\tt[N|L|M][E]};
+ {\tt N}=pin with not circle;
+ {\tt L}=active low out; {\tt M}=active low in;
+ {\tt E}=edge trigger \seesect{Logicgates:}}
+\macrodef{for\_}{for_}{({\sl start},{\sl end},{\sl increment},`{\sl actions}')}
+ {gen}
+ {integer for loop with index variable {\tt m4x} \seesect{Looping:}}
+\macrodef{FTcap}{FTcap}{({\sl chars})}
+ {cct}
+ {Feed-through capacitor; example of a composite element derived from
+ a two-terminal element. Defined points: {\sl .Start, .End, .C .T1 .T2 T}
+ Arg 1: (default) {\tt A}= type A, {\tt B}= type B, {\tt C}= type C
+ \seesect{Composite:}}
+\macrodef{fuse}{fuse}{({\sl linespec, type, wid, ht})}
+ {cct}
+ {fuse symbol, type$=$
+ {\tt A|B|C|D|S|HB|HC} or {\tt dA=D}\seesect{Twoterminal:}}
+\macrodef{g\_}{g_}{}
+ {gen}
+ {green color value}
+\macrodef{G\_hht}{G_hht}{}
+ {log}
+ {gate half-height in {\tt L\_unit}s}
+\macrodef{gap}{gap}{(\linespec,{\sl fill},A)}
+ {cct}
+ {gap with (filled) dots, A=chopped arrow between dots\seesect{Twoterminal:}}
+\macrodef{gen\_init}{gen_init}{}
+ {gen}
+ {initialize environment for general diagrams
+ (customizable, reads {\tt libgen.m4})}
+\macrodef{glabel\_}{glabel_}{}
+ {cct}
+ {internal general labeller}
+%\macrodef{gpar\_}{gpar_}{({\sl element},{\sl element},{\sl separation})}
+% {cct}
+% {two same-direction elements in parallel}
+\macrodef{gpolyline\_}{gpolyline_}{({\sl fraction},{\sl location}, ...)}
+ {gen}
+ {internal to {\tt gshade}}
+\macrodef{graystring}{graystring}{({\sl gray value})}
+ {gen}
+ {evaluates to a string compatible with the postprocessor in use
+ to go with {\tt colored}, {\tt shaded}, or {\tt outlined} attributes.
+ (PSTricks, metapost, pgf-tikz, pdf, postscript, svg).
+ The argument is a fraction in the range $[0,1]$; see {\tt rgbstring}}
+\macrodef{grid\_}{grid_}{({\sl x},{\sl y})}
+ {log}
+ {absolute grid location}
+\macrodef{ground}{ground}{(at {\sl location}, T, N|F|S|L|P|E, U|D|L|R|{\sl
+ degrees})}
+ {cct}
+ { ground, without stem for nonblank 2nd arg;
+ {\tt N}=normal, {\tt F}=frame, {\tt S}=signal, {\tt L}=low-noise,
+ {\tt P}=protective, {\tt E}=European; up, down, left, right, or angle
+ from horizontal (default -90)
+ \seesect{Composite:}}
+\macrodef{gshade}{gshade}{({\sl gray value},A,B,...,Z,A,B)}
+ {gen}
+ {(Note last two arguments). Shade a polygon with named
+ vertices, attempting to avoid sharp corners}
+\macrodef{gyrator}{gyrator}{({\sl box specs,space ratio,pin lgth,}[N][V])}
+ {cct}
+ {Gyrator two-port wrapper for {\tt nport}, {\tt N} omits pin dots; {\tt V}
+ gives a vertical orientation
+ \seesect{Composite:}}
+\macrodef{H\_ht}{H_ht}{}
+ {log}
+ {hysteresis symbol dimension in {\tt L\_unit}s}
+\macrodef{Header}{Header}{(1|2,{\sl rows,wid,ht,type})}
+ {log}
+ {Header block with 1 or 2 columns and square Pin 1
+ \seesect{Composite:}}
+\macrodef{HeaderPin}{HeaderPin}{({\sl location, type, Picname},%
+n|e|s|w,{\sl length})}
+ {log}
+ {General pin for {\tt Header} macro; arg 4 specifies pin direction
+ with respect to the current drawing direction)}
+\macrodef{hatchbox}{hatchbox}{({\sl boxspec,hashsep,hatchspec})}
+ {gen}
+ {Manhattan box with 45 degree hatching, e.g.,
+ {\tt hatchbox(outlined "blue",,dashed outlined "green" thick 0.4)}}
+\macrodef{heater}{heater}{({\sl linespec, ndivisions, wid, ht})}
+ {cct}
+ {heater element\seesect{Twoterminal:}}
+\macrodef{hex\_digit}{hex_digit}{($n$)}
+ {gen}
+ {hexadecimal digit for $0 \leq n < 16$}
+\macrodef{hexadecimal\_}{hexadecimal_}{($n$, [$m$])}
+ {gen}
+ {hexadecimal representation of $n,$ left padded to $m$ digits if the second
+ argument is nonblank}
+\macrodef{hlth}{hlth}{}
+ {gen}
+ {current line half thickness in drawing units}
+\macrodef{hoprad\_}{hoprad_}{}
+ {cct}
+ {hop radius in crossover macro}
+\macrodef{ht\_}{ht_}{}
+ {gen}
+ {height relative to current direction}
+\macrodef{ifdpic}{ifdpic}{({\sl if true},{\sl if false})}
+ {gen}
+ {test if dpic has been specified as pic processor}
+\macrodef{ifgpic}{ifgpic}{({\sl if true},{\sl if false})}
+ {gen}
+ {test if gpic has been specified as pic processor}
+\macrodef{ifinstr}{ifinstr}{({\sl string},{\sl string},{\sl if true},{\sl
+ if false})}
+ {gen}
+ {test if the second argument is a substring of the first; also
+ {\tt ifinstr({\sl string},{\sl string},{\sl if true},{\sl
+ string},{\sl string},{\sl if true}, $\ldots$ {\sl if false})}
+ }
+\macrodef{ifmfpic}{ifmfpic}{({\sl if true},{\sl if false})}
+ {gen}
+ {test if mfpic has been specified as pic post-processor}
+\macrodef{ifmpost}{ifmpost}{({\sl if true},{\sl if false})}
+ {gen}
+ {test if MetaPost has been specified as pic post-processor}
+\macrodef{ifpgf}{ifpgf}{({\sl if true},{\sl if false})}
+ {gen}
+ {test if \TPGF~has been specified as pic post-processor}
+\macrodef{ifpostscript}{ifpostscript}{({\sl if true},{\sl if false})}
+ {gen}
+ {test if Postscript ({\tt dpic -r}) has been specified as pic output format}
+\macrodef{ifpsfrag}{ifpsfrag}{({\sl if true},{\sl if false})}
+ {gen}
+ {Test if either {\tt psfrag} or {\tt psfrag\_} has been defined. For
+ postscript with psfrag strings, one or the other should be defined
+ prior to or at the beginning of the diagram}
+\macrodef{ifpstricks}{ifpstricks}{({\sl if true},{\sl if false})}
+ {gen}
+ {test if \PSTricks~has been specified as post-processor}
+\macrodef{ifroff}{ifroff}{({\sl if true},{\sl if false})}
+ {gen}
+ {test if {\bf troff} or {\bf groff} has been specified as post-processor}
+\macrodef{ifxfig}{ifxfig}{({\sl if true},{\sl if false})}
+ {gen}
+ {test if Fig 3.2 ({\tt dpic -x}) has been specified as pic output format}
+\macrodef{igbt}{igbt}{(\linespec,L|R,[L][[d]D])}
+ {cct}
+ {left or right IGBT, L=alternate gate type, D=parallel diode,
+ dD=dotted connections }
+\macrodef{in\_\_}{in__}{}
+ {gen}
+ {absolute inches}
+\macrodef{inductor}{inductor}{(\linespec,W|L,{\sl n},[M|P],{\sl loop wid})}
+ {cct}
+ {inductor, arg2: narrow (default), W=wide, L=looped;
+ arg3: {\sl n} arcs (default 4);
+ arg4: M=magnetic core, P=powder (dashed) core,
+ arg5: loop width (default L,W: {\tt dimen\_}/5; other: {\tt dimen\_}/8)
+ \seesect{Twoterminal:}}
+\macrodef{inner\_prod}{inner_prod}{({\sl linear obj},{\sl linear obj})}
+ {gen}
+ {inner product of (x,y) dimensions of two linear objects}
+\macrodef{Int\_}{Int_}{}
+ {gen}
+ {corrected (old) gpic $int()$ function}
+\macrodef{integrator}{integrator}{(\linespec,{\sl size})}
+ {cct}
+ {integrating amplifier\seesect{Twoterminal:}}
+\macrodef{intersect\_}{intersect_}{({\sl line1}.start,{\sl line1}.end,
+{\sl line2}.start,{\sl line2}.end)}
+ {gen}
+ {intersection of two lines}
+\macrodef{Intersect\_}{Intersect_}{({\sl Name1},{\sl Name2})}
+ {gen}
+ {intersection of two named lines}
+\macrodef{IOdefs}{IOdefs}{(\linespec,{\sl label},[P|N]*,L|R) }
+ {log}
+ {Define locations {\sl label}{\tt 1}, $\ldots$ {\sl label}{\tt n}
+ along the line; {\tt P}= label only;
+ {\tt N}=with {\tt NOT\_circle};
+ {\tt R}=circle to right of current direction }
+\macrodef{j\_fet}{j_fet}{(\linespec,L|R,P,E)}
+ {cct}
+ {left or right, N or P JFET, without or with envelope
+ \seesect{Semiconductors:}}
+\macrodef{jack}{jack}{(U|D|L|R|{\sl degrees},{\sl chars})}
+ {cct}
+ {arg1: drawing direction; string arg2: {\tt R}=right orientation,
+ one or more {\tt L[M][B]} for L and auxiliary contacts with make or break
+ points; {\tt S[M][B]} for S and auxiliary contacts
+ \seesect{Composite:}}
+\macrodef{KelvinR}{KelvinR}{({\sl cycles},[R],{\sl cycle wid})}
+ {cct}
+ {IEEE resistor in a {\tt [ ]} block with Kelvin taps {\sl T1} and {\sl T2}
+ \seesect{Composite:}}
+\macrodef{L\_unit}{L_unit}{}
+ {log}
+ {logic-element grid size}
+\macrodef{lamp}{lamp}{(\linespec, [R])}
+ {cct}
+ {Two-terminal incandescent lamp
+ \seesect{Twoterminal:}}
+\macrodef{larrow}{larrow}{({\sl label},{\tt ->|<-},{\sl dist})}
+ {cct}
+ {arrow {\sl dist} to left of last-drawn 2-terminal element
+ \seesect{Branchcurrent:}}
+\macrodef{lbox}{lbox}{({\sl wid}, {\sl ht}, {\sl type})}
+ {gen}
+ {box oriented in current direction, type= e.g.\ dotted}
+\macrodef{LCintersect}{LCintersect}{({\sl line name, Centre, rad,} [R])}
+ {gen}
+ { First (second if arg4 is R) intersection of a line with a circle}
+\macrodef{LCtangent}{LCtangent}{({\sl Pos1, Centre, rad,} [R])}
+ {gen}
+ { Left (right if arg4=R) tangent point of line
+ from Pos1 to circle at Centre with radius arg3}
+\macrodef{left\_}{left_}{}
+ {gen}
+ {left with respect to current direction \seesect{Placing:}}
+\macrodef{length3D}{length3D}{(x,y,z)}
+ {3D}
+ {Euclidean length of triple x,y,z}
+\macrodef{LEintersect}{LEintersect}{({\sl line name, Centre, ellipse wid,
+ ellipse ht}, [R])}
+ {gen}
+ { First (second if arg5 is R) intersection of a line with an ellipse}
+\macrodef{LEtangent}{LEtangent}{({\sl Pos1, Centre, ellips wid, ellipse ht}
+ [R])}
+ {gen}
+ { Left (right if arg5=R) tangent point of line
+ from Pos1 to ellipse at Centre with given width and height}
+\macrodef{lg\_bartxt}{lg_bartxt}{}
+ {log}
+ {draws an overline over logic-pin text (except for xfig)}
+\macrodef{lg\_pin}{lg_pin}{({\sl location, logical name, pin label},
+ n|e|s|w[L|M|I|O][N][E], {\sl pinno, optlen})}
+ {log}
+ {comprehensive logic pin; {\tt n|e|s|w}=direction,
+ {\tt L}=active low out, {\tt M}=active low in,
+ {\tt I}=inward arrow, {\tt O}=outward arrow,
+ {\tt N}=negated, {\tt E}=edge trigger}
+\macrodef{lg\_pintxt}{lg_pintxt}{}
+ {log}
+ {reduced-size text for logic pins}
+\macrodef{lg\_plen}{lg_plen}{}
+ {log}
+ {logic pin length in in {\tt L\_unit}s}
+\macrodef{LH\_symbol}{LH_symbol}{([U|D|L|R|{\sl degrees}][I])}
+ {log}
+ {logic-gate hysteresis symbol; {\tt I=}inverted}
+\macrodef{lin\_ang}{lin_ang}{({\sl line-reference})}
+ {gen}
+ {the angle from {\tt .start} to {\tt .end} of a line or move}
+\macrodef{lin\_leng}{lin_leng}{({\sl line-reference})}
+ {gen}
+ {length of a line, equivalent to {\sl line-reference}{\tt .len}
+ with dpic}
+\macrodef{linethick\_}{linethick_}{({\sl number})}
+ {gen}
+ {set line thickness in points}
+\macrodef{ljust\_}{ljust_}{}
+ {gen}
+ {ljust with respect to current direction}
+\macrodef{llabel}{llabel}{({\sl label},{\sl label},{\sl label})}
+ {cct}
+ {triple label on left side of the element \seesect{Labels:}}
+\macrodef{loc\_}{loc_}{({\sl x}, {\sl y})}
+ {gen}
+ {location adjusted for current direction}
+\macrodef{log\_init}{log_init}{}
+ {log}
+ {initialize environment for logic diagrams
+ (customizable, reads {\tt liblog.m4})}
+\macrodef{log10E\_}{log10E_}{}
+ {gen}
+ {constant $\log_{10}(e)$}
+\macrodef{loge}{loge}{}
+ {gen}
+ {logarithm, base $e$}
+\macrodef{Loopover\_}{Loopover_}{(`{\sl variable}',{\sl actions},{\sl value1,
+ value2, $\ldots$})}
+ {gen}
+ {Repeat {\sl actions} with {\sl variable} set successively to
+ {\sl value1, value2, $\ldots$}, setting macro {\tt m4Lx} to 1, 2, $\ldots$}
+\macrodef{lp\_xy}{lp_xy}{}
+ {log}
+ {coordinates used by {\tt lg\_pin}}
+\macrodef{lpop}{lpop}{({\sl xcoord}, {\sl ycoord}, {\sl radius}, {\sl fill},
+ {\sl zero ht})}
+ {gen}
+ {for lollipop graphs: filled circle with stem to (xcoord,zeroht)}
+\macrodef{lswitch}{lswitch}{( \linespec, L|R, {\sl chars} )}
+ {cct}
+ {knife switch R=right orientation (default L=left);
+ {\sl chars}=[O{\tt|}C][D][K][A] O=opening arrow; C=closing arrow; D=dots;
+ K=closed switch; A=blade arrowhead \seesect{Twoterminal:}}
+\macrodef{lt\_}{lt_}{}
+ {gen}
+ {left with respect to current direction}
+\macrodef{LT\_symbol}{LT_symbol}{(U|D|L|R|{\sl degrees})}
+ {log}
+ {logic-gate triangle symbol}
+\macrodef{lthick}{lthick}{}
+ {gen}
+ {current line thickness in drawing units}
+\macrodef{m4\_arrow}{m4_arrow}{(\linespec,{\sl ht},{\sl wid})}
+ {gen}
+ {arrow with adjustable head, filled when possible}
+\macrodef{m4dupstr}{m4dupstr}{({\sl string},{\sl n},`{\sl name}')}
+ {gen}
+ {Defines {\sl name} as {\sl n} concatenated copies of {\sl string}.}
+\macrodef{m4lstring}{m4lstring}{({\sl arg1},{\sl arg2})}
+ {gen}
+ {expand {\sl arg1} if it begins
+ with {\tt sprintf} or {\tt "}, otherwise {\sl arg2}}
+\macrodef{m4xpand}{m4xpand}{({\sl arg})}
+ {gen}
+ {Evaluate the argument as a macro}
+\macrodef{m4xtract}{m4xtract}{(`{\sl string1}',{\sl string2})}
+ {gen}
+ {delete {\sl string2} from {\sl string1}, return 1 if present}
+\macrodef{manhattan}{manhattan}{}
+ {gen}
+ {sets direction cosines for left, right, up, down}
+\macrodef{Max}{Max}{({\sl arg, arg, $\ldots$})}
+ {gen}
+ {Max of an arbitrary number of inputs}
+\macrodef{memristor}{memristor}{({\sl linespec, wid, ht})}
+ {cct}
+ {memristor element\seesect{Twoterminal:}}
+\macrodef{microphone}{microphone}{( U|D|L|R|{\sl degrees, size})}
+ {cct}
+ {microphone, {\sl In1} to {\sl In3} defined
+ \seesect{Composite:}}
+\macrodef{Min}{Min}{({\sl arg, arg, $\ldots$})}
+ {gen}
+ {Min of an arbitrary number of inputs}
+\macrodef{Mitre\_}{Mitre_}{%
+ ({\sl Line1,Line2,length,line attributes})}
+ {gen}
+ {e.g., {\tt Mitre\_(L,M)} draws angle at intersection of lines
+ L and M with legs of length arg3 (default {\tt linethick bp\_\_/2});
+ sets {\tt Here} to intersection
+ \seesect{Corners:}}
+\macrodef{mitre\_}{mitre_}{%
+ ({\sl Position1,Position2,Position3,length,line attributes})}
+ {gen}
+ {e.g., {\tt mitre\_(A,B,C)} draws angle ABC with legs
+ of length arg4 (default {\tt linethick bp\_\_/2});
+ sets {\tt Here} to Position2
+ \seesect{Corners:}}
+\macrodef{mm\_\_}{mm__}{}
+ {gen}
+ {absolute millimetres}
+\macrodef{mosfet}{mosfet}{(\linespec,L|R,{\sl chars},E)}
+ {cct}
+ {MOSFET left or right, included components defined by characters, envelope.
+ arg 3 chars:
+ {\tt [u][d]B:} center bulk connection pin;
+ {\tt D:} D pin and lead;
+ {\tt E:} dashed substrate;
+ {\tt F:} solid-line substrate;
+ {\tt [u][d]G:} G pin to substrate at source;
+ {\tt [u][d]H:} G pin to substrate at center;
+ {\tt L:} G pin to channel (obsolete);
+ {\tt [u][d]M:} G pin to channel; u: at drain end; d: at source end
+ {\tt [u][d]M{\sl n}:} multiple gates G0 to G{\sl n}
+ {\tt Pz:} parallel zener diode;
+ {\tt Q:} connect B pin to S pin;
+ {\tt R:} thick channel;
+ {\tt [u][d]S:} S pin and lead u: arrow up; d: arrow down;
+ {\tt [d]T:} G pin to center of channel d: not circle;
+ {\tt X:} XMOSFET terminal;
+ {\tt Z:} simplified complementary MOS
+ \seesect{Semiconductors:}}
+\macrodef{Mux\_ht}{Mux_ht}{}
+ {cct}
+ {Mux height parameter in {\tt L\_unit}s}
+\macrodef{Mux\_wid}{Mux_wid}{}
+ {cct}
+ {Mux width parameter in {\tt L\_unit}s}
+\macrodef{Mux}{Mux}{({\sl n},{\sl label},
+ {\tt [L][B|H|X][N[{\sl n}]|S[{\sl n}]][[N]OE],
+ {\sl wid},{\sl ht}})}
+ {log}
+ {binary multiplexer, $n$ inputs,
+ {\tt L} reverses input pin numbers,
+ {\tt B} display binary pin numbers,
+ {\tt H} display hexadecimal pin numbers,
+ {\tt X} do not print pin numbers,
+ {\tt N[{\sl n}]} puts Sel or Sel$0$ .. Sel$n$ at the top
+ (i.e., to the left of the drawing direction),
+ {\tt S[{\sl n}]} puts the Sel inputs at the bottom (default)
+ {\tt OE} ({\tt N=}negated) {\tt OE} pin
+ \seesect{Logicgates:}}
+\macrodef{Mx\_pins}{Mx_pins}{}
+ {log}
+ {max number of gate inputs without wings}
+\macrodef{n\_}{n_}{}
+ {gen}
+ {.n with respect to current direction}
+\macrodef{N\_diam}{N_diam}{}
+ {log}
+ {diameter of `not' circles in {\tt L\_unit}s}
+\macrodef{N\_rad}{N_rad}{}
+ {log}
+ {radius of `not' circles in {\tt L\_unit}s}
+\macrodef{NAND\_gate}{NAND_gate}{({\sl n},N)}
+ {log}
+ {`nand' gate, 2 or {\sl n\/} inputs; N=negated input.
+ Otherwise, arg1 can be a sequence of letters {\tt P|N}
+ to define normal or negated inputs.
+ \seesect{Logicgates:}}
+\macrodef{ne\_}{ne_}{}
+ {gen}
+ {.ne with respect to current direction}
+\macrodef{NeedDpicTools}{NeedDpicTools}{}
+ {gen}
+ {executes {\tt copy "HOMELIB\_/dpictools.pic"} if the file has not been read}
+\macrodef{neg\_}{neg_}{}
+ {gen}
+ {unary negation}
+\macrodef{NOR\_gate}{NOR_gate}{({\sl n},N)}
+ {log}
+ {`nor' gate, 2 or {\sl n\/} inputs; N=negated input.
+ Otherwise, arg1 can be a sequence of letters {\tt P|N}
+ to define normal or negated inputs.
+ \seesect{Logicgates:}}
+\macrodef{norator}{norator}{(\linespec,{\sl width},{\sl ht})}
+ {cct}
+ { norator two-terminal element \seesect{Twoterminal:}}
+\macrodef{NOT\_circle}{NOT_circle}{}
+ {log}
+ {`not' circle}
+\macrodef{NOT\_gate}{NOT_gate}{(\linespec,[B][N|n],{\sl wid},{\sl height})}
+ {log}
+ {`not' gate.
+ When {\sl linespec} is blank then the element is composite and In1,
+ Out, C, NE, and SE are defined; otherwise the element is drawn as
+ a two-terminal element. arg2: {\tt B}=box gate, {\tt N}=not circle at input
+ and output, {\tt n}=not circle at input only
+ \seesect{Logicgates:}}
+\macrodef{NOT\_rad}{NOT_rad}{}
+ {log}
+ {`not' radius in absolute units}
+\macrodef{NPDT}{NPDT}{({\sl npoles,}[R])}
+ {cct}
+ {Double-throw switch; {\sl npoles:} number of poles;
+ {\tt R}= right orientation with respect to drawing direction
+ \seesect{Composite:}}
+\macrodef{nport}{nport}{({\sl box spec{\tt ;}other commands,
+nw,nn,ne,ns,space ratio,pin lgth,style, other commands})}
+ {cct}
+ { Default is a standard-box twoport. Args 2 to 5 are
+ the number of ports to be drawn on w, n, e, s sides.
+ The port pins are named by side, number, and by a or b pin,
+ e.g., W1a, W1b, W2a, $\ldots$
+ Arg 6 specifies the ratio of port width to interport space (default 2),
+ and arg 7 is the pin length. Set arg 8 to N to omit the dots on
+ the port pins. Arguments 1 and 9 allow customizations
+ \seesect{Composite:}}
+\macrodef{nterm}{nterm}{({\sl box spec{\tt ;}other commands,
+nw,nn,ne,ns,pin lgth,style, other commands})}
+ {cct}
+ {n-terminal box macro (default three pins).
+ Args 2 to 5 are the number of pins to be drawn on W, N, E, S sides.
+ The pins are named by side and number, e.g. W1, W2, N1, $\ldots$
+ Arg 6 is the pin length. Set arg 7 to N to omit the dots
+ on the pins. Arguments 1 and 8 allow customizations, e.g.
+ {\tt nterm(,{,},{,},{,}N,"\$a\$" at Box.w ljust,"\$b\$" at Box.e rjust,
+ "\$c\$" at Box.s above)} }
+\macrodef{nullator}{nullator}{(\linespec,{\sl width},{\sl ht})}
+ {cct}
+ { nullator two-terminal element \seesect{Twoterminal:}}
+\macrodef{nw\_}{nw_}{}
+ {gen}
+ {.nw with respect to current direction}
+\macrodef{NXOR\_gate}{NXOR_gate}{({\sl n},N)}
+ {log}
+ {`nxor' gate, 2 or {\sl n\/} inputs; N=negated input.
+ Otherwise, arg1 can be a sequence of letters {\tt P|N}
+ to define normal or negated inputs.
+ \seesect{Logicgates:}}
+\macrodef{opamp}{opamp}{(\linespec,{\sl label},{\sl label},{\sl size},{\sl
+ chars}, other commands)}
+ {cct}
+ {operational amplifier with $-,$ $+$ or other internal labels,
+ specified size. {\sl chars:} {\tt P=} add power connections,
+ {\tt R=} swap In1, In2 labels,
+ {\tt T=} truncated point.
+ The first and last arguments allow added customizations
+ \seesect{Composite:}}
+\macrodef{open\_arrow}{open_arrow}{(\linespec,{\sl ht},{\sl wid})}
+ {gen}
+ {arrow with adjustable open head}
+\macrodef{OR\_gate}{OR_gate}{({\sl n},N)}
+ {log}
+ {`or' gate, 2 or {\sl n\/} inputs; N=negated input.
+ Otherwise, arg1 can be a sequence of letters {\tt P|N}
+ to define normal or negated inputs.
+ \seesect{Logicgates:}}
+\macrodef{OR\_gen}{OR_gen}{($n$,{\sl chars},[{\sl wid},[{\sl ht}]])}
+ {log}
+ {general OR gate: $n$=number of inputs $(0\leq n\leq 16)$;
+ {\sl chars:} B=base and straight sides; A=Arcs;
+ [N]NE,[N]SE,[N]I,[N]N,[N]S=inputs or circles;
+ [N]P=XOR arc; [N]O=output; C=center.
+ Otherwise, arg1 can be a sequence of letters {\tt P|N}
+ to define normal or negated inputs.}
+\macrodef{OR\_rad}{OR_rad}{}
+ {log}
+ {radius of OR input face in {\tt L\_unit}s}
+\macrodef{parallel\_}{parallel_}{(\char96{\sl elementspec}\char39,%
+ \char96{\sl elementspec}\char39 $\ldots$)}
+ {cct}
+ { Parallel combination of two-terminal elements in a {\tt [ ]} block.
+ Each argument is a {\em quoted} elementspec of the form
+ {\tt[Sep={\sl val};][{\sl Label}:] {\sl element}; [{\sl attributes}]}
+ where an {\sl attribute} is of the form
+ {\tt[llabel($\ldots$);] | [rlabel($\ldots$);] | [b\_current($\ldots$);]}.
+ An argument may also be {\tt series\_($\ldots$)} or
+ {\tt parallel\_($\ldots$)} {\em without} attributes or quotes.
+ Sep={\sl val}; in the first branch sets the default
+ separation of all branches to {\sl val}; in a later
+ element Sep={\sl val}; applies only to that branch.
+ An element may have normal arguments but should
+ not change the drawing direction.
+ \seesect{Seriesandparallel:}}
+%\macrodef{par\_}{par_}{({\sl element},{\sl element},{\sl separation})}
+% {cct}
+% {two same-direction, same-length elements in parallel}
+\macrodef{pc\_\_}{pc__}{}
+ {gen}
+ {absolute points}
+\macrodef{px\_\_}{px__}{}
+ {gen}
+ {absolute SVG screen pixels}
+\macrodef{pconnex}{pconnex}{(R|L|U|D|{\sl degrees},{\sl chars})}
+ {cct}
+ {power connectors, arg 1: drawing direction; {\sl chars:}
+ {\tt R}=right orientation,
+ {\tt M|F}= male, female,
+ {\tt A|AC}=115V, 3 prong, B=box, C=circle,
+ {\tt P}= PC connector,
+ {\tt D}= 2-pin connector,
+ {\tt G|GC}= GB 3-pin,
+ {\tt J}= 110V 2-pin
+ \seesect{Composite:}}
+\macrodef{pi\_}{pi_}{}
+ {gen}
+ {$\pi$}
+\macrodef{plug}{plug}{(U|D|L|R|{\sl degrees},[2|3][R])}
+ {cct}
+ {arg1: drawing direction; string arg2: {\tt R} right orientation,
+ {\tt 2|3} number of conductors
+ \seesect{Composite:}}
+\macrodef{pmod}{pmod}{({\sl integer}, {\sl integer})}
+ {gen}
+ {+ve $\hbox{mod}(M,N)$ e.g., $\hbox{\tt pmod}(-3,5)=2$}
+\macrodef{point\_}{point_}{({\sl angle})}
+ {gen}
+ {(radians) set direction cosines}
+\macrodef{Point\_}{Point_}{({\sl integer})}
+ {gen}
+ {sets direction cosines in degrees \seesect{Placing:}}
+\macrodef{polar\_}{polar_}{({\sl x},{\sl y})}
+ {gen}
+ {rectangular-to polar conversion}
+\macrodef{potentiometer}{potentiometer}{(\linespec,%
+ {\sl cycles},{\sl fractional pos},{\sl length},$\cdots$)}
+ {cct}
+ {resistor with taps T1, T2, $\ldots$
+ with specified fractional positions and lengths (possibly neg)
+ \seesect{Composite:}}
+\macrodef{print3D}{print3D}{(x,y,z)}
+ {3D}
+ {write out triple for debugging}
+\macrodef{prod\_}{prod_}{({\sl a},{\sl b})}
+ {gen}
+ {binary multiplication}
+\macrodef{project}{project}{({\sl x},({\sl y},({\sl z})}
+ {3D}
+ {3D to 2D projection onto the plane perpendicular to the view vector with
+ angles defined by {\tt setview({\sl azim, elev})}}
+\macrodef{psset\_}{psset_}{({\sl PSTricks settings})}
+ {gen}
+ {set PSTricks parameters}
+\macrodef{pt\_\_}{pt__}{}
+ {gen}
+ {\TeX\ point-size factor, in scaled inches, ({\tt *scale/72.27})}
+\macrodef{ptrans}{ptrans}{(\linespec, [R|L])}
+ {cct}
+ {pass transistor; {\tt L=} left orientation
+ \seesect{Semiconductors:}}
+\macrodef{r\_}{r_}{}
+ {gen}
+ {red color value}
+\macrodef{rarrow}{rarrow}{({\sl label,{\tt ->|<-},{\sl dist}})}
+ {cct}
+ {arrow {\sl dist} to right of last-drawn 2-terminal element
+ \seesect{Branchcurrent:}}
+\macrodef{Rect\_}{Rect_}{({\sl radius},{\sl angle})}
+ {gen}
+ {(deg) polar-to-rectangular conversion}
+\macrodef{rect\_}{rect_}{({\sl radius},{\sl angle})}
+ {gen}
+ {(radians) polar-rectangular conversion}
+\macrodef{reed}{reed}{({\sl linespec, width, height, box attribues}, [R][C])}
+ {cct}
+ {Enclosed reed two-terminal contact;
+ {\tt R}=right orientation; {\tt C}=closed contact;
+ e.g., {\tt reed(,,dimen\_/5,shaded "lightgreen"}
+ \seesect{Composite:}}
+ {cct}
+ {relay: n poles (default 1), {\sl chars:} {\tt O}=normally open,
+ {\tt C}=normally closed, {\tt P}=three position, default double throw,
+ {\tt L}=drawn left (default),
+ {\tt R}=drawn right, {\tt T}=thermal.
+ Argument 3={\tt [L|R]} is deprecated but works for
+ backward compatibility
+ \seesect{Composite:}}
+\macrodef{resetdir\_)}{resetdir_)}{}
+ {gen}
+ {resets direction set by {\tt setdir\_}}
+\macrodef{resetrgb}{resetrgb}{}
+ {gen}
+ {cancel {\tt r\_, g\_, b\_} color definitions}
+\macrodef{resistor}{resistor}{(\linespec,n|E,{\sl chars}, {\sl
+ cycle wid})}
+ {cct}
+ {resistor, n cycles (default 3), {\sl chars:}
+ {\tt E}={\tt ebox},
+ {\tt ES}={\tt ebox} with slash,
+ {\tt Q}=offset,
+ {\tt H}=squared,
+ {\tt N}=IEEE,
+ {\tt V}=varistor variant,
+ {\tt R}=right-oriented,
+ {\sl cycle width} (default {\tt dimen\_}$/6$) \seesect{Twoterminal:}}
+\macrodef{resized}{resized}{({\sl factor},`{\sl macro name}',args)}
+ {cct}
+ {scale the element body size by {\sl factor}}
+\macrodef{restorem4dir}{restorem4dir}{([`{\sl stack name}'])}
+ {gen}
+ {Restore m4 direction parameters from the named stack;
+ default {\tt `savm4dir\_'}}
+\macrodef{reversed}{reversed}{(`{\sl macro name}',args)}
+ {cct}
+ {reverse polarity of 2-terminal element}
+\macrodef{rgbdraw}{rgbdraw}{({\sl color triple}, {\sl drawing commands})}
+ {gen}
+ {color drawing for PSTricks, pgf, MetaPost, svg postprocessors;
+ (color entries are 0 to 1 except for SVG entries which are 0 to 255),
+ see {\tt setrgb} \seesect{Semiconductors:}}
+\macrodef{rgbfill}{rgbfill}{({\sl color triple}, {\sl closed path})}
+ {gen}
+ {fill with arbitrary color (color entries are 0 to 1 except
+ SVG entries which are 0 to 255); see {\tt setrgb}\seesect{Semiconductors:}}
+\macrodef{rgbstring}{rgbstring}{({\sl color triple or color name})}
+ {gen}
+ {evaluates to a string compatible with the postprocessor in use
+ to go with {\tt colored}, {\tt shaded}, or {\tt outlined} attributes.
+ (PSTricks, metapost, pgf-tikz, pdf, postscript, svg).
+ The arguments are fractions
+ in the range $[0,1]$; For example,
+ {\tt box outlined rgbstring(0.1,0.2,0.7) shaded rgbstring(0.75,0.5,0.25)}.
+ For those postprocessors that allow it,
+ there can be one argument which is the name of a defined color}
+\macrodef{right\_}{right_}{}
+ {gen}
+ {set current direction right \seesect{Placing:}}
+\macrodef{rjust\_}{rjust_}{}
+ {gen}
+ {right justify with respect to current direction}
+\macrodef{rlabel}{rlabel}{({\sl label},{\sl label},{\sl label})}
+ {cct}
+ {triple label on right side of the element \seesect{Labels:}}
+\macrodef{rot3Dx}{rot3Dx}{({\sl radians,x,y,z})}
+ {3D}
+ {rotates x,y,z about x axis}
+\macrodef{rot3Dy}{rot3Dy}{({\sl radians,x,y,z})}
+ {3D}
+ {rotates x,y,z about y axis}
+\macrodef{rot3Dz}{rot3Dz}{({\sl radians,x,y,z})}
+ {3D}
+ {rotates x,y,z about z axis}
+\macrodef{rotbox}{rotbox}{({\sl wid,ht,type},[r|t={\sl val}])}
+ {gen}
+ {box oriented in current direction in {\tt [ ]} block;
+ {\sl type}= e.g. {\tt dotted shaded "green".} Defined
+ internal locations: N, E, S, W (and NE, SE, NW, SW if arg4 is blank).
+ If arg4 is {\tt r=}{\sl val} then corners have radius {\sl val}.
+ If arg4 is {\tt t=}{\sl val} then a spline with tension {\sl val}
+ is used to draw a ``superellipse,'' and the bounding box is then
+ only approximate. }
+\macrodef{rotellipse}{rotellipse}{({\sl wid,ht,type})}
+ {gen}
+ {ellipse oriented in current direction in {\tt [ ]} block;
+ e.g. {\tt Point\_(45); rotellipse(,{},dotted fill\_(0.9)).} Defined internal
+ locations: N, S, E, W.}
+\macrodef{round}{round}{(at {\sl location,line thickness,attributes})}
+ {gen}
+ {filled circle for rounded corners; attributes={\tt colored "gray"}
+ for example; leaves {\tt Here} unchanged if arg1 is blank
+ \seesect{Corners:}}
+\macrodef{rpoint\_}{rpoint_}{(\linespec)}
+ {gen}
+ {set direction cosines}
+\macrodef{rpos\_}{rpos_}{({\sl position})}
+ {gen}
+ {Here + {\sl position}}
+\macrodef{rrot\_}{rrot_}{({\sl x, y, angle})}
+ {gen}
+ {\tt Here + vrot\_({\sl x, y, cos(angle), sin(angle))}}
+\macrodef{rs\_box}{rs_box}{({\sl text},{\sl expr1},$\cdots$)}
+ {gen}
+ {like {\tt s\_box} but the text is rotated by {\tt text\_ang}
+ (default 90) degrees \seesect{Interaction:}, \seesect{Pstricks:}}
+\macrodef{rsvec\_}{rsvec_}{({\sl position})}
+ {gen}
+ {Here + {\sl position}}
+\macrodef{rt\_}{rt_}{}
+ {gen}
+ {right with respect to current direction}
+\macrodef{rtod\_\_}{rtod__}{}
+ {gen}
+ {constant, degrees/radian}
+\macrodef{rtod\_}{rtod_}{}
+ {gen}
+ {constant, degrees/radian}
+\macrodef{rvec\_}{rvec_}{({\sl x},{\sl y})}
+ {gen}
+ {location relative to current direction}
+\macrodef{s\_}{s_}{}
+ {gen}
+ {.s with respect to current direction}
+\macrodef{s\_box}{s_box}{({\sl text},{\sl expr1},$\cdots$)}
+ {gen}
+ {generate dimensioned text string using {\tt\char92{}boxdims} from
+ {\tt boxdims.sty}. Two or more args are passed to {\tt sprintf()}
+ (default 90) degrees \seesect{Interaction:}}
+\macrodef{s\_dp}{s_dp}{({\sl name},{\sl default})}
+ {gen}
+ {depth of the most recent (or named) {\tt s\_box}
+ \seesect{Interaction:}}
+\macrodef{s\_ht}{s_ht}{({\sl name},{\sl default})}
+ {gen}
+ {height of the most recent (or named) {\tt s\_box}
+ \seesect{Interaction:}}
+\macrodef{s\_init}{s_init}{({\sl name})}
+ {gen}
+ {initialize {\tt s\_box} string label to {\sl name} which should be unique
+ \seesect{Interaction:}}
+\macrodef{s\_name}{s_name}{}
+ {gen}
+ {the value of the last {\tt s\_init} argument
+ \seesect{Interaction:}}
+\macrodef{s\_wd}{s_wd}{({\sl name},{\sl default})}
+ {gen}
+ {width of the most recent (or named) {\tt s\_box}
+ \seesect{Interaction:}}
+\macrodef{savem4dir}{savem4dir}{([`{\sl stack name}'])}
+ {gen}
+ {Stack m4 direction parameters in the named stack
+ (default {\tt `savm4dir\_'})}
+\macrodef{sbs}{sbs}{({\sl linespec, chars, label})}
+ {cct}
+ {Wrapper to place an SBS thyristor as a two-terminal element with
+ {\tt [ ]} block label given by the third argument
+ \seesect{Semiconductors:}}
+\macrodef{sc\_draw}{sc_draw}{({\sl dna string, chars, iftrue, iffalse})}
+ {cct}
+ {test if chars are in string, deleting chars from string}
+\macrodef{scr}{scr}{({\sl linespec, chars, label})}
+ {cct}
+ {Wrapper to place an SCR thyristor as a two-terminal element with
+ {\tt [ ]} block label given by the third argument
+ \seesect{Semiconductors:}}
+\macrodef{scs}{scs}{({\sl linespec, chars, label})}
+ {cct}
+ {Wrapper to place an SCS thyristor as a two-terminal element with
+ {\tt [ ]} block label given by the third argument
+ \seesect{Semiconductors:}}
+\macrodef{se\_}{se_}{}
+ {gen}
+ {.se with respect to current direction}
+\macrodef{series\_}{series_}{({\sl elementspec}, {\sl elementspec}, $\ldots$)}
+ {cct}
+ { Series combination in a {\tt []} block of elements
+ with shortened default length. An {\sl elementspec} is of the form
+ {\tt [{\sl Label}:] {\sl element}; [{\sl attributes}]},
+ where an {\sl attribute} is of the form
+ {\tt [llabel($\ldots$);] | [rlabel($\ldots$);] [b\_current($\ldots$);]}.
+ Internal points {\tt Start}, {\tt End}, and {\tt C} are defined
+ \seesect{Seriesandparallel:} }
+\macrodef{setdir\_}{setdir_}{(R|L|U|D|{\sl degrees}, {\sl default} U|D|R|L|{\sl degrees})}
+ {gen}
+ {store drawing direction and set it to
+ up, down, left, right, or angle in degrees (reset by {\tt resetdir\_}).
+ The directions may be spelled out, i.e., Right, Left, $\ldots$
+ \seesect{Seriesandparallel:}}
+\macrodef{setrgb}{setrgb}{({\sl red value, green value, blue value},[{\sl
+ name}])}
+ {gen}
+ {define colour for lines and text, optionally named (default {\tt lcspec});
+ svg values are integers from 0 to 255\seesect{Semiconductors:}}
+\macrodef{setview}{setview}{({\sl azimuth degrees},{\sl elevation degrees})}
+ {3D}
+ {set projection viewpoint}
+\macrodef{sfg\_init}{sfg_init}{({\sl default line len, node rad, arrowhd len,
+ arrowhd wid}), (reads {\tt libcct.m4})}
+ {cct}
+ {initialization of signal flow graph macros}
+\macrodef{sfgabove}{sfgabove}{}
+ {cct}
+ {like above but with extra space}
+\macrodef{sfgarc}{sfgarc}{(\linespec,{\sl text},{\sl text justification},cw|ccw,
+ {\sl height scale factor})}
+ {cct}
+ {directed arc drawn between nodes, with text label
+ and a height-adjustment parameter }
+\macrodef{sfgbelow}{sfgbelow}{}
+ {cct}
+ {like below but with extra space}
+\macrodef{sfgline}{sfgline}{(\linespec,{\sl text},{\sl text justification})}
+ {cct}
+ {directed straight line chopped by node radius, with text label}
+\macrodef{sfgnode}{sfgnode}{(at {\sl location},{\sl text},above|below,{\sl
+ circle options})}
+ {cct}
+ {small circle default white interior, with text label. The default label
+ position is inside if the diameter is bigger than {\tt textht} and
+ {\tt textwid}; otherwise it is {\tt sfgabove.} Options such as fill or
+ line thickness can be given.}
+\macrodef{sfgself}{sfgself}{(at {\sl location}, U|D|L|R|{\sl degrees},
+ {\sl text}, {\sl text justification}, cw|ccw, {\sl scale factor})}
+ {cct}
+ {self-loop drawn at angle {\sl angle} from a node,
+ with text label and a size-adjustment parameter }
+\macrodef{shade}{shade}{({\sl gray value},{\sl closed line specs})}
+ {gen}
+ {fill arbitrary closed curve}
+\macrodef{shadebox}{shadebox}{({\sl box specification})}
+ {gen}
+ {box with edge shading}
+\macrodef{ShadedPolygon}{ShadedPolygon}{({\sl vertexseq, line attributes,
+ degrees, colorseq})}
+ {gen}
+ {Draws the polygon specified in arg1 and shades the interior according
+ to arg4 by drawing lines perpendicular to the angle in arg3.
+ The {\sl vertexseq} is a colon ({\tt:}) separated sequence of vertex
+ positions (or names) of the polygon in cw or ccw order. A {\sl colorseq}
+ is of the form 0, r0,g0,b0, {\sl frac1},r1,g1,b1, {\sl frac2},r2,g2,b2,
+ \ldots 1,rn,gn,bn with $0 < \hbox{\sl frac1} < \hbox{\sl frac2} \ldots 1$
+}
+\macrodef{SIdefaults}{SIdefaults}{}
+ {gen}
+ {Sets {\tt scale = 25.4} for drawing units in mm, and sets
+ pic parameters {\tt lineht = 12, linewid = 12, moveht = 12, movewid = 12,
+ arcrad = 6, circlerad = 6, boxht = 12, boxwid = 18, ellipseht = 12,
+ ellipsewid = 18, dashwid = 2, arrowht = 3, arrowwid = arrowht/2,}}
+\macrodef{sign\_}{sign_}{({\sl number})}
+ {gen}
+ {sign function}
+\macrodef{Sin}{Sin}{({\sl integer})}
+ {gen}
+ {sine function, {\sl integer\/} degrees}
+\macrodef{sinc}{sinc}{({\sl number})}
+ {gen}
+ {the $\hbox{sinc}(x)$ function}
+\macrodef{sind}{sind}{({\sl arg})}
+ {gen}
+ {sine of an expression in degrees}
+\macrodef{sinusoid}{sinusoid}{({\sl amplitude, frequency, phase, tmin, tmax,
+ linetype})}
+ {gen}
+ {draws a sinusoid over the interval
+ $(t_{\hbox{\scriptsize min}}, t_{\hbox{\scriptsize max}})$;
+ e.g., to draw a dashed sine curve, amplitude {\sl a}, of {\sl n} cycles
+ of length {\sl x} from {\sl A},
+ {\tt sinusoid(a,twopi\_*n/x,-pi\_/2,0,x,dashed) with .Start at A}}
+\macrodef{source}{source}{(\linespec,V|v|I|i|AC|B|F|G|H|Q|L|N|P|S|T|X|U|{\sl
+ other},{\sl diameter},R)}
+ {cct}
+ {source, blank or voltage (2 types), current (2 types), AC,
+ or type F, G, Q, B, L, N, X or labelled,
+ H = step (Heaviside),
+ P = pulse, U = square, R = ramp,
+ S = sinusoid, T = triangle; other = custom interior label or waveform,
+ R = reversed polarity \seesect{Twoterminal:}}
+\macrodef{sourcerad\_}{sourcerad_}{}
+ {cct}
+ {default source radius}
+\macrodef{sp\_}{sp_}{}
+ {gen}
+ {evaluates to medium space for gpic strings}
+\macrodef{speaker}{speaker}{( U|D|L|R|{\sl degrees},{\sl size},H)}
+ {cct}
+ {speaker, {\sl In1} to {\sl In7} defined; {\tt H}=horn
+ \seesect{Composite:}}
+\macrodef{sprod3D}{sprod3D}{(a,x,y,z)}
+ {3D}
+ {scalar product of triple x,y,z by a}
+\macrodef{sqrta}{sqrta}{({\sl arg})}
+ {gen}
+ {square root of the absolute value of {\sl arg}; i.e.,
+ {\tt sqrt(abs({\sl arg}))}}
+\macrodef{SQUID}{SQUID}{({\sl n, diameter, initial angle}, {\tt ccw|cw})}
+ {cct}
+ {Superconducting quantum interface device
+ with {\sl }n junctions labeled {\tt J1, ... J}{\sl n}
+ placed around a circle with initial
+ angle -90 deg (by default) with respect
+ to the current drawing direction. The
+ default diameter is {\tt dimen\_} }
+\macrodef{stackargs\_}{stackargs}{(`{\sl stackname}',{\sl args})}
+ {gen}
+ {Stack arg 2, arg 3, ... onto the named stack up to a blank arg}
+\macrodef{stackcopy\_}{stackcopy_}{(`{\sl name 1}',`{\sl name 2}')}
+ {gen}
+ {Copy stack 1 into stack 2, preserving the order of pushed elements}
+\macrodef{stackdo\_}{stackdo}{(`{\sl stackname}',{\sl commands})}
+ {gen}
+ {Empty the stack to the first blank entry, performing arg 2}
+\macrodef{stackexec\_}{stackexec_}{(`{\sl name 1}',`{\sl name 2}',%
+ {\sl commands})}
+ {gen}
+ {Copy stack 1 into stack 2, performing arg3 for each nonblank entry}
+\macrodef{stackprint\_}{stackprint_}{(`{\sl stack name}')}
+ {gen}
+ {Print the contents of the stack to the terminal}
+%\macrodef{stackpromote\_}{stackpromote_}{({\sl prefix},%
+% `{\sl stack name}',{\sl In name})}
+% {gen}
+% {Define locations {\tt In1} or {\sl In name }{\tt 1}, $\ldots$ corresponding
+% to the locations in stack {\sl stack name}, as created by the
+% {\tt AutoGate} and {\tt Autologic} macros. Each location is prefixed
+% by argument 1 ``.''}
+\macrodef{stackreverse\_}{stackreverse_}{(`{\sl stack name}')}
+ {gen}
+ {Reverse the order of elements in a stack, preserving the name}
+\macrodef{stacksplit\_}{stacksplit_}{(`{\sl stack name}',{\sl string},{\sl
+ separator})}
+ {gen}
+ {Stack the fields of {\sl string} left to right separated by nonblank
+ {\sl separator} (default .). White space preceding the fields is ignored.}
+\macrodef{sum\_}{sum_}{({\sl a},{\sl b})}
+ {gen}
+ {binary sum}
+\macrodef{sum3D}{sum3D}{({\sl x1,y1,z1,x2,y2,z2})}
+ {3D}
+ {sum of two triples}
+\macrodef{sus}{sus}{({\sl linespec, chars, label})}
+ {cct}
+ {Wrapper to place an SUS thyristor as a two-terminal element with
+ {\tt [ ]} block label given by the third argument
+ \seesect{Semiconductors:}}
+\macrodef{svec\_}{svec_}{({\sl x},{\sl y})}
+ {log}
+ {scaled and rotated grid coordinate vector}
+\macrodef{sw\_}{sw_}{}
+ {gen}
+ {.sw with respect to current direction}
+\macrodef{switch}{switch}{(\linespec,L|R,[C|O][D],[B|D])}
+ {cct}
+ {SPST switch (wrapper for bswitch, lswitch, and dswitch),
+ arg2: R=right orientation (default L=left);
+ if arg4=blank (knife switch): arg3 = [O{\tt|}C][D][A]
+ O= opening, C=closing, D=dots, A=blade arrowhead;
+ if arg4=B (button switch): arg3 = O{\tt|}C
+ O=normally open, C=normally closed,
+ if arg4=D: arg3 = same as for dswitch \seesect{Twoterminal:}}
+\macrodef{ta\_xy}{ta_xy}{({\sl x, y})}
+ {cct}
+ {macro-internal coordinates adjusted for {\tt L|R}}
+\macrodef{tapped}{tapped}{(`{\sl two-terminal element}',
+ [{\sl arrowhd} | type={\sl arrowhd};name={\sl Name}],
+ {\sl fraction, length, fraction, length,} $\cdots$)}
+ {cct}
+ {Draw the two-terminal element with taps in a [ ] block (see {\tt addtaps}).
+ {\sl arrowhd} = blank or one of {\tt . - <- -> <->}.
+ Each fraction determines the position along the element body of the tap.
+ A negative length draws the tap to the right of the current
+ direction; positive length to the left.
+ Tap names are Tap1, Tap2, $\cdots$ by default or
+ Name1, Name2, $\cdots$ if specified.
+ Internal block names are {\tt .Start, .End,} and {.C} corresponding to the
+ drawn element, and the tap names
+ \seesect{Composite:} }
+\macrodef{tbox}{tbox}{({\sl text,wid,ht},<|>|<>,{\sl type})}
+ {cct}
+ {Pointed terminal box. The {\sl text} is placed at the rectangular center
+ in math mode unless the text begins with {\tt "} or {\tt sprintf} in which
+ case the arument is used literally. Arg 4 determines whether the point is
+ forward, backward, or both with respect to the current drawing direction.
+ \seesect{Composite:}}
+\macrodef{tconn}{tconn}{({\sl linespec,}>|>>|<|<<|O[F],{\sl wid})}
+ {cct}
+ {Terminal connector, {\tt O}=circle; {\tt OF}=filled circle;
+ {\tt > or >>} output connector
+ (default {\tt >}) ;
+ {\tt < or << input connector}; arg3 is arrowhead width or circle diameter
+ \seesect{Composite:}}
+\macrodef{tgate}{tgate}{({\sl linespec,} [B][R|L])}
+ {cct}
+ {transmission gate, {\tt B=} ebox type; {\tt L=} oriented left
+ \seesect{Semiconductors:}}
+\macrodef{thermocouple}{thermocouple}{({\sl linespec, wid, ht,} L|R)}
+ {cct}
+ { Thermocouple drawn to the left (by default) of the {\sl linespec}
+ line. If the {\sl linespec} length equals {\sl wid}
+ (default {\tt dimen\_/5}), then only the two branches appear.
+ {\tt R=} right orientation.
+ \seesect{Twoterminal:}}
+\macrodef{thicklines\_}{thicklines_}{({\sl number})}
+ {gen}
+ {set line thickness in points}
+\macrodef{thinlines\_}{thinlines_}{({\sl number})}
+ {gen}
+ {set line thickness in points}
+\macrodef{threeD\_init}{threeD_init}{}
+ {3D}
+ {initialize 3D transformations (reads {\tt lib3D.m4})}
+\macrodef{thyristor}{thyristor}{(\linespec,%
+ {\tt [SCR|SCS|SUS|SBS|IEC][{\sl chars}]})}
+ {cct}
+ {Composite thyristor element in {\tt []}block:
+ types
+ SCR: silicon controlled rectifier (default),
+ SCS: silicon controlled switch,
+ SUS: silicon unilateral switch,
+ SBS: silicon bilateral switch,
+ IEC: type IEC.
+ {\sl Chars} to modify or define the element:
+ K: open arrowheads,
+ A: arrowhead,
+ F: half arrowhead,
+ B: bidirectional diode,
+ E: adds envelope,
+ H: perpendicular gate (endpoint G),
+ N: anode gate (endpoint Ga),
+ U: centre line in diodes
+ V: perpendicular gate across arrowhead centre,
+ R=right orientation,
+ E=envelope
+ \seesect{Semiconductors:}}
+\macrodef{tikznode}{tikznode}{({\sl \Tikz node name, position}) }
+ {pgf}
+ {insert \Tikz code to define a zero-size \Tikz node at {\sl location}
+ (default {\tt Here}) to assist with inclusion of \pic code output in
+ \Tikz diagrams. This macro must be invoked in the outermost \pic scope.
+ \seesect{Tikzwithpic:}}
+\macrodef{tline}{tline}{(\linespec,{\sl wid},{\sl ht}) }
+ {cct}
+ {transmission line, manhattan direction\seesect{Twoterminal:}}
+\macrodef{tr\_xy\_init}{tr_xy_init}{({\sl origin, unit size, sign })}
+ {cct}
+ {initialize {\tt tr\_xy}}
+\macrodef{tr\_xy}{tr_xy}{({\sl x, y})}
+ {cct}
+ {relative macro internal coordinates adjusted for {\tt L|R}}
+\macrodef{transformer}{transformer}{(\linespec,L|R,{\sl np},%
+[A|P][W|L][D1|D2|D12|D21],{\sl ns})}
+ {cct}
+ {2-winding transformer or choke with terminals P1, P2, TP, S1, S2, TS:
+ arg2: L = left, R = right,
+ arg3: np primary arcs,
+ arg5: ns secondary arcs,
+ arg4: A = air core, P = powder (dashed) core,
+ W = wide windings, L = looped windings,
+ D1: phase dots at P1 and S1 end; D2 at P2 and S2 end; D12 at P1 and S2 end;
+ D21 at P2 and S1 end
+ \seesect{Composite:}}
+\macrodef{tstrip}{tstrip}{(R|L|U|D|{\sl degrees, nterms, chars})}
+ {cct}
+ {terminal strip, chars:
+ I=invisible terminals,
+ C=circle terminals (default),
+ D=dot terminals,
+ O=omitted separator lines,
+ {\tt wid=}value{\tt ;} total strip width,
+ {\tt ht=}value{\tt ;} strip height
+ \seesect{Composite:}}
+\macrodef{ttmotor}{ttmotor}{({\sl linespec, string, diameter, brushwid, brushht})}
+ {cct}
+ {motor with label\seesect{Twoterminal:}}
+\macrodef{twopi\_}{twopi_}{}
+ {gen}
+ {$2\pi$}
+\macrodef{ujt}{ujt}{(\linespec,R,P,E)}
+ {cct}
+ {unijunction transistor, right, P-channel, envelope
+ \seesect{Semiconductors:}}
+\macrodef{unit3D}{unit3D}{(x,y,z)}
+ {3D}
+ {unit triple in the direction of triple x,y,z}
+\macrodef{up\_\_}{up__}{}
+ {gen}
+ {up with respect to current direction}
+\macrodef{up\_}{up_}{}
+ {gen}
+ {set current direction up \seesect{Placing:}}
+\macrodef{variable}{variable}{(`{\sl element}',
+ {\tt [A|P|L|[u]N][C|S]},{\sl angle},{\sl length})}
+ {cct}
+ {overlaid arrow or line to indicate variable 2-terminal element:
+ {\tt A}=arrow, {\tt P}=preset,
+ {\tt L}=linear, {\tt N}=nonlinear, {\tt C}=continuous, {\tt S}=setpwise
+ \seesect{Twoterminal:}}
+\macrodef{vec\_}{vec_}{({\sl x},{\sl y})}
+ {gen}
+ {position rotated with respect to current direction}
+\macrodef{View3D}{View3D}{}
+ {3D}
+ {The view vector (triple) defined by {\tt setview({\sl azim, elev})}. The
+ {\tt project}
+ macro projects onto the plane perpendicular to this vector}
+\macrodef{vlength}{vlength}{({\sl x},{\sl y})}
+ {gen}
+ {vector length $\sqrt{x^2+y^2}$}
+\macrodef{vperp}{vperp}{({\sl linear object})}
+ {gen}
+ {unit-vector pair CCW-perpendicular to linear object}
+\macrodef{Vperp}{Vperp}{({\sl position name}, {\sl position name})}
+ {gen}
+ {unit-vector pair CCW-perpendicular to line joining two named positions}
+\macrodef{vrot\_}{vrot_}{({\sl x},{\sl y},{\sl xcosine},{\sl ycosine})}
+ {gen}
+ {rotation operator}
+\macrodef{vscal\_}{vscal_}{({\sl number},{\sl x},{\sl y})}
+ {gen}
+ {vector scale operator}
+\macrodef{Vsprod\_}{Vsprod_}{({\sl position}, {\sl expression})}
+ {gen}
+ {The vector in arg 1 multiplied by the scalar in arg 2}
+\macrodef{w\_}{w_}{}
+ {gen}
+ {.w with respect to current direction}
+\macrodef{while\_}{while_}{(`{\sl test}',`{\sl actions}')}
+ {gen}
+ {Integer m4 while loop}
+\macrodef{wid\_}{wid_}{}
+ {gen}
+ {width with respect to current direction}
+\macrodef{winding}{winding}{(L|R, {\sl diam, pitch, turns, core wid,
+ core color})}
+ {cct}
+ {core winding drawn in the current direction; {\tt R}=right-handed
+ \seesect{Composite:}}
+\macrodef{XOR\_gate}{XOR_gate}{({\sl n},N)}
+ {log}
+ {`xor' gate, 2 or {\sl n\/} inputs; N=negated input.
+ Otherwise, arg1 can be a sequence of letters {\tt P|N}
+ to define normal or negated inputs.
+ \seesect{Logicgates:}}
+\macrodef{XOR\_off}{XOR_off}{}
+ {log}
+ {XOR and NXOR offset of input face}
+\macrodef{xtal}{xtal}{(\linespec)}
+ {cct}
+ {quartz crystal\seesect{Twoterminal:}}
+\macrodef{xtract}{xtract}{({\sl string, substr1, substr2, $\ldots$})}
+ {gen}
+ {returns substrings if present}
+% \end{tabbing}
diff --git a/graphics/circuit_macros/doc/eboxdims.m4 b/graphics/circuit_macros/doc/eboxdims.m4
new file mode 100644
index 0000000000..024d017c48
--- /dev/null
+++ b/graphics/circuit_macros/doc/eboxdims.m4
@@ -0,0 +1,14 @@
+.PS
+# `eboxdims.m4'
+sinclude(Circuit_macros.dim) # The input file is Circuit_macros.tex
+box fill_(0.9) wid boxdim(Q,w) + 5pt__ ht boxdim(Q,v) + 5pt__ \
+ "\boxdims{Q}{\large$\displaystyle\int_0^T e^{tA}\,dt$}"
+thinlines_
+ s_init(eboxdims)
+ d2 = 5pt__/2
+ textoffset = 2 pt__
+ dimension_(from last box.sw to last box.se chop d2, -0.1,
+ s_box(\tt Q\_w),W,2pt__)
+ dimension_(from last box.se to last box.ne chop d2, -0.1,
+ s_box($\!\!\!$\tt Q\_h${+}$Q\_d) ljust,H,2pt__)
+.PE
diff --git a/graphics/circuit_macros/doc/fbfilter.m4 b/graphics/circuit_macros/doc/fbfilter.m4
new file mode 100644
index 0000000000..fdae23938e
--- /dev/null
+++ b/graphics/circuit_macros/doc/fbfilter.m4
@@ -0,0 +1,39 @@
+.PS
+# fbfilter.m4
+cct_init
+# `fbfilter( U|D|L|R|degrees, [R|L],
+# amp label, C label, R label )'
+define(`fbfilter',
+`[
+ setdir_(ifelse(`$1',,0,`$1')) # Process arg 1
+ eleminit_ # Assign rp_ang, rp_len
+ tmpang = rp_ang # Save rp_ang
+ hunit = elen_ # Dimension parameters
+ vunit = ifinstr(`$2',R,-)dimen_
+ Q: opamp(,,,,`$2')
+ move to Q.In`'ifinstr(`$2',R,2,1); line to rvec_(-hunit/4,0)
+ J: dot
+ R: resistor(to rvec_(-elen_,0)) # Two-term elements change rp_ang
+ point_(tmpang) # so reset it.
+ In: Here
+ move to Q.In`'ifinstr(`$2',R,1,2); line to rvec_(-hunit/4,0)
+ G: Here
+ dot(at Q.Out)
+ { line to rvec_(hunit/4,0)
+ Out: Here }
+ line to rvec_(0,vunit)
+ C: capacitor(to rvec_(-distance(Q.Out,0.5 between J and G),0)); point_(tmpang)
+ line to J
+ ifelse(`$3',,,"$`$3'$" at Q.C)
+ ifelse(`$4',,,"$`$4'$" at C+vec_(0,-vunit/3))
+ ifelse(`$5',,,"$`$5'$" at R+vec_(0,-vunit/4))
+ ]')
+
+F1: fbfilter(,,K_3,C_{24},R_4)
+ ground(at F1.G)
+ dot(at F1.In); line up_ elen_/4
+F2: fbfilter(L,R,K_2,C_{23},R_3) with .In at F1.In
+ ground(at F2.G)
+ resetdir_
+
+.PE
diff --git a/graphics/circuit_macros/doc/fet.m4 b/graphics/circuit_macros/doc/fet.m4
new file mode 100644
index 0000000000..08498ef83d
--- /dev/null
+++ b/graphics/circuit_macros/doc/fet.m4
@@ -0,0 +1,170 @@
+.PS
+# `fet.m4'
+cct_init
+
+dwn = 0.9
+dwn = 1.0
+rgt = 0.9
+textht = 0.1
+
+dnl `IRF4905(linespec,R)'
+define(`IRF4905',
+ `[ ifelse(`$1',,,`eleminit_(`$1')')
+ Q: mosfet(,`$2',dMdPzEDSQdB,) ifelse(`$1',,`
+ S: Q.tr_xy(-4,-2); line from Q.tr_xy(-2,-2) to S
+ D: Q.tr_xy( 4,-2); line from Q.tr_xy(2,-2) to D',
+ `with .Diode.c at last line.c
+ S: last line.start; D: last line.end; line from S to D ')
+ G: Q.G
+ circle rad 5*dimen_/10 at Q.tr_xy(0,1) ]')
+
+define(`rmove',0.75)
+define(`dir_',`right_')
+
+Orig: Here
+dir_
+ { move left 0.2 }
+ {J: j_fet(right_ dimen_,,,E)
+ "{\tt j\_fet(right\_ dimen\_,{,},E)}" wid 1.75 \
+ with .nw at last [].sw+(0.0,-0.25)
+ "$G$" at last [].G rjust above
+ "$S$" at last [].S rjust
+ "$D$" at last [].D ljust
+ }
+
+ move right_ 0.9; dir_
+ {j_fet(,,P,)
+ "{\tt j\_fet(,{,}P,)}" at last [].s+(0,-0.05) below
+ "$G$" at last [].G rjust
+ "$S$" at last [].S rjust
+ "$D$" at last [].D ljust
+ }
+
+ move right_ 0.9; dir_
+ {e_fet(,R,,)
+ "{\tt e\_fet(,R,{,})}" at last [].s+(0,-0.05) below
+ "$G$" at last [].G rjust
+ "$S$" at last [].S rjust
+ "$D$" at last [].D ljust
+ }
+
+ {move down_ dwn; dir_
+ e_fet(,,P)
+ "{\tt e\_fet(,{,}P)}" at last [].s+(0.1,-0.2) below}
+
+ move right_ 0.9; dir_
+ {d_fet(,,,)
+ "{\tt d\_fet(,{,},)}" at last [].s+(0,-0.05) below}
+
+ {move down_ dwn; dir_
+ d_fet(,,P)
+ "{\tt d\_fet(,{,}P)}" at last [].s+(0,-0.05) below}
+
+ move right_ 0.9; dir_
+ {e_fet(,,,S)
+ "{\tt e\_fet(,{,},S)}" at last [].s+(0,-0.05) below}
+
+ {move down_ dwn; dir_
+ e_fet(,,P,S)
+ "{\tt e\_fet(,{,}P,S)}" at last [].s+(0,-0.2) below}
+
+ move right_ 0.9; dir_
+ {d_fet(,,,S)
+ "{\tt d\_fet(,{,},S)}" at last [].s+(0,-0.2) below}
+
+ {move down_ dwn; dir_
+ d_fet(,,P,S)
+ "{\tt d\_fet(,{,}P,S)}" at last [].s+(0,-0.05) below}
+
+ move right_ 0.9; dir_
+ {c_fet(,,,)
+ "{\tt `c\_fet'(,{,},)}" at last [].s+(0,-0.05) below}
+
+ {move down_ dwn; dir_
+ c_fet(,,P)
+ "{\tt `c\_fet'(,{,}P)}" at last [].s+(0,-0.2) below}
+
+move down 1; right_
+ [
+ linewid = linewid*1.2
+
+ Q1: mosfet(,,dGSDF,)
+ {"\tt `mosfet'(,{,}dGSDF,)" wid 1.25 \
+ with .nw at last [].sw+(-0.2,-0.05)
+ thinlines_
+ arrow <- down .05 left .15 from (Q1.G.x,Q1.G.y-0.05)
+ "\tt dG" rjust
+ arrow <- down .10 left .30 from Q1.Channel.start+(.15,0)
+ "\tt F" rjust
+ arrow <- down .05 left .15 from (Q1.S.x,Q1.S.y+0.05)
+ "\tt S" rjust
+ arrow <- down .05 right .15 from (Q1.D.x,Q1.D.y+0.05)
+ "\tt D" ljust
+ thicklines_ }
+
+ move right_ rmove
+ Q2: mosfet(,,uHSDF,)
+ {"\tt `$\ldots$'(,{,}uHSDF,)" at last [].s+(0,-0.15) below
+ thinlines_
+ arrow <- down .05 left .15 from (Q2.G.x,Q2.G.y-0.05)
+ "\tt uH" rjust
+ thicklines_ }
+
+ move right_ rmove
+ Q3: mosfet(,,dMEDSQuB,)
+ {"\tt `$\ldots$'(,{,}dMEDSQuB,)" at last [].s+(0,-0.05) below
+ thinlines_
+ arrow <- down .05 left .15 from (Q3.G.x,Q3.G.y-0.05)
+ "\tt dM" rjust
+ arrow <- down .13 left .30 from Q3.Channel.start+(.12,0)
+ "\tt E" rjust
+ arrow <- down .05 left .10 from Q3.S+(.06,0)
+ "\tt Q" rjust
+ arrow <- down .08 right .24 from (Q3.B.x,Q3.B.y+0.175)
+ "\tt uB" ljust
+ thicklines_ }
+
+ move right_ rmove
+ Q4: mosfet(,,uMEDSuB)
+ {`"{\tt $\ldots$(,{,}uMEDSuB)}"' at last [].s+(0,-0.15) below
+ "$G$" at last [].G rjust
+ "$S$" at last [].S rjust
+ "$D$" at last [].D ljust
+ "$B$" at last [].B below
+ }
+
+ move right_ rmove
+ Q5: mosfet(,,ZSDFdT,)
+ {"\tt `$\ldots$'(,{,}ZSDFdT,)" at last [].s+(0,-0.05) below
+ thinlines_
+ arrow <- down .08 left .08 from (Q5.S.x,Q5.S.y+0.12)
+ "\tt Z" rjust
+ arrow from last arrow.end to Q5.Channel.c+(0.05,0)
+ arrow from last arrow.start to (Q5.D.x,Q5.D.y+.05)
+ arrow <- down .08 right .24 from (Q5.G.x,Q5.G.y-0.02)
+ "\tt dT" ljust
+ thicklines_ }
+
+ move right_ rmove
+ up_
+ Q6: IRF4905 with .c at Here
+ {`"\tt IRF4905"' at Q6.s+(0,-0.15) below
+ "$G$" at Q6.G rjust
+ "$D$" at Q6.D ljust above
+ "$S$" at Q6.S ljust below
+ }
+ ] with .nw at J.sw+(0,-1.35) #Orig+(-0.26,-1.2)
+
+ right_
+ M1: mosfet(,,dBSDFQM1,E) with .nw at J.nw+(0,-dwn)
+ "$G0$" at M1.G0 above rjust
+ "$G1$" at M1.G1 above ljust
+ {"\tt `mosfet'(,{,}dBSDFQM1,E)" wid 1.45 \
+ with .nw at last [].sw+(0,-0.23) }
+ M2: mosfet(,,dBSDFQuM1) with .nw at M1.ne+(0.5,0)
+ "$G0$" at M2.G0 above ljust
+ "$G1$" at M2.G1 above rjust
+ {"\tt ...(,{,}dBSDFQuM1)" wid 1.25 \
+ with .n at last [].s+(0,-0.05) }
+
+.PE
diff --git a/graphics/circuit_macros/doc/lrarrows.m4 b/graphics/circuit_macros/doc/lrarrows.m4
new file mode 100644
index 0000000000..e0a54222e3
--- /dev/null
+++ b/graphics/circuit_macros/doc/lrarrows.m4
@@ -0,0 +1,16 @@
+.PS
+# `lrarrows.m4'
+cct_init
+ del = 0.55
+ inductor; larrow(i)
+ {"`\tt larrow(i)'" at last line + (0,-0.25)}
+ move right_ del
+ inductor; rarrow(i)
+ {"`\tt rarrow(i)'" at last line + (0,-0.25)}
+ move right_ del
+ inductor; larrow(i,<-)
+ {"`\tt larrow(i,<-)'" at last line + (0,-0.25)}
+ move right_ del
+ inductor; rarrow(i,<-)
+ {"`\tt rarrow(i,<-)'" at last line + (0,-0.25)}
+.PE
diff --git a/graphics/circuit_macros/doc/md.tex b/graphics/circuit_macros/doc/md.tex
new file mode 100644
index 0000000000..7d195339e1
--- /dev/null
+++ b/graphics/circuit_macros/doc/md.tex
@@ -0,0 +1,59 @@
+%
+\newdimen{\leftwid}\setlength{\leftwid}{2in}
+\newdimen{\libwid}\setlength{\libwid}{0.5in}
+\newdimen\rightwid
+\setlength{\rightwid}{\textwidth}
+\addtolength{\rightwid}{-\leftwid}
+\addtolength{\rightwid}{-\libwid}
+%
+\newbox\Defbox
+%\iffalse% original macrodef:
+%\newcommand{\macrodef}[3]{\setbox\Defbox=\hbox{\tt #1}%
+% \ifdim\wd\Defbox>\textwidth%
+% \setbox\Defbox=\hbox{\parbox{\textwidth}{\tt #1}}\fi
+% \ifdim\wd\Defbox>\leftwid%
+% \box\Defbox\hfill\break\hspace*{\leftwid}%
+% \else\hbox to \leftwid{\box\Defbox\hfill}\fi%
+% \hbox to \libwid{#2\hfill}\parbox[t]{\rightwid}%
+% {\raggedright #3}\vspace{\parsep}\\}
+%\fi
+
+\newcommand{\macx}[2]{%
+ \phantomsection\pdfbookmark[subsection]{#1}{#2}#1}
+
+\newcommand{\macrodef}[5]{\begin{samepage}%
+\phantomsection\pdfbookmark[subsection]{#1}{#2}%
+\setbox\Defbox=\hbox{\tt #1#3}%
+ \ifdim\wd\Defbox>\textwidth%
+ \setbox\Defbox=\hbox{\parbox{\textwidth}{\tt #1#3}}\fi
+ \ifdim\wd\Defbox>\leftwid%
+ \box\Defbox\hfill\break\hspace*{\leftwid}%
+ \else\hbox to \leftwid{\box\Defbox\hfill}\fi%
+ \hbox to \libwid{#4\hfill}\parbox[t]{\rightwid}%
+ {\raggedright #5}\end{samepage}\vspace{\parsep}\\}
+
+\newcommand{\seesect}[1]{ (see \SR{#1})}
+
+
+\vspace{\abovedisplayskip}
+\noindent
+\macrodef{Along\_}{Along_}{({\sl LinearObj,distance,}[R])}
+ {gen}
+ {Distance arg2 (default all the way) along a linear object
+ from {\tt .start} to {\tt .end}
+ (from {\tt .end} to {\tt .start} if arg3={\tt R}) }
+\macrodef{AND\_gate}{AND_gate}{({\sl n},N)}
+ {log}
+ {basic `and' gate, 2 or {\sl n\/} inputs; {\tt N}=negated input.
+ Otherwise, arg1 can be a sequence of letters {\tt P|N}
+ to define normal or negated inputs
+ \seesect{Logicgates:}}
+\macrodef{AND\_gen}{AND_gen}{($n$,{\sl chars},[{\sl wid},[{\sl ht}]])}
+ {log}
+ {general AND gate: $n$=number of inputs $(0\leq n\leq 16)$;
+ {\sl chars:}
+ B=base and straight sides; A=Arc;
+ [N]NE,[N]SE,[N]I,[N]N,[N]S=inputs or circles;
+ [N]O=output; C=center.
+ Otherwise, arg1 can be a sequence of letters {\tt P|N}
+ to define normal or negated inputs.}
diff --git a/graphics/circuit_macros/doc/mplex.m4 b/graphics/circuit_macros/doc/mplex.m4
new file mode 100644
index 0000000000..926a365438
--- /dev/null
+++ b/graphics/circuit_macros/doc/mplex.m4
@@ -0,0 +1,49 @@
+.PS
+# mplex.m4
+ log_init
+ linewid = linewid*0.9
+
+ define(`short',elen_*2/3)
+ del = BUF_ht*L_unit
+down_
+P: NOR_gate(8)
+B: P.In3+(0,del/2)
+ dx = P.In1.x-P.In2.x
+ line down del/2 from P.Out then right 2*del; dot
+ {line up del*1.5; right_; BUFFER_gate(right_ short); "$\bar{Y}$" ljust }
+# BUFFER_gate(right_ short,N) ; "$Y$" ljust
+ NOT_gate(right_ short,n) ; "$Y$" ljust
+ for_(0,7,1,
+ `line from P.In`'eval(8-m4x) \
+ up B.y-P.In`'eval(8-m4x).y + (3.5-abs(m4x-3.5)) * dx \
+ then left (3.5-m4x)*AND_wd*L_unit then up (0.5+abs(m4x-3.5))*dx; down_
+ A`'m4x: AND_gate(5) with .Out at Here ')
+
+Eb: "$\bar{E}$" rjust at (A0.In5.x-2*short-dx/2,A0.n.y+del/2)
+# BUFFER_gate(from Eb right_ short,N); line to (A7.In1,Here) then to A7.In1
+ NOT_gate(from Eb right_ short,n); line to (A7.In1,Here) then to A7.In1
+ for_(0,6,1,
+ `line from A`'m4x.In1 to (A`'m4x.In1,Eb) ; dot')
+
+ for_(0,2,1,
+ `"`$S_'m4x$" wid 0.17 with .e at (Eb.x-textoffset,Eb.y+(1+m4x)*del*2)
+ NOT_gate(right_ short)
+ V1`'m4x: Here+(N_diam*L_unit/2,-del); {dot(at (V1`'m4x,Here))}
+# NOT_gate(right_ short)
+ NOT_gate(right_ short,n)
+ V0`'m4x: Here')
+
+ for_(0,7,1,`define(`i',m4x)dnl
+ for_(0,2,1,`define(`j',m4x)define(`k',`eval(((i+2**j)/2**j)%2)')dnl
+ move to A`'i.In`'eval(j+2)
+ line up V`'k`'j.y - Here.y dnl
+ ifelse(eval((i==7)|(i==(7-2**j))),1,
+ `then to V`'k`'j ifelse(eval(k==1),1,`then up del')',
+ `; dot')
+ ')
+ move to A`'i.In5; line to (Here,V02)
+ reversed(`BUFFER_gate',up_ short)
+ "$`I_'i$" at last line.end rjust
+ ')
+
+.PE
diff --git a/graphics/circuit_macros/doc/oax.m4 b/graphics/circuit_macros/doc/oax.m4
new file mode 100644
index 0000000000..d2396d6ced
--- /dev/null
+++ b/graphics/circuit_macros/doc/oax.m4
@@ -0,0 +1,5 @@
+.PS
+# `oax.m4'
+cct_init
+include(oaxbody.m4)
+.PE
diff --git a/graphics/circuit_macros/doc/oaxbody.m4 b/graphics/circuit_macros/doc/oaxbody.m4
new file mode 100644
index 0000000000..983b816cf5
--- /dev/null
+++ b/graphics/circuit_macros/doc/oaxbody.m4
@@ -0,0 +1,4 @@
+line right 0.2 then up 0.1
+A: opamp(up_,,,0.4,R) with .In1 at Here
+ line right 0.2 from A.Out
+ line down 0.1 from A.In2 then right 0.2
diff --git a/graphics/circuit_macros/doc/quick.m4 b/graphics/circuit_macros/doc/quick.m4
new file mode 100644
index 0000000000..7de2399601
--- /dev/null
+++ b/graphics/circuit_macros/doc/quick.m4
@@ -0,0 +1,16 @@
+.PS # Pic input begins with .PS
+cct_init # Read in macro definitions and set defaults
+elen = 0.75 # Variables are allowed; default units are inches
+Origin: Here # Position names are capitalized
+ source(up_ elen); llabel(-,v_s,+)
+ resistor(right_ elen); rlabel(,R,)
+ dot
+ { # Save the current position and direction
+ capacitor(down_ to (Here,Origin)) #(Here,Origin) = (Here.x,Origin.y)
+ rlabel(+,v,-); llabel(,C,)
+ dot
+ } # Restore position and direction
+ line right_ elen*2/3
+ inductor(down_ Here.y-Origin.y); rlabel(,L,); b_current(i)
+ line to Origin
+.PE # Pic input ends
diff --git a/graphics/circuit_macros/doc/stringdims.m4 b/graphics/circuit_macros/doc/stringdims.m4
new file mode 100644
index 0000000000..279ce24be1
--- /dev/null
+++ b/graphics/circuit_macros/doc/stringdims.m4
@@ -0,0 +1,10 @@
+.PS
+# stringdims.m4
+sinclude(Circuit_macros.dim)
+s_init(stringdims)
+[B: box
+ s_box(`Left text') at B.w rjust
+ s_box(`Right text: $x^%g$',2) at B.e ljust
+ ]
+ box dotted ht last [].ht wid last [].wid at last []
+.PE
diff --git a/graphics/circuit_macros/doc/test.tex b/graphics/circuit_macros/doc/test.tex
new file mode 100644
index 0000000000..44d486d0c5
--- /dev/null
+++ b/graphics/circuit_macros/doc/test.tex
@@ -0,0 +1 @@
+\centering
diff --git a/graphics/circuit_macros/doc/thyristor.m4 b/graphics/circuit_macros/doc/thyristor.m4
new file mode 100644
index 0000000000..ecc6448bf3
--- /dev/null
+++ b/graphics/circuit_macros/doc/thyristor.m4
@@ -0,0 +1,118 @@
+.PS
+# `thyristor.m4'
+cct_init
+
+define labels { {
+ "\sl $1" ht 11 pt__ $2 at last[].$1
+ "\sl $3" $4 at last[].$3
+ "\sl $5" $6 at last[].$5
+ "\tt $7" ht 11 pt__ $9 at (last[].s+(0,$8)) } }
+
+down_
+Row1: [
+ {thyristor
+ labels(A,above,K,below,G,ljust,`thyristor',-0.25,wid 0.75) }
+
+ move right 0.50 ; down_
+ {thyristor(,B)
+ labels(T1,above,T2,below,G,below ljust,`...(,B)',-0.35) }
+
+ move right 0.50 ; down_
+ {thyristor(down_ dimen_*0.8,BRK)
+ labels(T1,above,T2,below,G,below rjust,`...(,BRK)',-0.22) }
+
+ move right 0.60 ; down_
+ {thyristor(,BE)
+ labels(T1,above,T2,below,G,below ljust,`...(,BE)',-0.35) }
+
+ move right 0.50 ; down_
+ {thyristor(,A) at (Here,last [])
+ labels(A,above,K,below,G,ljust,`...(,A)',-0.35) }
+
+ move right 0.50 ; down_
+ {thyristor(,F) at (Here,last [])
+ labels(A,above,K,below,G,ljust,`...(,F)',-0.22) }
+
+ move right 0.65 ; down_
+ {thyristor(,BRE)
+ labels(T1,above,T2,below,G,below rjust,`...(,BRE)',-0.35) }
+
+ move right 0.75 ; down_
+ {thyristor(,UARE) at (Here,last [])
+ labels(A,above,K,below,G,rjust below,`...(,UARE)',-0.22) }
+
+ move right 0.50 ; down_
+ {thyristor(,AV,G: G+(0.1,0.1)) at (Here,last [])
+ thinlines_
+ spline -> from last[].G left 0.05 then left 0.05 down 0.1
+ thicklines_
+ labels(A,above,K,below,G,ljust,`...(,AV)',-0.35) }
+
+ move right 0.50 ; down_
+ {thyristor(,IEC)
+ labels(A,above ljust,K,below ljust,G,ljust,`...(,IEC)',-0.22) }
+ ]
+Row2: [
+ down_
+ {thyristor(,UAH)
+ labels(A,rjust above,K,rjust below,G,ljust,`...(,UAH)',-0.35,wid 0.65) }
+
+ move right 0.55 ; down_
+ {thyristor(,N) at (Here,last [])
+ labels(A,above,K,below,Ga,rjust,`...(,N)',-0.22) }
+
+ move right 0.55 ; down_
+ {thyristor(,UANRE) at (Here,last [])
+ labels(A,above,K,below,Ga,ljust above,`...(,UANRE)',-0.35) }
+ move right 0.55 ; down_
+ {thyristor(,SCR) at (Here,last [])
+ labels(A,above,K,below rjust,G,below ljust,`...(,SCR)',-0.22) }
+
+ move right 0.55 ; down_
+ {thyristor(,SCRE) at (Here,last [])
+ labels(A,above,K,below,G,ljust below,`...(SCRE)',-0.35) }
+
+ move right 0.65 ; down_
+ {thyristor(,SCRRE) at (Here,last [])
+ labels(A,above,K,below,G,rjust below,`...(SCRRE)',-0.22) }
+
+ move right 0.55 ; down_
+ {thyristor(,SCS) at (Here,last [])
+ labels(A,above,K,below,G,ljust,`...(SCS)',-0.35) }
+ { "\sl Ga" rjust above at last[].Ga }
+
+ move right 0.55 ; down_
+ {thyristor(,SCSE) at (Here,last [])
+ labels(A,above,K,below,G,ljust below,`...(SCSE)',-0.22) }
+ { "\sl Ga" rjust above at last[].Ga }
+
+ move right 0.65 ; down_
+ {thyristor(,SUSE) at (Here,last [])
+ labels(A,above,K,below,G,rjust,`...(SUSE)',-0.35) }
+
+ move right 0.65 ; down_
+ {thyristor(,SBSE) at (Here,last [])
+ labels(T1,above,T2,below,G,rjust,`...(SBSE)',-0.22) }
+
+ ] with .nw at Row1.sw + (0,-0.20)
+
+Twoterms: [ right_
+ { scr(,,Q) ; `"\tt scr(,{,}Q)"' at last [].e ljust}
+ { "\sl Q.G" at Q.G above }
+
+ move down 0.4; right_
+ { scs(,,Q2) ; `"\tt scs(,{,}Q2)"' at last [].e ljust }
+ { "\sl Q2.G" at Q2.G above }
+ { "\sl Q2.Ga" at Q2.Ga below }
+ ] with .nw at Row2.sw+(0,-0.2)
+
+ [ right_
+ { sus(,RE,Q3) ; `"\tt sus(,RE,Q3)"' at last [].e ljust}
+ { "\sl Q3.G" at Q3.G above }
+
+ move right_ 1.2 from last line.end
+ { sbs(,E,Q4) ; `"\tt sbs(,E,Q4)"' at last [].e ljust}
+ { "\sl Q4.G" at Q4.G below }
+ ] with .w at last [].e+(1.0,0)
+
+.PE
diff --git a/graphics/circuit_macros/doc/tran.m4 b/graphics/circuit_macros/doc/tran.m4
new file mode 100644
index 0000000000..3314be47e0
--- /dev/null
+++ b/graphics/circuit_macros/doc/tran.m4
@@ -0,0 +1,5 @@
+.PS
+# `tran.m4'
+cct_init
+include(tranbody.m4)
+.PE
diff --git a/graphics/circuit_macros/doc/tran.tex b/graphics/circuit_macros/doc/tran.tex
new file mode 100644
index 0000000000..a894de26d5
--- /dev/null
+++ b/graphics/circuit_macros/doc/tran.tex
@@ -0,0 +1,76 @@
+% tran.m4
+\begin{tikzpicture}[scale=2.54]
+% dpic version 2014.03.24 option -g for TikZ and PGF 1.01
+\ifx\dpiclw\undefined\newdimen\dpiclw\fi
+\global\def\dpicdraw{\draw[line width=\dpiclw]}
+\global\def\dpicstop{;}
+\dpiclw=0.8bp
+\dpiclw=0.8bp
+\dpicdraw (0,0)
+ --(0.2,0)\dpicstop
+\dpicdraw (0.2,0.333333)
+ --(0.2,0.291667)\dpicstop
+\dpicdraw (0.2,0.291667)
+ --(0.194444,0.291667)\dpicstop
+\dpicdraw (0.2,0.291667)
+ ..controls (0.217259,0.291667) and (0.23125,0.277676)
+ ..(0.23125,0.260417)
+ ..controls (0.23125,0.243158) and (0.217259,0.229167)
+ ..(0.2,0.229167)\dpicstop
+\dpicdraw (0.2,0.229167)
+ --(0.194444,0.229167)\dpicstop
+\dpicdraw (0.2,0.229167)
+ ..controls (0.217259,0.229167) and (0.23125,0.215176)
+ ..(0.23125,0.197917)
+ ..controls (0.23125,0.180658) and (0.217259,0.166667)
+ ..(0.2,0.166667)\dpicstop
+\dpicdraw (0.2,0.166667)
+ --(0.194444,0.166667)\dpicstop
+\dpicdraw (0.2,0.166667)
+ ..controls (0.241667,0.166667) and (0.241667,0.104167)
+ ..(0.2,0.104167)\dpicstop
+\dpicdraw (0.2,0.104167)
+ --(0.194444,0.104167)\dpicstop
+\dpicdraw (0.2,0.104167)
+ ..controls (0.241667,0.104167) and (0.241667,0.041667)
+ ..(0.2,0.041667)\dpicstop
+\dpicdraw (0.2,0.041667)
+ --(0.194444,0.041667)\dpicstop
+\dpicdraw (0.2,0.041667)
+ --(0.2,-0)\dpicstop
+\dpicdraw (0.272917,0.291667)
+ --(0.272917,0.041667)\dpicstop
+\dpicdraw (0.335417,0.291667)
+ --(0.335417,0.041667)\dpicstop
+\dpicdraw (0.408333,0.072917)
+ --(0.408333,0.072917)\dpicstop
+\dpicdraw (0.408333,0.072917)
+ --(0.413889,0.072917)\dpicstop
+\dpicdraw (0.408333,0.072917)
+ ..controls (0.366667,0.072917) and (0.366667,0.135417)
+ ..(0.408333,0.135417)\dpicstop
+\dpicdraw (0.408333,0.135417)
+ --(0.413889,0.135417)\dpicstop
+\dpicdraw (0.408333,0.135417)
+ ..controls (0.391074,0.135417) and (0.377083,0.149408)
+ ..(0.377083,0.166667)
+ ..controls (0.377083,0.183926) and (0.391074,0.197917)
+ ..(0.408333,0.197917)\dpicstop
+\dpicdraw (0.408333,0.197917)
+ --(0.413889,0.197917)\dpicstop
+\dpicdraw (0.408333,0.197917)
+ ..controls (0.366667,0.197917) and (0.366667,0.260417)
+ ..(0.408333,0.260417)\dpicstop
+\dpicdraw (0.408333,0.260417)
+ --(0.413889,0.260417)\dpicstop
+\dpicdraw (0.408333,0.260417)
+ --(0.408333,0.260417)\dpicstop
+\dpicdraw (0.2,0.333333)
+ --(0,0.333333)\dpicstop
+\dpicdraw (0.408333,0.260417)
+ --(0.608333,0.260417)
+ --(0.608333,0.360417)\dpicstop
+\dpicdraw (0.408333,0.072917)
+ --(0.608333,0.072917)
+ --(0.608333,-0.027083)\dpicstop
+\end{tikzpicture}
diff --git a/graphics/circuit_macros/doc/tranbody.m4 b/graphics/circuit_macros/doc/tranbody.m4
new file mode 100644
index 0000000000..bf16300cf0
--- /dev/null
+++ b/graphics/circuit_macros/doc/tranbody.m4
@@ -0,0 +1,6 @@
+line right 0.2
+up_
+A: transformer(,R,,,3) with .P1 at Here
+ line left 0.2 from A.P2
+ line right 0.2 from A.S2 then up 0.1
+ line right 0.2 from A.S1 then down 0.1
diff --git a/graphics/circuit_macros/doc/ujt.m4 b/graphics/circuit_macros/doc/ujt.m4
new file mode 100644
index 0000000000..aa4e708462
--- /dev/null
+++ b/graphics/circuit_macros/doc/ujt.m4
@@ -0,0 +1,28 @@
+.PS
+# `ujt.m4'
+cct_init
+dwn = 1.0
+dsep = 0.15
+
+define(`demo_ujt',`Q: ujt(`$1',`$2',`$3',`$4')
+ "\sl B1" ifelse(`$5',,below,ljust) at last [].B1
+ "{\sl E}sp_" at 1.5 between last [].Bulk.c and last [].E
+ "\sl B2" ifelse(`$5',,above,ljust) at last [].B2
+ ')
+
+[demo_ujt(up_ dimen_,,,E,A)
+`"{\tt ujt(up\_ dimen\_,{,},E)}"' wid 1.45 ht 0.1 at Q.s+(0,-0.15) ]
+
+[demo_ujt(,,P,)
+`"{\tt ujt(,{,}P,)}"' at Q.s+(0.1,-dsep) below ] \
+with .Q.w at last [].Q.e+(0.85,0)
+
+[demo_ujt(,R,,)
+`"{\tt ujt(,R,{,})}"' at Q.s+(0,-dsep) below] \
+with .Q.w at last [].Q.e+(0.8,0)
+
+[demo_ujt(,R,P,)
+`"{\tt ujt(,R,P,)}"' at Q.s+(0,-dsep) below] \
+with .Q.w at last [].Q.e+(0.8,0)
+
+.PE
diff --git a/graphics/circuit_macros/doc/woodchips.m4 b/graphics/circuit_macros/doc/woodchips.m4
new file mode 100644
index 0000000000..e792c13508
--- /dev/null
+++ b/graphics/circuit_macros/doc/woodchips.m4
@@ -0,0 +1,24 @@
+divert(-1)
+# `woodchips.m4'
+
+define(`grid',`[
+ psset_(linecolor=lightgray)
+ B: box invis wid 1.0 ht 0.3
+ d = 0.08
+ for x=B.ht to B.wid by d do {
+ line from B.nw+(x,0) thick 0.4 down B.ht left B.ht }
+ psset_(linecolor=black)
+ ]')
+
+divert(0)dnl
+.PS
+sinclude(Circuit_macros.dim)
+s_init(woodchips)
+
+ G: grid
+ f_box(Wood chips) with .w at G
+
+ f_box(color "lightgray" thickness 2 rad 2pt__,"\huge$n^{%g}$",4-1) \
+ with .w at G.e+(1.2,0)
+
+.PE