%%%%Author of this macro: Libor Gajdosik  1997
%%%%% adress: libor.gajdosik@vsb.cz

%%%This macro is for drawing simple electro scheme in picture
%%%environment and  puting to text (suitable for articles)
%%%Latex209,DOS is sufficient%%%%%%%

\unitlength=1mm
%grid -generating help grid 10x10mm to simplify orientation
\newcommand{\grid}[2]{
\linethickness{0.1mm}
\unitlength=10mm
\put(0,0){\line(0,1){#2}
\multiput(1,0)(1,0){#1}{\line(0,1){#2}}}
\put(0,0){\line(1,0){#1}}
\multiput(0,1)(0,1){#2}{\line(1,0){#1}}
\thicklines
\unitlength=1mm
}

%%%%transistors (bipolar, mosfet, jfet)
%thick circle 10mm
\newcommand{\kolo}{
\put(0,0){\oval(10,10)[tl]}
\put(0.1,-0.1){\oval(9.9,9.9)[tl]}
\put(0.2,-0.2){\oval(9.8,9.8)[tl]}
\put(0.3,-0.3){\oval(9.7,9.7)[tl]}
\put(0,0){\oval(10,10)[tr]}
\put(-0.1,-0.1){\oval(9.9,9.9)[tr]}
\put(-0.2,-0.2){\oval(9.8,9.8)[tr]}
\put(-0.3,-0.3){\oval(9.7,9.7)[tr]}
\put(0,0){\oval(10,10)[bl]}
\put(0.1,0.1){\oval(9.9,9.9)[bl]}
\put(0.2,0.2){\oval(9.8,9.8)[bl]}
\put(0.3,0.3){\oval(9.7,9.7)[bl]}
\put(0,0){\oval(10,10)[br]}
\put(-0.1,0.1){\oval(9.9,9.9)[br]}
\put(-0.2,0.2){\oval(9.8,9.8)[br]}
\put(-0.3,0.3){\oval(9.7,9.7)[br]}
}
%jfet transistor
\newcommand{\jfet}[5]{
\ifx#2R                    %right oriented
 \ifx#3U                   %drain up
   \ifx#1N                  %n channel
\put(0,0){\vector(1,0){11}}
    \fi \ifx#1P             %p channel
\put(0,0){\line(1,0){11}}
\put(11.5,0){\vector(-1,0){4}}
     \fi
\put(12,2.5){\kolo}
\put(11.5,5){\line(1,0){8.5}}
\put(11.5,0){\line(1,0){8.5}}
\put(20,5){\line(0,1){5}}
\put(20,0){\line(0,-1){10}}
\put(0,5){\makebox(10,6)[l]{#4}}
\put(6,-10){\makebox(10,6)[r]{#5}}
\multiput(11,5)(0.1,0){5}{\line(0,-1){5}}
 \fi \ifx#3D                  %drain down
   \ifx#1N                  %n channel
\put(0,0){\vector(1,0){11}}
    \fi \ifx#1P             %p channel
\put(0,0){\line(1,0){11}}
\put(11.5,0){\vector(-1,0){4}}
     \fi
\put(12,-2.5){\kolo}
\put(11.5,-5){\line(1,0){8.5}}
\put(11.5,0){\line(1,0){8.5}}
\put(20,0){\line(0,1){10}}
\put(20,-5){\line(0,-1){5}}
\put(8,5){\makebox(10,6)[r]{#4}}
\put(-2,-12.5){\makebox(10,6)[r]{#5}}
\multiput(11.5,0)(0.1,0){5}{\line(0,-1){5}}
 \fi
 \fi \ifx#2L                  %left oriented
  \ifx#3D                     %drain down
   \ifx#1N                  %n channel
\put(0,0){\vector(-1,0){11}}
    \fi \ifx#1P             %p channel
\put(0,0){\line(-1,0){11}}
\put(-11.5,0){\vector(1,0){4}}
     \fi
\put(-12,-2.5){\kolo}
\put(-11.5,-5){\line(-1,0){8.5}}
\put(-11.5,0){\line(-1,0){8.5}}
\put(-20,-5){\line(0,-1){5}}
\put(-20,0){\line(0,1){10}}
\put(-15,5){\makebox(10,6)[l]{#4}}
\put(-5,-10){\makebox(10,6)[l]{#5}}
\multiput(-11,0)(-0.1,0){5}{\line(0,-1){5}}
  \fi \ifx#3U                     %drain up
   \ifx#1N                  %n channel
\put(0,0){\vector(-1,0){11}}
    \fi \ifx#1P             %p channel
\put(0,0){\line(-1,0){11}}
\put(-11.5,0){\vector(1,0){4}}
     \fi
\put(-12,2.5){\kolo}
\put(-11.5,5){\line(-1,0){8.5}}
\put(-11.5,0){\line(-1,0){8.5}}
\put(-20,5){\line(0,1){5}}
\put(-20,0){\line(0,-1){10}}
\put(-5,5){\makebox(10,6)[l]{#4}}
\put(-15,-10){\makebox(10,6)[l]{#5}}
\multiput(-11,5)(-0.1,0){5}{\line(0,-1){5}}
     \fi \fi

\ifx#2U                    %up oriented
 \ifx#3R                   %drain right
   \ifx#1N                  %n channel
\put(0,0){\vector(0,1){11}}
    \fi \ifx#1P             %p channel
\put(0,0){\line(0,1){11}}
\put(0,11.5){\vector(0,-1){4}}
     \fi
\put(2.5,12){\circle{10}}
\put(5,11.5){\line(0,1){8.5}}
\put(0,11.5){\line(0,1){8.5}}
\put(5,20){\line(1,0){5}}
\put(0,20){\line(-1,0){10}}
\put(5,0){\makebox(10,6)[l]{#5}}
\put(-13,0){\makebox(10,6)[r]{#4}}
\multiput(5,11)(0,0.1){5}{\line(-1,0){5}}
 \fi \ifx#3L                  %drain left
   \ifx#1N                  %n channel
\put(0,0){\vector(0,1){11}}
    \fi \ifx#1P             %p channel
\put(0,0){\line(0,1){11}}
\put(0,11.5){\vector(0,-1){4}}
     \fi
\put(-2.5,12){\kolo}
\put(-5,11.5){\line(0,1){8.5}}
\put(0,11.5){\line(0,1){8.5}}
\put(0,20){\line(1,0){10}}
\put(-5,20){\line(-1,0){5}}
\put(5,0){\makebox(10,6)[l]{#5}}
\put(-13,0){\makebox(10,6)[r]{#4}}
\multiput(0,11.5)(0,0.1){5}{\line(-1,0){5}}
 \fi

 \fi \ifx#2D                  %down oriented
  \ifx#3L                     %drain left
   \ifx#1N                  %n channel
\put(0,0){\vector(0,-1){11}}
    \fi \ifx#1P             %p channel
\put(0,0){\line(0,-1){11}}
\put(0,-11.5){\vector(0,1){4}}
     \fi
\put(-2.5,-12){\kolo}
\put(-5,-11.5){\line(0,-1){8.5}}
\put(0,-11.5){\line(0,-1){8.5}}
\put(-5,-20){\line(-1,0){5}}
\put(0,-20){\line(1,0){10}}
\put(5,-5){\makebox(10,6)[l]{#5}}
\put(-13,-5){\makebox(10,6)[r]{#4}}
\multiput(0,-11)(0,-0.1){5}{\line(-1,0){5}}
  \fi \ifx#3R                     %drain right
   \ifx#1N                  %n channel
\put(0,0){\vector(0,-1){11}}
    \fi \ifx#1P             %p channel
\put(0,0){\line(0,-1){11}}
\put(0,-11.5){\vector(0,1){4}}
     \fi
\put(2.5,-12){\kolo}
\put(5,-11.5){\line(0,-1){8.5}}
\put(0,-11.5){\line(0,-1){8.5}}
\put(5,-20){\line(1,0){5}}
\put(0,-20){\line(-1,0){10}}
\put(5,-5){\makebox(10,6)[l]{#5}}
\put(-13,-5){\makebox(10,6)[r]{#4}}
\multiput(5,-11)(0,-0.1){5}{\line(-1,0){5}}
     \fi \fi
}
%mos transistor
\newcommand{\mos}[6]{
  \ifx#3R          %right oriented
       \ifx#4D      %drain down
\put(0,0){\line(1,0){10}}
\put(12,2.5){\kolo}
\put(10,5){\line(0,-1){5}}
\put(11.5,5){\line(1,0){8.5}}
\put(11.5,0){\line(1,0){8.5}}
\put(20,5){\line(0,1){5}}
\put(20,0){\line(0,-1){10}}
\put(0,5){\makebox(10,6)[l]{#5}}
\put(6,-10){\makebox(10,6)[r]{#6}}
   \ifx#1E                     %enhancement mode
\multiput(11,1)(0,2){3}{\multiput(0,0)(0.1,0){5}{\line(0,-1){1}}}
   \else \ifx#1D               %depletion mode
\multiput(11,5)(0.1,0){5}{\line(0,-1){5}}
   \fi \fi
   \ifx#2P                    %p type
\put(11.5,0){\vector(1,0){4}}
   \else \ifx#2N              %n type
\put(15.5,0){\vector(-1,0){4}}
   \fi \fi

       \else \ifx#4U   %drain up
\put(0,0){\line(1,0){10}}
\put(12,-2.5){\kolo}
\put(10,0){\line(0,-1){5}}
\put(11.5,-5){\line(1,0){8.5}}
\put(11.5,0){\line(1,0){8.5}}
\put(20,-5){\line(0,-1){5}}
\put(20,0){\line(0,1){10}}
\put(0,-11){\makebox(10,6)[l]{#5}}
\put(6,3){\makebox(10,6)[r]{#6}}
   \ifx#1E                     %enhancement mode
\multiput(11,-4)(0,2){3}{\multiput(0,0)(0.1,0){5}{\line(0,-1){1}}}
   \else \ifx#1D               %depletion mode
\multiput(11,0)(0.1,0){5}{\line(0,-1){5}}
   \fi \fi
   \ifx#2P                    %p type
\put(11.5,0){\vector(1,0){4}}
   \else \ifx#2N              %n type
\put(15.5,0){\vector(-1,0){4}}
   \fi \fi
       \fi \fi
 \fi

  \ifx#3L          %leftt oriented
       \ifx#4D      %drain down
\put(0,0){\line(-1,0){10}}
\put(-12,2.5){\kolo}
\put(-10,5){\line(0,-1){5}}
\put(-11.5,5){\line(-1,0){8.5}}
\put(-11.5,0){\line(-1,0){8.5}}
\put(-20,5){\line(0,1){5}}
\put(-20,0){\line(0,-1){10}}
\put(-5,5){\makebox(10,6)[l]{#5}}
\put(-15,-10){\makebox(10,6)[l]{#6}}
   \ifx#1E                     %enhancement mode
\multiput(-11,1)(0,2){3}{\multiput(0,0)(-0.1,0){5}{\line(0,-1){1}}}
   \else \ifx#1D               %depletion mode
\multiput(-11,5)(-0.1,0){5}{\line(0,-1){5}}
   \fi \fi
   \ifx#2P                    %p type
\put(-11.5,0){\vector(-1,0){4}}
   \else \ifx#2N              %n type
\put(-15.5,0){\vector(1,0){4}}
   \fi \fi

       \else \ifx#4U   %drain up
\put(0,0){\line(-1,0){10}}
\put(-12,-2.5){\kolo}
\put(-10,0){\line(0,-1){5}}
\put(-11.5,-5){\line(-1,0){8.5}}
\put(-11.5,0){\line(-1,0){8.5}}
\put(-20,-5){\line(0,-1){5}}
\put(-20,0){\line(0,1){10}}
\put(-5,-11){\makebox(10,6)[l]{#5}}
\put(-15,3){\makebox(10,6)[l]{#6}}
   \ifx#1E                     %enhancement mode
\multiput(-11,-4)(0,2){3}{\multiput(0,0)(-0.1,0){5}{\line(0,-1){1}}}
   \else \ifx#1D               %depletion mode
\multiput(-11,0)(-0.1,0){5}{\line(0,-1){5}}
   \fi \fi
   \ifx#2P                    %p type
\put(-11.5,0){\vector(-1,0){4}}
   \else \ifx#2N              %n type
\put(-15.5,0){\vector(1,0){4}}
   \fi \fi
       \fi \fi
 \fi

  \ifx#3U          %up oriented
       \ifx#4L      %drain left
\put(0,0){\line(0,1){10}}
\put(2.5,12){\kolo}
\put(5,10){\line(-1,0){5}}
\put(5,11.5){\line(0,1){8.5}}
\put(0,11.5){\line(0,1){8.5}}
\put(5,20){\line(1,0){5}}
\put(0,20){\line(-1,0){10}}
\put(-12,0){\makebox(10,6)[r]{#5}}
\put(2,0){\makebox(10,6)[l]{#6}}
   \ifx#1E                     %enhancement mode
\multiput(1,11)(2,0){3}{\multiput(0,0)(0,0.1){5}{\line(-1,0){1}}}
   \else \ifx#1D               %depletion mode
\multiput(5,11)(0,0.1){5}{\line(-1,0){5}}
   \fi \fi
   \ifx#2P                    %p type
\put(0,11.5){\vector(0,1){4}}
   \else \ifx#2N              %n type
\put(0,15.5){\vector(0,-1){4}}
   \fi \fi

       \else \ifx#4R   %drain right
\put(0,0){\line(0,1){10}}
\put(-2.5,12){\kolo}
\put(0,10){\line(-1,0){5}}
\put(-5,11.5){\line(0,1){8.5}}
\put(0,11.5){\line(0,1){8.5}}
\put(-5,20){\line(-1,0){5}}
\put(0,20){\line(1,0){10}}
\put(-12,0){\makebox(10,6)[r]{#5}}
\put(2,0){\makebox(10,6)[l]{#6}}
   \ifx#1E                     %enhancement mode
\multiput(-4,11)(2,0){3}{\multiput(0,0)(0,0.1){5}{\line(-1,0){1}}}
   \else \ifx#1D               %depletion mode
\multiput(0,11)(0,0.1){5}{\line(-1,0){5}}
   \fi \fi
   \ifx#2P                    %p type
\put(0,11.5){\vector(0,1){4}}
   \else \ifx#2N              %n type
\put(0,15.5){\vector(0,-1){4}}
   \fi \fi
       \fi \fi
 \fi

  \ifx#3D          %down oriented
       \ifx#4L      %drain left
\put(0,0){\line(0,-1){10}}
\put(2.5,-12){\kolo}
\put(5,-10){\line(-1,0){5}}
\put(5,-11.5){\line(0,-1){8.5}}
\put(0,-11.5){\line(0,-1){8.5}}
\put(5,-20){\line(1,0){5}}
\put(0,-20){\line(-1,0){10}}
\put(-12,-6){\makebox(10,6)[r]{#5}}
\put(2,-6){\makebox(10,6)[l]{#6}}
   \ifx#1E                     %enhancement mode
\multiput(1,-11)(2,0){3}{\multiput(0,0)(0,-0.1){5}{\line(-1,0){1}}}
   \else \ifx#1D               %depletion mode
\multiput(5,-11)(0,-0.1){5}{\line(-1,0){5}}
   \fi \fi
   \ifx#2P                    %p type
\put(0,-11.5){\vector(0,-1){4}}
   \else \ifx#2N              %n type
\put(0,-15.5){\vector(0,1){4}}
   \fi \fi

       \else \ifx#4R   %drain right
\put(0,0){\line(0,-1){10}}
\put(-2.5,-12){\kolo}
\put(0,-10){\line(-1,0){5}}
\put(-5,-11.5){\line(0,-1){8.5}}
\put(0,-11.5){\line(0,-1){8.5}}
\put(-5,-20){\line(-1,0){5}}
\put(0,-20){\line(1,0){10}}
\put(-12,-6){\makebox(10,6)[r]{#5}}
\put(2,-6){\makebox(10,6)[l]{#6}}
   \ifx#1E                     %enhancement mode
\multiput(-4,-11)(2,0){3}{\multiput(0,0)(0,-0.1){5}{\line(-1,0){1}}}
   \else \ifx#1D               %depletion mode
\multiput(0,-11)(0,-0.1){5}{\line(-1,0){5}}
   \fi \fi
   \ifx#2P                    %p type
\put(0,-11.5){\vector(0,-1){4}}
   \else \ifx#2N              %n type
\put(0,-15.5){\vector(0,1){4}}
   \fi \fi
       \fi \fi
 \fi
}
%bipolar transistor
\newcommand{\bipolar}[5]{
  \ifx#2R                       %right oriented
\put(0,0){\line(1,0){10}}
\put(11,0){\kolo}
\put(10,0){\line(1,1){10}}
\multiput(9,2)(0.1,0){10}{\line(0,-1){4}}
\put(10,0){\line(1,-1){10}}
\put(20,10){\line(0,1){10}}
\put(20,-10){\line(0,-1){10}}
\put(5,5){\makebox(10,6){#4}}
\put(5,-12){\makebox(10,6)[r]{#5}}
     \ifx#3D                     %emitor down
          \ifx#1N                  %npn type
\put(10,0){\vector(1,-1){4}}
          \else \ifx#1P            %pnp type
\put(14,-4){\vector(-1,1){4}}
          \fi \fi
     \else \ifx#3U              %emitor up
          \ifx#1N              %npn type
\put(10,0){\vector(1,1){4}}
          \else \ifx#1P        %pnp type
\put(14,4){\vector(-1,-1){4}}
          \fi \fi
     \fi \fi
  \fi
  \ifx#2L                         %left oriented
\put(0,0){\line(-1,0){10}}
\put(-11,0){\kolo}
\put(-10,0){\line(-1,1){10}}
\multiput(-9,2)(-0.1,0){10}{\line(0,-1){4}}
\put(-10,0){\line(-1,-1){10}}
\put(-20,10){\line(0,1){10}}
\put(-20,-10){\line(0,-1){10}}
\put(-13,5){\makebox(10,6)[l]{#4}}
\put(-15,-12){\makebox(10,6)[l]{#5}}
     \ifx#3D                         %emitor down
          \ifx#1N                      %npn type
\put(-10,0){\vector(-1,-1){4}}
          \else \ifx#1P                %pnp type
\put(-14,-4){\vector(1,1){4}}
          \fi \fi                    
     \else \ifx#3U                   %emitor up
          \ifx#1N                      %npn type
\put(-10,0){\vector(-1,1){4}}
          \else \ifx#1P                %pnp type
\put(-14,4){\vector(1,-1){4}}
          \fi \fi
     \fi \fi
  \fi
  \ifx#2U                            %up oriented
\put(0,0){\line(0,1){10}}
\put(0,11){\kolo}
\put(0,10){\line(1,1){10}}
\multiput(-2,9)(0,0.1){10}{\line(1,0){4}}
\put(0,10){\line(-1,1){10}}
\put(10,20){\line(1,0){10}}
\put(-10,20){\line(-1,0){10}}
\put(-17,8){\makebox(10,6)[r]{#4}}
\put(7,8){\makebox(10,6)[l]{#5}}
     \ifx#3R                        %emitor right
        \ifx#1N                       %npn type
\put(0,10){\vector(1,1){4}}
        \else \ifx#1P                %pnp type
\put(4,14){\vector(-1,-1){4}}
        \fi \fi
     \else \ifx#3L                 %emitor left
        \ifx#1N                      %npn type
\put(0,10){\vector(-1,1){4}}
        \else \ifx#1P                %pnp type
\put(-4,14){\vector(1,-1){4}}
        \fi \fi
     \fi \fi
  \fi
  \ifx#2D                         %emitor down
\put(0,0){\line(0,-1){10}}
\put(0,-11){\kolo}
\put(0,-10){\line(1,-1){10}}
\multiput(-2,-9)(0,-0.1){10}{\line(1,0){4}}
\put(0,-10){\line(-1,-1){10}}
\put(10,-20){\line(1,0){10}}
\put(-10,-20){\line(-1,0){10}}
\put(-17,-13){\makebox(10,6)[r]{#4}}
\put(7,-13){\makebox(10,6)[l]{#5}}
     \ifx#3R                       %emitor right
         \ifx#1N                     %npn type
\put(0,-10){\vector(1,-1){4}}
         \else \ifx#1P               %pnp type
\put(4,-14){\vector(-1,1){4}}
         \fi \fi
     \else \ifx#3L                 %emitor left
         \ifx#1N                     %npn type
\put(0,-10){\vector(-1,-1){4}}
         \else \ifx#1P               %pnp type
\put(-4,-14){\vector(1,1){4}}
         \fi \fi
     \fi \fi
  \fi
}


%%%%%%semiconductors (photorezistor, varistor, thermistor,
%%%%%%diode, thyristor, triac, diac, optomember, opamplifier)
%horizontal photorezistor
\newcommand{\hphotorez}[2]{
\put(0,0){\hrez{#1}{#2}{}}
\multiput(12,8)(2,0){2}{\vector(1,-1){4}}
}
%diagonal photorezistor
\newcommand{\dphotorez}[3]{
\put(0,0){\drez{#1}{#2}{#3}{}}
  \ifx#1D
\multiput(3,-15)(0,2){2}{\vector(1,0){4}}
  \fi \ifx#1U
\multiput(3,12)(0,2){2}{\vector(1,0){4}}
  \fi
}
%vertical photorezistor
\newcommand{\vphotorez}[2]{
\put(0,0){\vrez{#1}{#2}{}}
\multiput(-8,18)(0,2){2}{\vector(1,-1){4}}
}
%diagonal thermistor or varistor
\newcommand{\dvarrez}[4]{
\put(0,0){\drez{#1}{#2}{#3}{}}
  \ifx#1D
\put(16,-6){\makebox(5,5)[l]{#4}}
\put(16,-6){\line(-2,-1){14}}
\put(16,-6){\line(1,0){4}}
  \fi \ifx#1U
\put(0,12){\makebox(5,5)[r]{#4}}
\put(5,12){\line(2,-1){14}}
\put(5,12){\line(-1,0){4}}
  \fi
}
%vertical thermistor or varistor
\newcommand{\vvarrez}[3]{
\put(0,0){\vrez{#1}{#2}{0}}
\put(-12,18){\makebox(5,5){#3}}
\put(-6,18){\line(3,-1){12}}
\put(-6,18){\line(-1,0){4}}
}
%horizontal thermistor or varistor
\newcommand{\hvarrez}[3]{
\put(0,0){\hrez{#1}{#2}{0}}
\put(7,6){\makebox(5,5){#3}}
\put(12,6){\line(1,-3){4}}
\put(12,6){\line(-1,0){4}}
}
%graetz
\newcommand{\graetz}[1]{
   \ifx#1R
\put(0,0){\ddiode{U}{U}{}{}}
\put(20,20){\ddiode{D}{D}{}{}}
\put(0,0){\ddiode{D}{D}{}{}}
\put(20,-20){\ddiode{U}{U}{}{}}
   \fi
   \ifx#1L
\put(0,0){\ddiode{U}{D}{}{}}
\put(20,20){\ddiode{D}{U}{}{}}
\put(0,0){\ddiode{D}{U}{}{}}
\put(20,-20){\ddiode{U}{D}{}{}}
   \fi
}
%diagonal diode
\newcommand{\ddiode}[4]{
\ifx#1D                %down right oriented
\put(0,0){\line(1,-1){8}}
\put(10.5,-5.5){\line(-1,-1){5}}
      \ifx#2D                   %cathode down
\put(10.5,-5.5){\line(1,-3){2.5}}
\put(5.5,-10.5){\line(3,-1){7}}
      \fi \ifx#2U              %cathode up
\put(10.5,-15.5){\line(-1,3){2.5}}
\put(15.5,-10.5){\line(-3,1){7}}
           \fi
\put(15.5,-10.5){\line(-1,-1){5}}
\put(13,-13){\line(1,-1){7}}
\put(4,-4){\makebox(10,6)[l]{#3}}    %label
\put(20,-18){\makebox(10,6)[l]{#4}}  %label
\fi

\ifx#1U                       %up right oriented
\put(0,0){\line(1,1){8}}
\put(10.5,5.5){\line(-1,1){5}}
      \ifx#2U                    %cathode up
\put(10.5,5.5){\line(1,3){2.5}}
\put(5.5,10.5){\line(3,1){7}}
      \fi \ifx#2D               %cathode down
\put(10.5,15.5){\line(-1,-3){2.5}}
\put(15.5,10.5){\line(-3,-1){7}}
           \fi
\put(15.5,10.5){\line(-1,1){5}}
\put(13,13){\line(1,1){7}}
\put(18,11){\makebox(10,6)[l]{#3}}
\put(6,-1){\makebox(10,6)[l]{#4}}
\fi
}
%horizontal diode
\newcommand{\hdiode}[4]{
  \ifx#1R                  %cathode right
\put(0,0){\line(1,0){10}}
\put(10,3){\line(0,-1){6}}
\put(10,3){\line(2,-1){6}}
\put(10,-3){\line(2,1){6}}
\put(16,3){\line(0,-1){6}}
\put(-2,1){\makebox(10,6)[r]{#3}}
\put(20,1){\makebox(10,6)[l]{#4}}
    \ifx#2R                        %rectifier diode
\put(16,0){\line(1,0){14}}
    \else \ifx#2C                 %varicap
\put(17,3){\line(0,-1){6}}
\put(17,0){\line(1,0){13}}
    \else \ifx#2Z                %zener diode
\put(16,3){\line(-1,0){2}}
\put(16,0){\line(1,0){14}}
    \else \ifx#2E                %esaki diode
\put(16,-3){\line(-1,0){2}}
\put(16,3){\line(-1,0){2}}
\put(16,0){\line(1,0){14}}
    \else \ifx#2S                %shottky diode
\put(16,-3){\line(1,0){2}}
\put(16,3){\line(-1,0){2}}
\put(16,0){\line(1,0){14}}
    \else \ifx#2L                %led diode
\multiput(12,4)(2,0){2}{\vector(1,1){4}}
\put(16,0){\line(1,0){14}}
    \else \ifx#2P                       %photo diode
\multiput(16,8)(2,0){2}{\vector(-1,-1){4}}
\put(16,0){\line(1,0){14}}
   \fi \fi  \fi  \fi  \fi \fi \fi \fi

  \ifx#1L                      %cathode left
\put(10,3){\line(0,-1){6}}
\put(16,3){\line(-2,-1){6}}
\put(16,-3){\line(-2,1){6}}
\put(16,3){\line(0,-1){6}}
\put(16,0){\line(1,0){14}}
\put(-2,1){\makebox(10,6)[r]{#3}}
\put(20,1){\makebox(10,6)[l]{#4}}
    \ifx#2R                      %rectifier diode
\put(0,0){\line(1,0){10}}
    \else \ifx#2C                %varicap
\put(9,3){\line(0,-1){6}}
\put(0,0){\line(1,0){9}}
    \else \ifx#2Z                %zener diode
\put(10,3){\line(1,0){2}}
\put(0,0){\line(1,0){10}}
    \else \ifx#2E                %esaki diode
\put(10,-3){\line(1,0){2}}
\put(10,3){\line(1,0){2}}
\put(0,0){\line(1,0){10}}
    \else \ifx#2S                %shottky diode
\put(10,-3){\line(-1,0){2}}
\put(10,3){\line(1,0){2}}
\put(0,0){\line(1,0){10}}
    \else \ifx#2L                %led diode
\multiput(12,4)(2,0){2}{\vector(-1,1){4}}
\put(0,0){\line(1,0){10}}
    \else \ifx#2P                  %photo diode
\multiput(8,8)(2,0){2}{\vector(1,-1){4}}
\put(0,0){\line(1,0){10}}
   \fi \fi  \fi  \fi  \fi \fi \fi \fi
}
%vertical diode
\newcommand{\vdiode}[4]{
  \ifx#1U                  %cathode up
\put(0,0){\line(0,1){10}}
\put(3,10){\line(-1,0){6}}
\put(3,10){\line(-1,2){3}}
\put(-3,10){\line(1,2){3}}
\put(3,16){\line(-1,0){6}}
\put(2,20){\makebox(10,6)[l]{#3}}
\put(2,1){\makebox(10,6)[l]{#4}}
    \ifx#2R                        %rectifier diode
\put(0,16){\line(0,1){14}}
    \else \ifx#2C                 %varicap
\put(3,17){\line(-1,0){6}}
\put(0,17){\line(0,1){13}}
    \else \ifx#2Z                %zener diode
\put(3,16){\line(0,-1){2}}
\put(0,16){\line(0,1){14}}
    \else \ifx#2E                %esaki diode
\put(-3,16){\line(0,-1){2}}
\put(3,16){\line(0,-1){2}}
\put(0,16){\line(0,1){14}}
    \else \ifx#2S                %shottky diode
\put(-3,16){\line(0,1){2}}
\put(3,16){\line(0,-1){2}}
\put(0,16){\line(0,1){14}}
    \else \ifx#2L                %led diode
\multiput(4,12)(0,2){2}{\vector(1,1){4}}
\put(0,16){\line(0,1){14}}
    \else \ifx#2P                       %photo diode
\multiput(8,16)(0,2){2}{\vector(-1,-1){4}}
\put(0,16){\line(0,1){14}}
   \fi \fi  \fi  \fi  \fi \fi \fi \fi

  \ifx#1D                      %cathode down
\put(3,10){\line(-1,0){6}}
\put(3,16){\line(-1,-2){3}}
\put(-3,16){\line(1,-2){3}}
\put(3,16){\line(-1,0){6}}
\put(0,16){\line(0,1){14}}
\put(2,1){\makebox(10,6)[l]{#3}}
\put(2,20){\makebox(10,6)[l]{#4}}
    \ifx#2R                      %rectifier diode
\put(0,0){\line(0,1){10}}
    \else \ifx#2C                %varicap
\put(3,9){\line(-1,0){6}}
\put(0,0){\line(0,1){9}}
    \else \ifx#2Z                %zener diode
\put(3,10){\line(0,1){2}}
\put(0,0){\line(0,1){10}}
    \else \ifx#2E                %esaki diode
\put(-3,10){\line(0,1){2}}
\put(3,10){\line(0,1){2}}
\put(0,0){\line(0,1){10}}
    \else \ifx#2S                %shottky diode
\put(-3,10){\line(0,-1){2}}
\put(3,10){\line(0,1){2}}
\put(0,0){\line(0,1){10}}
    \else \ifx#2L                %led diode
\multiput(4,12)(0,2){2}{\vector(1,-1){4}}
\put(0,0){\line(0,1){10}}
    \else \ifx#2P                  %photo diode
\multiput(8,8)(0,2){2}{\vector(-1,1){4}}
\put(0,0){\line(0,1){10}}
   \fi \fi  \fi  \fi  \fi \fi \fi \fi
}
%vertical triac
\newcommand{\vtriac}[3]{
\put(0,0){\line(0,1){10}}
\put(6,10){\line(-1,0){6}}
\put(6,10){\line(-1,2){3}}
\put(0,10){\line(1,2){3}}
\put(6,16){\line(-1,0){6}}
\put(0,16){\line(0,1){14}}
\put(0,10){\line(-1,0){6}}
\put(0,16){\line(-1,-2){3}}
\put(-6,16){\line(1,-2){3}}
\put(-6,16){\line(1,0){6}}
\put(0,0){\line(0,1){10}}
 \ifx#1A                         %gate down left
\put(2,20){\makebox(10,6)[l]{#2}}
\put(2,1){\makebox(10,6)[l]{#3}}
\put(0,10){\line(-1,-1){5}}
\put(-5,5){\line(-1,0){5}}
 \fi  \ifx#1B                    %gate up left
\put(2,20){\makebox(10,6)[l]{#2}}
\put(2,1){\makebox(10,6)[l]{#3}}
\put(0,16){\line(-1,1){4}}
\put(-4,20){\line(-1,0){6}}
 \fi  \ifx#1C                      %gate down right
\put(-12,20){\makebox(10,6)[r]{#2}}
\put(-12,1){\makebox(10,6)[r]{#3}}
\put(0,10){\line(1,-1){5}}
\put(5,5){\line(1,0){5}}
 \fi \ifx#1D                       %gate up right
\put(-12,20){\makebox(10,6)[r]{#2}}
\put(-12,1){\makebox(10,6)[r]{#3}}
\put(0,16){\line(1,1){4}}
\put(4,20){\line(1,0){6}}
 \fi
}
%horizontal triac
\newcommand{\htriac}[3]{
\put(0,0){\line(1,0){10}}
\put(10,0){\line(0,-1){6}}
\put(10,0){\line(2,-1){6}}
\put(10,-6){\line(2,1){6}}
\put(16,0){\line(0,-1){6}}
\put(16,0){\line(1,0){14}}
\put(10,0){\line(0,1){6}}
\put(16,6){\line(-2,-1){6}}
\put(16,0){\line(-2,1){6}}
\put(16,0){\line(0,1){6}}
 \ifx#1A                    %gate down left
\put(-2,1){\makebox(10,6)[r]{#2}}
\put(20,1){\makebox(10,6)[l]{#3}}
\put(10,0){\line(-1,-1){5}}
\put(5,-5){\line(0,-1){5}}
 \fi \ifx#1C                %gate down right
\put(-2,1){\makebox(10,6)[r]{#2}}
\put(20,1){\makebox(10,6)[l]{#3}}
\put(16,0){\line(1,-1){4}}
\put(20,-4){\line(0,-1){6}}
 \fi \ifx#1D                        %gate up right
\put(-2,-8){\makebox(10,6)[r]{#2}}
\put(20,-8){\makebox(10,6)[l]{#3}}
\put(16,0){\line(1,1){4}}
\put(20,4){\line(0,1){6}}
 \fi \ifx#1B                        %gate up left
\put(-2,-8){\makebox(10,6)[r]{#2}}
\put(20,-8){\makebox(10,6)[l]{#3}}
\put(10,0){\line(-1,1){4}}
\put(6,4){\line(0,1){6}}
 \fi
}
%diagonal thyristor
\newcommand{\dthyristor}[5]{
\ifx#1D                           %down oriented
\put(0,0){\line(1,-1){8}}
\put(10.5,-5.5){\line(-1,-1){5}}
      \ifx#2D                      %cathode down
\put(10.5,-5.5){\line(1,-3){2.5}}
\put(5.5,-10.5){\line(3,-1){7}}
      \fi \ifx#2U                  %cathode up
\put(10.5,-15.5){\line(-1,3){2.5}}
\put(15.5,-10.5){\line(-3,1){7}}
           \fi
\put(15.5,-10.5){\line(-1,-1){5}}
\put(13,-13){\line(1,-1){7}}

 \ifx#3A                           %gate down left
\put(4,-4){\makebox(10,6)[l]{#4}}
\put(20,-18){\makebox(10,6)[l]{#5}}
\put(13,-13){\line(0,-1){4}}
\put(13,-17){\line(-1,-1){4}}
 \fi   \ifx#3B                     %gate up left
\put(4,-4){\makebox(10,6)[l]{#4}}
\put(20,-18){\makebox(10,6)[l]{#5}}
\put(8,-8){\line(-1,0){6}}
\put(2,-8){\line(-1,-1){4}}
 \fi
 \ifx#3C                           %gate down right
\put(-8,-9){\makebox(10,6)[r]{#4}}
\put(2,-23){\makebox(10,6)[r]{#5}}
\put(13,-13){\line(1,0){4}}
\put(17,-13){\line(1,1){4}}
 \fi   \ifx#3D                     %gate up right
\put(-8,-9){\makebox(10,6)[r]{#4}}
\put(2,-23){\makebox(10,6)[r]{#5}}
\put(8,-8){\line(0,1){6}}
\put(8,-2){\line(1,1){4}}
\fi  \fi


\ifx#1U                            %up oriented
\put(0,0){\line(1,1){8}}
\put(10.5,5.5){\line(-1,1){5}}
      \ifx#2U                      %cathode up
\put(10.5,5.5){\line(1,3){2.5}}
\put(5.5,10.5){\line(3,1){7}}
      \fi \ifx#2D                  %cathode down
\put(10.5,15.5){\line(-1,-3){2.5}}
\put(15.5,10.5){\line(-3,-1){7}}
           \fi
\put(15.5,10.5){\line(-1,1){5}}
\put(13,13){\line(1,1){7}}

  \ifx#3A                          %gate down left
\put(18,11){\makebox(10,6)[l]{#4}}
\put(6,-1){\makebox(10,6)[l]{#5}}
\put(8,8){\line(-1,0){6}}
\put(2,8){\line(-1,1){4}}
  \fi  \ifx#3B                      %gate up left
\put(18,11){\makebox(10,6)[l]{#4}}
\put(6,-1){\makebox(10,6)[l]{#5}}
\put(13,13){\line(0,1){4}}
\put(13,17){\line(-1,1){4}}
 \fi  \ifx#3C                      %gate  down right
\put(3,18){\makebox(10,6)[r]{#4}}
\put(-10,1){\makebox(10,6)[r]{#5}}
\put(8,8){\line(0,-1){6}}
\put(8,2){\line(1,-1){4}}
 \fi  \ifx#3D                       %gate up right
\put(3,18){\makebox(10,6)[r]{#4}}
\put(-10,1){\makebox(10,6)[r]{#5}}
\put(13,13){\line(1,0){4}}
\put(17,13){\line(1,-1){4}}
 \fi \fi
}

%vertical thyristor
\newcommand{\vthyristor}[4]{
 \ifx#2A                          %gate down left
\put(1,2){\makebox(10,6)[l]{#3}}
\put(1,20){\makebox(10,6)[l]{#4}}
\put(0,10){\line(-1,-1){5}}
\put(-5,5){\line(-1,0){5}}
 \fi \ifx#2B                      %gate up left
\put(1,2){\makebox(10,6)[l]{#3}}
\put(1,20){\makebox(10,6)[l]{#4}}
\put(0,16){\line(-1,1){4}}
\put(-4,20){\line(-1,0){6}}
 \fi  \ifx#2C                   %gate down right
\put(-12,-2){\makebox(10,6)[r]{#3}}
\put(-12,20){\makebox(10,6)[r]{#4}}
\put(0,10){\line(1,-1){5}}
\put(5,5){\line(1,0){5}}
 \fi \ifx#2D                   %gate up right
\put(-12,-2){\makebox(10,6)[r]{#3}}
\put(-12,20){\makebox(10,6)[r]{#4}}
\put(0,16){\line(1,1){4}}
\put(4,20){\line(1,0){6}}
 \fi
   \ifx#1U                 %cathode up
\put(3,10){\line(-1,0){6}}
\put(3,10){\line(-1,2){3}}
\put(-3,10){\line(1,2){3}}
\put(3,16){\line(-1,0){6}}
   \fi \ifx#1D              %cathode down
\put(-3,10){\line(1,0){6}}
\put(3,16){\line(-1,-2){3}}
\put(-3,16){\line(1,-2){3}}
\put(-3,16){\line(1,0){6}}
  \fi
\put(0,0){\line(0,1){10}}
\put(0,16){\line(0,1){14}}
}
%horizontal thyristor
\newcommand{\hthyristor}[4]{
 \ifx#2A                           %gate down left
\put(-2,1){\makebox(10,6)[r]{#3}}
\put(20,1){\makebox(10,6)[l]{#4}}
\put(10,0){\line(-1,-1){5}}
\put(5,-5){\line(0,-1){5}}
 \fi \ifx#2C                      %gate down right
\put(-2,1){\makebox(10,6)[r]{#3}}
\put(20,1){\makebox(10,6)[l]{#4}}
\put(16,0){\line(1,-1){4}}
\put(20,-4){\line(0,-1){6}}
 \fi  \ifx#2B                      %gate up left
\put(-2,-7){\makebox(10,6)[r]{#3}}
\put(20,-7){\makebox(10,6)[l]{#4}}
\put(10,0){\line(-1,1){5}}
\put(5,5){\line(0,1){5}}
 \fi \ifx#2D                        %gate up right
\put(-2,-7){\makebox(10,6)[r]{#3}}
\put(20,-7){\makebox(10,6)[l]{#4}}
\put(16,0){\line(1,1){4}}
\put(20,4){\line(0,1){6}}
 \fi
   \ifx#1R                     %cathode right
\put(10,3){\line(0,-1){6}}
\put(10,3){\line(2,-1){6}}
\put(10,-3){\line(2,1){6}}
\put(16,3){\line(0,-1){6}}
   \fi \ifx#1L                 %cathode left
\put(10,-3){\line(0,1){6}}
\put(16,3){\line(-2,-1){6}}
\put(16,-3){\line(-2,1){6}}
\put(16,-3){\line(0,1){6}}
  \fi
\put(0,0){\line(1,0){10}}
\put(16,0){\line(1,0){14}}
}
%horizontal diac
\newcommand{\hdiac}[2]{
\put(-2,1){\makebox(10,6)[r]{#1}}
\put(20,1){\makebox(10,6)[l]{#2}}
\put(0,0){\line(1,0){10}}
\put(10,0){\line(0,-1){6}}
\put(10,0){\line(2,-1){6}}
\put(10,-6){\line(2,1){6}}
\put(16,0){\line(0,-1){6}}
\put(16,0){\line(1,0){14}}
\put(10,0){\line(0,1){6}}
\put(16,6){\line(-2,-1){6}}
\put(16,0){\line(-2,1){6}}
\put(16,0){\line(0,1){6}}
}
%vertical diac
\newcommand{\vdiac}[2]{
\put(0,0){\line(0,1){10}}
\put(6,10){\line(-1,0){6}}
\put(6,10){\line(-1,2){3}}
\put(0,10){\line(1,2){3}}
\put(6,16){\line(-1,0){6}}
\put(2,20){\makebox(10,6)[l]{#1}}
\put(2,1){\makebox(10,6)[l]{#2}}
\put(0,16){\line(0,1){14}}
\put(0,10){\line(-1,0){6}}
\put(0,16){\line(-1,-2){3}}
\put(-6,16){\line(1,-2){3}}
\put(-6,16){\line(1,0){6}}
\put(0,0){\line(0,1){10}}
}
%optic member
\newcommand{\opto}[3]{
 \ifx#1R
\put(0,0){\line(0,1){8}}
\put(-2,8){\line(1,0){4}}
\put(0,8){\line(-1,2){2}}
\put(0,8){\line(1,2){2}}
\put(-2,12){\line(1,0){4}}
\put(0,12){\line(0,1){8}}
\multiput(3,9)(0,2){2}{\vector(1,0){4}}
\multiput(10,8)(0.1,0){10}{\line(0,1){4}}
\put(15,0){\line(0,1){8}}
\put(15,12){\line(0,1){8}}
\put(11,10){\line(2,1){4}}
\put(11,10){\vector(2,-1){4}}
\put(0,10){\oval(10,10)[l]}
\put(15,10){\oval(10,10)[r]}
\multiput(0,5)(0,10){2}{\line(1,0){15}}
\put(-15,12){\makebox(10,6)[r]{#2}}
\put(-20,0){\makebox(15,6)[r]{#3}}
 \fi  \ifx#1L
\put(0,0){\line(0,1){8}}
\put(2,8){\line(-1,0){4}}
\put(0,8){\line(1,2){2}}
\put(0,8){\line(-1,2){2}}
\put(2,12){\line(-1,0){4}}
\put(0,12){\line(0,1){8}}
\multiput(-3,9)(0,2){2}{\vector(-1,0){4}}
\multiput(-10,8)(-0.1,0){10}{\line(0,1){4}}
\put(-15,0){\line(0,1){8}}
\put(-15,12){\line(0,1){8}}
\put(-11,10){\line(-2,1){4}}
\put(-11,10){\vector(-2,-1){4}}
\put(0,10){\oval(10,10)[r]}
\put(-15,10){\oval(10,10)[l]}
\multiput(0,5)(0,10){2}{\line(-1,0){15}}
\put(8,12){\makebox(10,6)[l]{#2}}
\put(5,0){\makebox(15,6)[l]{#3}}
 \fi
}
%operational amplifier
\newcommand{\opamp}[3]{
  \ifx#1R                      %right oriented
\multiput(0,0)(0,10){2}{\line(1,0){5}}
\put(25,5){\line(1,0){5}}
\put(5,-5){\line(0,1){20}}
\put(5,-5){\line(2,1){20}}
\put(5,15){\line(2,-1){20}}
\put(8,2){\makebox(10,6){#3}}     %label
  \ifx#2D                       %-input down
\put(7,0){\line(1,0){3}}
\put(7,7){\makebox(5,5)[l]{+}}
  \fi  \ifx#2U                  %-input up
\put(7,10){\line(1,0){3}}
\put(7,-2){\makebox(5,5)[l]{+}}
  \fi
   \fi  \ifx#1L                  %left oriented
\multiput(0,0)(0,10){2}{\line(-1,0){5}}
\put(-25,5){\line(-1,0){5}}
\put(-5,-5){\line(0,1){20}}
\put(-5,-5){\line(-2,1){20}}
\put(-5,15){\line(-2,-1){20}}
\put(-17,2){\makebox(10,6){#3}}
  \ifx#2A                        %-input down
\put(-7,0){\line(-1,0){3}}
\put(-12,7){\makebox(5,5)[r]{+}}
  \fi  \ifx#2B                   %-input up
\put(-7,10){\line(-1,0){3}}
\put(-12,-2){\makebox(5,5)[r]{+}}   %label
  \fi
   \fi
}


%%%%other basic devices (fuse, engine, generator, microphone
%%%%%earphone, loudspeaker, antenna, spark gap, pick up, taperecorder
%%%%head, fluorescent bulb, discharge lamp, glow bulb, bulb, bell,
%%%%buzzer, crystal, relay)
%vertical fuse
\newcommand{\vfuse}[2]{
\put(0,0){\line(0,1){20}}
\put(-2.5,5){\framebox(5,10)}
\put(4,12){\makebox(10,5)[l]{#1}}
\put(4,5){\makebox(10,5)[l]{#2}}
}
%horizontal fuse
\newcommand{\hfuse}[2]{
\put(0,0){\line(1,0){20}}
\put(5,-2.5){\framebox(10,5)}
\put(5,4){\makebox(10,5){#1}}
\put(5,-8){\makebox(10,5){#2}}
}
%vertical for engine or generator
\newcommand{\ve}[1]{
\put(0,0){\line(0,1){8}}
\multiput(-1,8)(0.1,0){20}{\line(0,1){2}}
\put(0,15){\circle{10}}
\multiput(-1,20)(0.1,0){20}{\line(0,1){2}}
\put(0,22){\line(0,1){8}}
 \ifx#1A
\put(-2.5,10){\makebox(5,5){$\sim$}}
 \fi \ifx#1D
\put(-2.5,10){\makebox(5,5){=}}
 \fi
}
%vertical engine
\newcommand{\vengine}[1]{
\ve{#1}
\put(-2.5,14){\makebox(5,5){M}}
}
%vertical generator
\newcommand{\vgenerator}[1]{
\ve{#1}
\put(-2.5,14){\makebox(5,5){G}}
}
%horizontal engine or generator
\newcommand{\he}[1]{
\put(0,0){\line(1,0){8}}
\multiput(8,-1)(0,0.1){20}{\line(1,0){2}}
\put(15,0){\circle{10}}
\multiput(20,-1)(0,0.1){20}{\line(1,0){2}}
\put(22,0){\line(1,0){8}}
 \ifx#1A
\put(12.5,-5){\makebox(5,5){$\sim$}}
 \fi \ifx#1D
\put(12.5,-5){\makebox(5,5){=}}
 \fi
}
%horizontal engine
\newcommand{\hengine}[1]{
\he{#1}
\put(12.5,-1){\makebox(5,5){M}}
}
%horizontal generator
\newcommand{\hgenerator}[1]{
\he{#1}
\put(12.5,-1){\makebox(5,5){G}}
}
%antenna
\newcommand{\antenna}[1]{
 \ifx#1G              %general
\put(0,0){\line(0,1){15}}
\put(0,10){\line(-1,2){2.5}}
\put(0,10){\line(1,2){2.5}}
 \fi  \ifx#1D         %dipole
\multiput(0,0)(5,0){2}{\line(0,1){10}}
\multiput(-10,10)(0,0.1){5}{\line(1,0){10}}
\multiput(5,10)(0,0.1){5}{\line(1,0){10}}
 \fi  \ifx#1F         %folded dipole
\multiput(0,0)(5,0){2}{\line(0,1){10}}
\put(-10,10){\line(1,0){10}}
\put(5,10){\line(1,0){10}}
\put(-10,14){\line(1,0){25}}
\put(-10,12){\oval(4,4)[l]}
\put(15,12){\oval(4,4)[r]}
 \fi
}
%pick up
\newcommand{\pickup}[3]{
\put(0,0){\line(0,1){10}}
\put(0,15){\circle{10}}
\put(0,20){\line(0,1){10}}
\multiput(-8,20)(0.1,0.1){5}{\line(2,-1){4}}
\put(8,12){\makebox(10,6)[l]{#3}}
\put(-18,12){\makebox(10,6)[r]{#2}}
 \ifx#1D                 %dynamic
\put(0,10){\line(0,1){3}}
\put(0,20){\line(0,-1){3}}
\multiput(0,14)(0,2){2}{\oval(2,2)[r]}
 \fi  \ifx#1C            %piezo
\put(0,10){\line(0,1){4.5}}
\put(0,20){\line(0,-1){4.5}}
\multiput(-2,14.5)(0,1){2}{\line(1,0){4}}
 \fi
}
%microphone
\newcommand{\microphone}[4]{
\put(0,0){\line(0,1){10}}
\put(0,15){\circle{10}}
\put(0,20){\line(0,1){10}}
  \ifx#1R                    %right
\multiput(5,10)(0.1,0){5}{\line(0,1){10}}
  \fi \ifx#1L                %left
\multiput(-5,10)(-0.1,0){5}{\line(0,1){10}}
  \fi
\put(8,12){\makebox(10,6)[l]{#4}}
\put(-18,12){\makebox(10,6)[r]{#3}}
  \ifx#2D                     %dynamic
\put(0,10){\line(0,1){3}}
\put(0,20){\line(0,-1){3}}
  \ifx#1R
\multiput(0,14)(0,2){2}{\oval(2,2)[r]}
  \fi \ifx#1L
\multiput(0,14)(0,2){2}{\oval(2,2)[l]}
      \fi
  \fi  \ifx#2C                %piezo
\put(0,10){\line(0,1){4.5}}
\put(0,20){\line(0,-1){4.5}}
\multiput(-2,14.5)(0,1){2}{\line(1,0){4}}
  \fi
}
%earphone
\newcommand{\earphone}[4]{
\put(0,0){\line(0,1){6.5}}
\put(-2,6.5){\framebox(4,7)}
\put(0,13.5){\line(0,1){6.5}}
 \ifx#1R
\multiput(2,5.5)(0.1,0){10}{\line(0,1){9.5}}
 \fi \ifx#1L
\multiput(-2,5.5)(-0.1,0){10}{\line(0,1){9.5}}
 \fi
\put(6,7){\makebox(10,6)[l]{#4}}
\put(-16,7){\makebox(10,6)[r]{#3}}
  \ifx#2D                     %dynamic
\put(0,6.5){\line(0,1){1.5}}
\put(0,13.5){\line(0,-1){1.5}}
  \ifx#1R
\multiput(0,9)(0,2){2}{\oval(2,2)[r]}
  \fi \ifx#1L
\multiput(0,9)(0,2){2}{\oval(2,2)[l]}
  \fi
  \fi \ifx#2C                 %crystall
\put(0,6.5){\line(0,1){3}}
\put(0,13.5){\line(0,-1){3}}
\multiput(-1,9.5)(0,1){2}{\line(1,0){2}}
  \fi
}
%loudspeaker
\newcommand{\loudspeaker}[3]{
\put(0,0){\line(0,1){6.5}}
\put(-2,6.5){\framebox(4,7)}
\put(0,13.5){\line(0,1){6.5}}
  \ifx#1R
\put(2,6.5){\line(2,-1){4}}
\put(2,13.5){\line(2,1){4}}
\put(6,4.5){\line(0,1){11}}
\put(8,7){\makebox(10,6)[l]{#3}}
\put(-14,7){\makebox(10,6)[r]{#2}}
  \fi \ifx#1L
\put(-2,6.5){\line(-2,-1){4}}
\put(-2,13.5){\line(-2,1){4}}
\put(-6,4.5){\line(0,1){11}}
\put(6,7){\makebox(10,6)[l]{#2}}
\put(-20,7){\makebox(10,6)[r]{#3}}
  \fi
}
%vertical crystal rezonator
\newcommand{\vcrystal}[2]{
\put(0,0){\line(0,1){8}}
\put(-4,8){\line(1,0){8}}
\put(-3,9){\framebox(6,2)}
\put(-4,12){\line(1,0){8}}
\put(0,12){\line(0,1){8}}
\put(2,0){\makebox(10,6)[l]{#1}}
\put(2,14){\makebox(10,6)[l]{#2}}
}
%horizontal crystal rezonator
\newcommand{\hcrystal}[2]{
\put(0,0){\line(1,0){8}}
\put(8,-4){\line(0,1){8}}
\put(9,-3){\framebox(2,6)}
\put(12,-4){\line(0,1){8}}
\put(12,0){\line(1,0){8}}
\put(-4,0){\makebox(10,6)[r]{#1}}
\put(14,0){\makebox(10,6)[l]{#2}}
}
%horizontal spark gap
\newcommand{\hgap}[1]{
\put(0,0){\vector(1,0){8}}
\put(20,0){\vector(-1,0){8}}
\put(5,-8){\makebox(10,6){#1}}
}
%vertical spark gap
\newcommand{\vgap}[1]{
\put(0,0){\vector(0,1){8}}
\put(0,20){\vector(0,-1){8}}
\put(3,8){\makebox(10,6)[l]{#1}}
}
%relay
\newcommand{\relay}[3]{
\put(0,0){\line(0,1){7}}
\put(-6,7){\framebox(12,6){#3}}
\put(0,13){\line(0,1){7}}
\put(2,0){\makebox(10,6){#2}}
 \ifx#1A                       %AC relay
\multiput(-6,7)(0,-0.1){8}{\line(1,0){12}}
\multiput(-6,13)(0,0.1){8}{\line(1,0){12}}
 \fi \ifx#1B                   %slow acting
\put(-12,7){\framebox(6,6)}
\put(-12,13){\line(1,-1){6}}
\put(-12,7){\line(1,1){6}}
 \fi  \ifx#1C                %slow releasing
\put(-12,7){\framebox(6,6)}
\multiput(-12,7)(0,0.1){61}{\line(1,0){6}}
 \fi  \ifx#1P                %polarized relay
\put(-12,7){\framebox(6,6){N}}
\put(6,7){\framebox(6,6){S}}
 \fi  \ifx#1M                %mettering relay
\put(-12,7){\framebox(6,6)}
\put(-9,10){\circle{3}}
 \fi
}
%vertical glow bulb
\newcommand{\vglow}[2]{
\put(0,0){\line(0,1){9}}
\put(0,10){\circle{10}}
\put(0,11){\line(0,1){9}}
\put(-3,9){\line(1,0){6}}
\put(-3,11){\line(1,0){6}}
\put(3,15){\makebox(10,6)[l]{#2}}
\put(3,-2){\makebox(10,6)[l]{#1}}
}
%horizontal glow bulb
\newcommand{\hglow}[2]{
\put(0,0){\line(1,0){9}}
\put(10,0){\circle{10}}
\put(11,0){\line(1,0){9}}
\put(9,-3){\line(0,1){6}}
\put(11,-3){\line(0,1){6}}
\put(15,3){\makebox(10,6)[l]{#2}}
\put(-5,3){\makebox(10,6)[r]{#1}}
}
% buzzer
\newcommand{\buzzer}[2]{
\put(0,0){\line(1,0){8}}
\put(12,0){\line(1,0){8}}
\put(8,0){\line(0,1){2}}
\put(12,0){\line(0,1){2}}
\put(10,5){\oval(7,7)[b]}
\put(6.5,5){\line(1,0){7}}
\put(5,-8){\makebox(10,6)[c]{#2}}
\put(5,8){\makebox(10,6)[c]{#1}}
}
% bell
\newcommand{\bell}[2]{
\put(0,0){\line(1,0){8}}
\put(12,0){\line(1,0){8}}
\put(8,0){\line(0,1){2}}
\put(12,0){\line(0,1){2}}
\put(10,2){\oval(7,7)[t]}
\put(6.5,2){\line(1,0){7}}
\put(5,-8){\makebox(10,6)[c]{#2}}
\put(5,8){\makebox(10,6)[c]{#1}}
}
%vertical fluorescent lamp
\newcommand{\vflamp}[2]{
\put(-1,5){\framebox(7,20)}
\put(2.5,5){\oval(5,5)[t]}
\put(2.5,25){\oval(5,5)[b]}
\put(0,12.5){\line(1,1){5}}
\put(0,17.5){\line(1,-1){5}}
\put(0,0){\line(0,1){5}}
\put(0,25){\line(0,1){5}}
\put(5,0){\line(0,1){5}}
\put(5,25){\line(0,1){5}}
\put(-12,12){\makebox(10,6)[r]{#2}}
\put(8,12){\makebox(10,6)[l]{#1}}
}
%horizontal flourescent lamp
\newcommand{\hflamp}[2]{
\put(5,-1){\framebox(20,7)}
\put(5,2.5){\oval(5,5)[r]}
\put(25,2.5){\oval(5,5)[l]}
\put(12.5,0){\line(1,1){5}}
\put(17.5,0){\line(-1,1){5}}
\put(0,0){\line(1,0){5}}
\put(25,0){\line(1,0){5}}
\put(0,5){\line(1,0){5}}
\put(25,5){\line(1,0){5}}
\put(12,-8){\makebox(10,6)[l]{#2}}
\put(12,8){\makebox(10,6)[l]{#1}}
}
%vertical discharge lamp
\newcommand{\vdlamp}[2]{
\put(0,7){\oval(6,6)[b]}
\put(0,13){\oval(6,6)[t]}
\put(3,7){\line(0,1){7}}
\put(-3,7){\line(0,1){7}}
\put(-2,12){\line(1,-1){4}}
\put(2,12){\line(-1,-1){4}}
\put(0,0){\line(0,1){4}}
\put(0,16){\line(0,1){4}}
\put(4,7){\makebox(6,6)[[l]{#1}}
\put(-10,7){\makebox(6,6)[l]{#2}}
}
%horizontal discharge lamp
\newcommand{\hdlamp}[2]{
\put(7,0){\oval(6,6)[l]}
\put(13,0){\oval(6,6)[r]}
\put(7,3){\line(1,0){7}}
\put(7,-3){\line(1,0){7}}
\put(8,2){\line(1,-1){4}}
\put(12,2){\line(-1,-1){4}}
\put(0,0){\line(1,0){4}}
\put(16,0){\line(1,0){4}}
\put(7,4){\makebox(6,6)[[r]{#1}}
\put(7,-10){\makebox(6,6)[l]{#2}}
}
%horizontal bulb
\newcommand{\hbulb}[2]{
\put(0,0){\line(1,0){5}}
\put(15,0){\line(1,0){5}}
\put(10,0){\circle{10}}
\put(6.5,3.5){\line(1,-1){7}}
\put(13.5,3.5){\line(-1,-1){7}}
\put(-2,0){\makebox(6,6)[[r]{#1}}
\put(17,0){\makebox(6,6)[l]{#2}}
}
%vertical bulb
\newcommand{\vbulb}[2]{
\put(0,10){\circle{10}}
\put(-3.5,13.5){\line(1,-1){7}}
\put(3.5,13.5){\line(-1,-1){7}}
\put(0,0){\line(0,1){5}}
\put(0,15){\line(0,1){5}}
\put(3,15){\makebox(6,6)[[l]{#1}}
\put(3,0){\makebox(6,6)[l]{#2}}
}
%diagonal bulb
\newcommand{\dbulb}[3]{
   \ifx#1D
\put(0,0){\line(1,-1){6.5}}
\put(20,-20){\line(-1,1){6.5}}
\put(10,-10){\circle{10}}
\put(10,-5){\line(0,-1){10}}
\put(5,-10){\line(1,0){10}}
\put(5,-5){\makebox(6,6)[[l]{#2}}
\put(18,-18){\makebox(6,6)[l]{#3}}
    \fi \ifx#1U
\put(0,0){\line(1,1){6.5}}
\put(20,20){\line(-1,-1){6.5}}
\put(10,10){\circle{10}}
\put(10,5){\line(0,1){10}}
\put(5,10){\line(1,0){10}}
\put(5,-1){\makebox(6,6)[[l]{#2}}
\put(18,12){\makebox(6,6)[l]{#3}}
     \fi
}
%tape recorder head
\newcommand{\mghead}[2]{
\put(0,0){\vind{L}{}{}{0}}
\put(-15,1){\makebox(10,6){#2}}
\put(-9,15){
\put(0,2){\oval(10,10)[t]}
\put(0,-2){\oval(10,10)[b]}
\put(5,-2){\line(0,1){4}}
\put(0,1.9){\oval(9.9,9.9)[t]}
\put(0,-1.9){\oval(9.9,9.9)[b]}
\put(4.9,-1.9){\line(0,1){3.9}}
\put(0,1.8){\oval(9.8,9.8)[t]}
\put(0,-1.8){\oval(9.8,9.8)[b]}
\put(4.8,-1.8){\line(0,1){3.8}}
\put(0,1.7){\oval(9.7,9.7)[t]}
\put(0,-1.7){\oval(9.7,9.7)[b]}
\put(4.7,-1.7){\line(0,1){3.7}}
\put(0,1.6){\oval(9.6,9.6)[t]}
\put(0,-1.6){\oval(9.6,9.6)[b]}
\put(0,1.5){\oval(9.5,9.5)[t]}
\put(0,-1.5){\oval(9.5,9.5)[b]}}
   \ifx#1R                     %recording head
\put(-13,15){\vector(-1,0){5}}
   \fi  \ifx#1P                %playing head
\put(-15,15){\vector(1,0){5}}
   \fi  \ifx#1C                %combined head
\put(-13,15){\vector(-1,0){5}}
\put(-15,15){\vector(1,0){5}}
   \fi  \ifx#1E                %erasing head
\put(-16,17){\line(1,-1){4}}
\put(-16,13){\line(1,1){4}}
   \fi
}

%%%switch, measuring device%%%%%%%%%%%%
%vertical over switch
\newcommand{\voverswitch}[3]{
 \ifx#2D
\put(0,0){\circle*{1.5}}
  \ifx#1R
\multiput(0,0)(0.1,-0.1){3}{\line(1,-3){1.5}}
  \fi \ifx#1L
\multiput(0,0)(-0.1,-0.1){3}{\line(-1,-3){1.5}}
       \fi
\put(3,-4){\line(-1,0){1.5}}
\put(3,-4){\line(0,-1){6}}
\put(-3,-4){\line(1,0){1.5}}
\put(-3,-4){\line(0,-1){6}}
\put(5,-3){\makebox(6,-6)[l]{#3}}
 \fi \ifx#2U
\put(0,0){\circle*{1.5}}
  \ifx#1R
\multiput(0,0)(0.1,0.1){3}{\line(1,3){1.5}}
  \fi \ifx#1L
\multiput(0,0)(-0.1,0.1){3}{\line(-1,3){1.5}}
       \fi
\put(3,4){\line(-1,0){1.5}}
\put(3,4){\line(0,1){6}}
\put(-3,4){\line(1,0){1.5}}
\put(-3,4){\line(0,1){6}}
\put(5,3){\makebox(6,6)[l]{#3}}
 \fi
}
%horizontal over switch
\newcommand{\hoverswitch}[3]{
 \ifx#2R         %right oriented
\put(0,0){\circle*{1.5}}
  \ifx#1U        %switch is on up
\multiput(0,0)(-0.1,0.1){3}{\line(3,1){5}}
  \fi \ifx#1D    %switch is on down
\multiput(0,0)(0.1,-0.1){3}{\line(3,-1){5}}
       \fi
\put(4,3){\line(0,-1){1.5}}
\put(4,3){\line(1,0){6}}
\put(4,-3){\line(0,1){1.5}}
\put(4,-3){\line(1,0){6}}
\put(0,-4){\makebox(6,-6)[l]{#3}}  %label
 \fi \ifx#2L          %left oriented
\put(0,0){\circle*{1.5}}
  \ifx#1U            %switch is on up
\multiput(0,0)(0.1,0.1){3}{\line(-3,1){5}}
  \fi \ifx#1D       %switch is on down
\multiput(0,0)(0.1,-0.1){3}{\line(-3,-1){5}}
       \fi
\put(-4,3){\line(0,-1){1.5}}
\put(-4,3){\line(-1,0){6}}
\put(-4,-3){\line(0,1){1.5}}
\put(-4,-3){\line(-1,0){6}}
\put(-8,-4){\makebox(6,-6)[r]{#3}}   %label
 \fi
}
%horizontal switch
\newcommand{\hswitch}[2]{
\put(0,0){\circle*{1.5}}
  \ifnum#1=1                   %switch on
\multiput(0,0)(-0.1,0.1){3}{\line(3,1){5}}
  \fi \ifnum#1=0               %switch off
\multiput(0,0)(-0.1,0.1){3}{\line(2,1){5}}
       \fi
\put(4,0){\line(0,1){1}}
\put(4,0){\line(1,0){6}}
\put(4,0){\makebox(6,-6)[l]{#2}} %label
}
%vertical switch
\newcommand{\vswitch}[2]{
\put(0,0){\circle*{1.5}}
  \ifnum#1=1               %switch on
\multiput(0,0)(0.1,-0.1){3}{\line(1,-3){1.5}}
  \fi \ifnum#1=0           %switch off
\multiput(0,0)(0.1,-0.1){3}{\line(1,-2){2.5}}
       \fi
\put(0,-4){\line(1,0){1}}
\put(0,-4){\line(0,-1){6}}
\put(-7,-4){\makebox(6,-6)[r]{#2}}  %label
}

%diagonal measuring instrument
\newcommand{\dmeasure}[2]{
  \ifx#1D
\put(0,0){\line(1,-1){11.5}}
\put(15,-15){\circle{10}}
\put(10.25,-20){\makebox(10,10){#2}}
\put(18.5,-18.5){\line(1,-1){11.5}}
  \else \ifx#1U
\put(0,0){\line(1,1){11.5}}
\put(15,15){\circle{10}}
\put(10.25,10){\makebox(10,10){#2}}
\put(18.5,18.5){\line(1,1){11.5}}
  \fi \fi
}

%%%%basic pasive devices (source, resistor, capacitor, inductor)%%%%
%diagonal source
\newcommand{\dsrc}[3]{
\ifx#1U         %first diagonal
\put(0,0){\line(1,1){11.5}}
\put(15,15){\circle{10}}
\put(18.5,18.5){\line(1,1){11.5}}
\put(3,20){\makebox(10,6){#2}}    %label
\put(16,3){\makebox(10,6){#3}}    %label
 \fi \ifx#1D          %second diagonal
\put(0,0){\line(1,-1){11.5}}
\put(15,-15){\circle{10}}
\put(18.5,-18.5){\line(1,-1){11.5}}
\put(20,-10){\makebox(10,6){#2}}   %label
\put(0,-25){\makebox(10,6){#3}}    %label
\fi
}
%diagonal voltage source
\newcommand{\dsourcev}[4]{
\put(0,0){\dsrc{#1}{#3}{#4}}
\ifx#1U   %if source up right oriented
\ifx#2U        % arrow up oriented
\put(7,16){\vector(1,1){7}}
   \fi \ifx#2D    % arrow down oriented
\put(14,24){\vector(-1,-1){7}}
\fi \fi
\ifx#1D  %if source down right oriented
\ifx#2U                 %arrow up oriented
\put(23,-13){\vector(-1,1){7}}
   \fi \ifx#2D        %arrow down oriented
\put(17,-6){\vector(1,-1){7}}
\fi \fi
}
%diagonal current source
\newcommand{\dsourcec}[4]{
\put(0,0){\dsrc{#1}{#3}{#4}}
\ifx#1U   %if source up right oriented
\ifx#2U        % arrow up oriented
\put(13,13){\vector(1,1){4}}
   \fi \ifx#2D    % arrow down oriented
\put(17,17){\vector(-1,-1){4}}
\fi \fi
\ifx#1D  %if source down right oriented
\ifx#2U                 %arrow up oriented
\put(17,-17){\vector(-1,1){4}}
   \fi \ifx#2D        %arrow down oriented
\put(13,-13){\vector(1,-1){4}}
\fi \fi
}
%horizontal source
\newcommand{\hsr}[1]{
\put(0,0){\line(1,0){10}}
\put(15,0){\circle{10}}
\put(20,0){\line(1,0){10}}
\put(11,-12){\makebox(10,6){#1}}   %label
}
%horizontal voltage source
\newcommand{\hsourcev}[3]{
\put(0,0){\hsr{#3}}
\put(11,10){\makebox(10,6){#2}}    %label
\ifx#1R                        %arrow right oriented
\put(10,8){\vector(1,0){10}}
   \else \ifx#1L              %arrow left oriented
\put(20,8){\vector(-1,0){10}}
\fi \fi
}
%horizontal current source
\newcommand{\hsourcec}[3]{
\put(0,0){\hsr{#3}}
\put(11,5){\makebox(10,6){#2}}    %label
\ifx#1R                        %arrow right oriented
\put(13,0){\vector(1,0){5}}
   \else \ifx#1L              %arrow left oriented
\put(17,0){\vector(-1,0){5}}
\fi \fi
}
%vertical source
\newcommand{\vsrc}[1]{
\put(0,0){\line(0,1){10}}
\put(0,15){\circle{10}}
\put(0,20){\line(0,1){10}}
\put(6,12){\makebox(10,6){#1}}    %label
}
%vertical voltage source
\newcommand{\vsourcev}[3]{
\put(0,0){\vsrc{#3}}
\put(-17,12){\makebox(10,6){#2}}  %label
\ifx#1U                           %arrow up oriented
\put(-7,10){\vector(0,1){10}}
  \else \ifx#1D                   %arrow down oriented
\put(-7,20){\vector(0,-1){10}}
\fi \fi
}
%vertical current source
\newcommand{\vsourcec}[3]{
\put(0,0){\vsrc{#3}}
\put(-15,12){\makebox(10,6){#2}}  %label
\ifx#1U                           %arrow up oriented
\put(0,13){\vector(0,1){5}}
  \else \ifx#1D                   %arrow down oriented
\put(0,17){\vector(0,-1){5}}
\fi \fi
}
%vertical measuring instrument
\newcommand{\vmeasure}[1]{
\put(0,0){\line(0,1){10}}
\put(0,15){\circle{10}}
\put(0,20){\line(0,1){10}}
\put(-4.75,10){\makebox(10,10){#1}}  %label
}
%horizontal measuring instrument
\newcommand{\hmeasure}[1]{
\put(0,0){\line(1,0){10}}
\put(15,0){\circle{10}}
\put(20,0){\line(1,0){10}}
\put(10,-4.75){\makebox(10,10){#1}}    %label
}
%horizontal transformer
\newcommand{\htrafo}[3]{
\put(0,0){\hind{U}{}{}{#3}}  %label
    \ifx#1Y        %transformer with core
      \ifx#2I           %iron core
  \put(10,4.5){\hcore{10}{I}}
      \else \ifx#2F     %ferrit core
  \put(10,4.5){\hcore{3}{F}}
      \fi \fi
    \fi
 \put(0,10){\hind{D}{}{}{#3}}    %label
}
%vertical transformer
\newcommand{\vtrafo}[3]{
\put(0,0){\vind{R}{}{}{#3}}   %label
   \ifx#1Y            %transformer with core
    \ifx#2I           %iron core
  \put(4.5,10){\vcore{10}{I}}
    \else \ifx#2F     %ferrit core
  \put(4.5,10){\vcore{3}{F}}
    \fi  \fi
    \fi
  \put(10,0){\vind{L}{}{}{#3}}
}
%diagonal coil core
\newcommand{\dcore}[3]{
\ifx#1D                    %down oriented
  \ifx#3I          %iron core
\multiput(0,0)(0.1,0.1){6}{\line(1,-1){#2}}
  \else \ifx#3F    %ferrit core
\multiput(0,0)(5,-5){#2}{\multiput(0,0)(0.1,0.1){6}{\line(1,-1){4}}}
   \fi \fi
 \else \ifx#1U             %up oriented
  \ifx#3I         %iron core
\multiput(0,0)(0.1,-0.1){6}{\line(1,1){#2}}
  \else \ifx#3F   %ferrit core
\multiput(0,0)(5,5){#2}{\multiput(0,0)(0.1,-0.1){6}{\line(1,1){4}}}
  \fi \fi
\fi \fi
}
%vertical coil core
\newcommand{\vcore}[2]{
 \ifx#2I            %iron core
\multiput(0,0)(0.1,0){10}{\line(0,1){#1}}
 \else \ifx#2F      %ferrit core
\multiput(0,0)(0,4){#1}{\multiput(0,0)(0.1,0){10}{\line(0,1){3}}}
 \fi \fi
}
%horizontal coil core
\newcommand{\hcore}[2]{
 \ifx#2I             %iron core
\multiput(0,0)(0,0.1){10}{\line(1,0){#1}}
 \else \ifx#2F       %ferrit core
\multiput(0,0)(4,0){#1}{\multiput(0,0)(0,0.1){10}{\line(1,0){3}}}
 \fi \fi
}
%\horizontal inductor
\newcommand{\hind}[4]{
\put(0,0){\line(1,0){9}}
\ifx#1U               %up arces
\multiput(11,0)(4,0){3}{\oval(4,4)[t]}
\put(-1,-7){\makebox(10,6)[r]{#2}}  %label
\put(22,-7){\makebox(10,6)[l]{#3}}  %label
  \ifnum#4=1            %variable inducance
\put(12,7){\line(1,-2){5}}
\put(15.25,-4.25){\line(2,1){4}}
  \fi
\else \ifx#1D         %down arces
\multiput(11,0)(4,0){3}{\oval(4,4)[b]}
\put(-1,0){\makebox(10,6)[r]{#2}}
\put(22,0){\makebox(10,6)[l]{#3}}
 \ifnum#4=1            %variable inductance
\put(12,-7){\line(1,2){5}}
\put(15.25,4.25){\line(2,-1){4}}
  \fi
\fi \fi
\put(21,0){\line(1,0){9}}
}
%vertical inductor
\newcommand{\vind}[4]{
\put(0,0){\line(0,1){9}}
\ifx#1L               %left arces
\multiput(0,11)(0,4){3}{\oval(4,4)[l]}
\put(4,21){\makebox(10,6)[l]{#2}}  %label
\put(4,4){\makebox(10,6)[l]{#3}}   %label
   \ifnum#4=1           %variable inductance
 \put(4,18){\line(-2,-1){10}}
 \put(3,20){\line(1,-2){2}}
    \fi
\else \ifx#1R        %right arces
\multiput(0,11)(0,4){3}{\oval(4,4)[r]}
\put(-13,21){\makebox(10,6)[r]{#2}}
\put(-13,4){\makebox(10,6)[r]{#3}}
    \ifnum#4=1           %variable inductance
 \put(-4,13){\line(2,1){10}}
 \put(-5,15){\line(1,-2){2}}
    \fi
\fi \fi
\put(0,21){\line(0,1){9}}
}
%diagonal inductor
\newcommand{\dind}[5]{
\ifx#1D                 %down oriented
\put(0,0){\line(1,-1){7}}
\put(14.5,-14.5){\line(1,-1){5.5}}
       \ifx#2R          %right arces
\multiput(7,-7)(2.5,-2.5){3}{\bezier{40}(0,0)(3.5,1)(2.5,-2.5)}
\put(-7,-9){\makebox(10,6)[r]{#3}}  %label
\put(3,-21){\makebox(10,6)[r]{#4}}  %label
        \ifnum#5=1          %variable inductance
    \put(5,-10.5){\line(1,0){12}}
    \put(5,-8.5){\line(0,-1){4}}
      \fi
    \fi
       \ifx#2L          %left arces
\multiput(7,-7)(2.5,-2.5){3}{\bezier{40}(0,0)(-1,-3.5)(2.5,-2.5)}
\put(5,-5){\makebox(10,6)[l]{#3}}   %label
\put(18,-18){\makebox(10,6)[l]{#4}} %label
       \ifnum#5=1          %variable inductance
    \put(15,-11){\line(-1,0){12}}
    \put(15,-9){\line(0,-1){4}}
      \fi
  \fi
\fi
\ifx#1U                  %up oriented
\put(0,0){\line(1,1){7}}
\put(14.5,14.5){\line(1,1){5.5}}
   \ifx#2R               %right arces
\multiput(7,7)(2.5,2.5){3}{\bezier{40}(0,0)(3.5,-1)(2.5,2.5)}
\put(-6,3){\makebox(10,6)[r]{#4}}    %label
\put(3,14){\makebox(10,6)[r]{#3}}    %label
    \ifnum#5=1              %variable inductance
  \put(6,11){\line(1,0){12}}
  \put(6,13){\line(0,-1){4}}
    \fi
    \fi
  \ifx#2L                %left arces
\multiput(7,7)(2.5,2.5){3}{\bezier{40}(0,0)(-1,3.5)(2.5,2.5)}
\put(7,-1){\makebox(10,6)[l]{#4}}   %label
\put(18,10){\makebox(10,6)[l]{#3}}  %label
        \ifnum#5=1          %variable inductance
     \put(15,11){\line(-1,0){12}}
     \put(15,13){\line(0,-1){4}}
        \fi
   \fi
\fi
}
%horizontal capacitor
\newcommand{\hcap}[4]{
\put(0,0){\line(1,0){14}}
\multiput(14,3)(0.1,0){5}{\line(0,-1){6}}
\multiput(15.5,3)(0.1,0){5}{\line(0,-1){6}}
\put(16,0){\line(1,0){14}}
\put(0,0){\makebox(10,6)[r]{#1}}    %label
\put(20,0){\makebox(10,6)[l]{#2}}   %label
\ifx#4L                      %if electrolytic cap. + electrode left
\put(9,-5){\makebox(5,5){+}}
 \else \ifx#4R               %if electrolytic cap. + electrode right
\put(16,-5){\makebox(5,5){+}}
 \fi \fi
\ifnum#3=1              % capacitor adjustable by tool
\put(18,-3){\line(-1,1){6}}
\put(9.5,0.5){\makebox(5,5){/}}
 \else \ifnum#3=4       %capacitor adjustable
\put(18,-3){\vector(-1,1){7}}
 \fi \fi
  }
%vertical capacitor
\newcommand{\vcap}[4]{
\put(0,0){\line(0,1){14}}
\multiput(-3,14)(0,0.1){5}{\line(1,0){6}}
\multiput(-3,15.5)(0,0.1){5}{\line(1,0){6}}
\put(0,16){\line(0,1){14}}
\put(2,20){\makebox(10,6){#1}}  %label
\put(2,5){\makebox(10,6){#2}}   %label
 \ifnum#3=1                %cap. adjustable by tool
\put(2.5,12.5){\line(-1,1){6}}
\put(-6,16){\makebox(5,5){/}}
 \else \ifnum#3=4             %cap. adjustable
\put(-3,12){\vector(1,1){7}}
 \fi \fi
\ifx#4D        % if electolytic cap. + electrode up
\put(-5,9){\makebox(5,5){+}}
 \else \ifx#4U                % + electrode down
\put(-5,16){\makebox(5,5){+}}
 \fi \fi
  }
%diagonal capacitor
\newcommand{\dcap}[5]{
\ifx#1U          % up right oriented
\put(0,0){\line(1,1){9}}
\multiput(7,11.5)(0.1,0.1){5}{\line(1,-1){4.5}}
\multiput(8.25,12.75)(0.1,0.1){5}{\line(1,-1){4.5}}
\put(11,11){\line(1,1){9}}
\put(14,10){\makebox(10,6){#2}}  %label
\put(5,0){\makebox(10,6){#3}}    %label
  \ifnum#4=1                    %cap. adjustable with tool
\put(5,10){\line(1,0){10}}
\put(15,8){\line(0,1){4}}
  \else \ifnum#4=4             %cap. adjustable
\put(5,10){\vector(1,0){12}}
   \fi \fi
  \ifx#5D                      % if electrolytic cap. + electode down
\put(2.5,7){\makebox(5,5){+}}
  \else \ifx#5U                % if electrolytic cap. + electode up
\put(8.5,12.5){\makebox(5,5){+}}
  \fi \fi
\fi
\ifx#1D                      % down right oriented
\put(0,0){\line(1,-1){9}}
\multiput(7,-11.5)(0.1,-0.1){5}{\line(1,1){4.5}}
\multiput(8.25,-12.75)(0.1,-0.1){5}{\line(1,1){4.5}}
\put(11,-11){\line(1,-1){9}}
\put(5,-4){\makebox(10,6){#2}}    %label
\put(15,-15){\makebox(10,6){#3}}  %label
  \ifnum#4=1                        %cap. adjustable with tool
\put(10,-15){\line(0,1){10}}
\put(8,-5){\line(1,0){4}}
  \else \ifnum#4=4            %cap. adjustable
\put(10,-15){\vector(0,1){11}}
  \fi \fi
 \ifx#5U             % if electrolytic cap. + electrode up
\put(3,-12){\makebox(5,5){+}}
 \else \ifx#5D       % if electrolytic cap. + electrode down
\put(8.5,-17.5){\makebox(5,5){+}}
 \fi \fi
\fi
}


%horizontal rezistor
\newcommand{\hrez}[3]{
\put(0,0){\line(1,0){10}}
\put(10,-2){\framebox(10,4){}\put(0,2){\line(1,0){10}}}
\put(20,3){\makebox(10,6)[l]{#1}}       %label
\put(20,-8){\makebox(10,6)[l]{#2}}      %label
\ifnum#3=1           % rez. adjustable by tool (medium pin down oriented)
\put(12,-6){\line(1,3){4}}
\put(14,7){\line(3,-1){4}}
\else \ifnum#3=2     % rez. adjustable by tool (medium pin up oriented)
\put(12,6){\line(1,-3){4}}
\put(14,-7){\line(3,1){4}}
\else \ifnum#3=3     % rez. adjustable by tool (medium pin shortly
                                                        %conected)
\put(12,6){\line(1,-3){4}}
\put(14,-7){\line(3,1){4}}
\put(12,6){\line(-1,0){4}}
\put(8,6){\line(0,-1){6}}
\put(8,0){\node}
\else \ifnum#3=4       % rez. adjustable (medium pin down oriented)
\put(12,-6){\vector(1,3){4}}
\else \ifnum#3=5       % rez. adjustable (medium pin up oriented)
\put(12,6){\vector(1,-3){4}}
\else \ifnum#3=6       % rez. adjustable (medium pin shortly conected)
\put(12,6){\vector(1,-3){4}}
\put(12,6){\line(-1,0){4}}
\put(8,6){\line(0,-1){6}}
\put(8,0){\node}
\fi \fi \fi \fi \fi \fi
  }
%vertical rezistor
\newcommand{\vrez}[3]{
\put(0,0){\line(0,1){10}}
\put(-2,10){\framebox(4,10){}\put(-2,10){\line(0,1){10}}}
\put(2,20){\makebox(10,6){#1}}  %label
\put(2,5){\makebox(10,6){#2}}   %label
\ifnum#3=1          % rez. adjustable by tool (medium pin left oriented)
\put(-6,12){\line(3,1){12}}
\put(5,18){\line(1,-2){2}}
\else \ifnum#3=2    % rez. adjustable by tool (medium pin right oriented)
\put(-6,18){\line(3,-1){12}}
\put(-7,16){\line(1,2){2}}
\else \ifnum#3=3   % rez. adjustable by tool (medium pin shortly
                                                        %conected)
\put(-6,12){\line(3,1){12}}
\put(5,18){\line(1,-2){2}}
\put(-6,12){\line(0,-1){4}}
\put(-6,8){\line(1,0){6}}
\put(0,8){\node}
\else \ifnum#3=4       % rez. adjustable (medium pin left oriented)
\put(-6,12){\vector(3,1){12}}
\else \ifnum#3=5       % rez. adjustable (medium pin right oriented)
\put(6,12){\vector(-3,1){12}}
\else \ifnum#3=6      % rez. adjustable (medium pin shortly conected)
\put(-6,12){\vector(3,1){12}}
\put(-6,12){\line(0,-1){4}}
\put(-6,8){\line(1,0){6}}
\put(0,8){\node}
\fi \fi \fi \fi \fi \fi
  }
%diagonal rezistor
\newcommand{\drez}[4]{
\ifx#1U      % up left oriented
\put(0,0){\line(1,1){7}\put(2.2,5.2){\line(-1,1){4}}
\put(-1.9,9){\line(1,1){7}}\put(2.2,5){\line(1,1){7}}
\put(9,12){\line(-1,1){4}}\put(7,14){\line(1,1){6}}}
\put(17,12){\makebox(10,6){#2}}  %label
\put(2,-2){\makebox(10,6){#3}}   %label
      \ifnum#4=1        % rez. adjustable by tool (medium pin left oriented)
\put(2,10){\line(1,0){16}}
\put(18,12){\line(0,-1){4}}
      \fi \ifnum#4=2    % rez. adjustable by tool (medium pin right oriented)
\put(2,10){\line(1,0){16}}
\put(2,12){\line(0,-1){4}}
      \fi \ifnum#4=3   % rez. adjustable by tool (medium pin shortly
                                                        %conected)
\put(2,10){\line(1,0){16}}
\put(18,12){\line(0,-1){4}}
\put(2,10){\line(0,-1){4}}
\put(2,6){\line(1,0){4}}
\put(6,6){\node}
      \fi \ifnum#4=4         % rez. adjustable (medium pin left oriented)
\put(2,10){\vector(1,0){16}}
      \fi \ifnum#4=5         % rez. adjustable (medium pin right oriented)
\put(18,10){\vector(-1,0){16}}
      \fi \ifnum#4=6         % rez. adjustable (medium pin shortly conected)
\put(2,10){\vector(1,0){16}}
\put(2,10){\line(0,-1){4}}
\put(2,6){\line(1,0){4}}
\put(6,6){\node}
       \fi   \fi

\ifx#1D              %down right oriented
\put(0,0){\line(1,-1){7}\put(-1.9,-9){\line(1,1){4}}
\put(2,-4.9){\line(1,-1){7}}\put(-1.9,-9){\line(1,-1){7}}}
\put(12,-16){\line(1,1){4}\put(-2,2){\line(1,-1){6}}}
\put(4,-5){\makebox(10,6){#2}}     %label
\put(16,-17){\makebox(10,6){#3}}   %label
       \ifnum#4=1   % rez. adjustable by tool (medium pin left oriented)
\put(2,-10){\line(1,0){16}}
\put(18,-8){\line(0,-1){4}}
       \else \ifnum#4=2  % rez. adjustable by tool (medium pin right oriented)
\put(2,-10){\line(1,0){16}}
\put(2,-8){\line(0,-1){4}}
      \else \ifnum#4=3   % rez. adjustable by tool (medium pin shortly
                                                        %conected)
\put(2,-10){\line(1,0){16}}
\put(18,-8){\line(0,-1){4}}
\put(2,-10){\line(0,1){4}}
\put(2,-6){\line(1,0){4}}
\put(6,-6){\node}
     \else \ifnum#4=4    % rez. adjustable (medium pin left oriented)
\put(2,-10){\vector(1,0){16}}
     \else \ifnum#4=5    % rez. adjustable (medium pin right oriented)
\put(18,-10){\vector(-1,0){16}}
     \else \ifnum#4=6    % rez. adjustable (medium pin shortly conected)
\put(2,-10){\vector(1,0){16}}
\put(2,-10){\line(0,1){4}}
\put(2,-6){\line(1,0){4}}
\put(6,-6){\node}
\fi  \fi  \fi \fi  \fi \fi  \fi
}

%%%%help marks (arrow, node, loop, pin, wire, earth, chassis)%%%%%%%%%
% horizontal arrow
\newcommand{\harrow}[2]{
\if#1R                          %right oriented
\put(0,0){\vector(1,0){10}
\put(-10,0){\makebox(10,6){#2}}}     %label
\else \ifx#1L                   %left oriented
\put(0,0){\vector(-1,0){10}
\put(0,0){\makebox(10,6){#2}}}       %label
\fi \fi
}
%vertical arrow
\newcommand{\varrow}[2]{
\ifx#1U                    %up oriented
\put(0,0){\vector(0,1){10}
\put(0,2){\makebox(10,6){#2}}}   %label
\else \if#1D                %down  oriented
\put(0,0){\vector(0,-1){10}
\put(0,-8){\makebox(10,6){#2}}}  %label
\fi \fi
}
%diagonal  arrows
\newcommand{\darrow}[2]{
\ifnum#1=1                  %up right oriented
\put(0,0){\vector(1,1){7}
\put(-4,-1){\makebox(10,6){#2}}} %label
\fi \ifnum#1=2              %up left oriented
\put(0,0){\vector(-1,1){7}
\put(-1,3){\makebox(10,6){#2}}}  %label
\fi \ifnum#1=4             %down  right oriented
\put(0,0){\vector(1,-1){7}
\put(-5,-5){\makebox(10,6){#2}}}  %label
\fi \ifnum#1=3   %down left oriented
\put(0,0){\vector(-1,-1){7}
\put(-1,-9){\makebox(10,6){#2}}} %label
\fi
}
\newcommand{\node}{       %conection of devices
\put(0,0){\circle*{1}}
}
\newcommand{\pin}[1]{
\put(0,0){\circle{1.5}\put(0,0){\makebox(10,6){#1}}}  %label
}
\newcommand{\hwire}[1]{
\put(0,0){\line(1,0){#1}}  % length mm
}
\newcommand{\vwire}[1]{
\put(0,0){\line(0,1){#1}}  % length mm
}
\newcommand{\dwire}[2]{
\ifx#1U                    %up right oriented
\put(0,0){\line(1,1){#2}}  %length mm
\fi
\ifx#1D                    %down right oriented
\put(0,0){\line(1,-1){#2}} %length mm
\fi
}
%simbol
\newcommand{\simb}[1]{
\ifnum#1=1
\put(0,0){\circle*{1.5}}
 \else \ifnum#1=2
\put(0,0){$\Box$}
 \else \ifnum#1=3
\put(0,0){$\triangle$}
 \fi \fi \fi
}
%current loop oriented
\newcommand{\cloop}[2]{
\ifx#1R             %right oriented
\put(0,0){\oval(12,12)[t]}
\put(0,0){\oval(12,12)[l]\put(0,-6){\vector(1,0){1}}}
\put(-5,-5){\makebox(10,10){#2}}   %label
   \else \ifx#1L       %left oriented
\put(0,0){\oval(12,12)[t]}
\put(0,0){\oval(12,12)[l]\put(6,0){\vector(0,-1){1}}}
\put(-5,-5){\makebox(10,10){#2}}    %label
\fi \fi
}
%earth
\newcommand{\earth}{
\put(0,0){\line(0,-1){5}}
\put(-4,-5){\line(1,0){8}}
\put(-3,-6){\line(1,0){6}}
\put(-2,-7){\line(1,0){4}}
}
%chassis
\newcommand{\chassis}{
\put(0,0){\line(0,-1){5}}
\multiput(-2.5,-5)(0,-0.1){5}{\line(1,0){5}}
}

%%%%block symbols(amplifier, high-low-band pass, stop band,
%%%%corrector, attenuator, transformer, limiter, balancing network
%%%%%hybrid circuit)
%block
\newcommand{\bl}{
\put(0,0){\line(1,0){5}}
\put(5,-5){\line(0,1){10}}
\put(5,-5){\line(1,0){10}}
\put(5,5){\line(1,0){10}}
\put(15,-5){\line(0,1){10}}
\put(15,0){\line(1,0){5}}
}
%general block
\newcommand{\block}[1]{
\put(0,0){\bl}
\put(5,-5){\makebox(10,10){#1}}
}
%generator
\newcommand{\generator}[1]{
\put(0,0){\bl}
\put(5,0){\makebox(10,5){G}}
   \ifx#1H
\put(5,-5){\makebox(10,2,5){$\sim$}}
\put(5,-3){\makebox(10,2,5){$\sim$}}
   \fi \ifx#1L
\put(5,-5){\makebox(10,5){$\sim$}}
   \fi
}
%convertor
\newcommand{\convertor}[2]{
\put(0,0){\bl}
\put(5,-5){\line(1,1){10}}
\put(5,0){\makebox(5,5){#1}}
\put(10,-5){\makebox(5,5){#2}}
}
%low pass
\newcommand{\lowpass}{
\put(0,0){\bl}
\put(5,-2){\makebox(10,3){$\not\sim$}}
\put(5,-5){\makebox(10,3){$\sim$}}
}
%high pass
\newcommand{\highpass}{
\put(0,0){\bl}
\put(5,-4){\makebox(10,3){$\not\sim$}}
\put(5,-1){\makebox(10,3){$\sim$}}
}
%band pass
\newcommand{\bandpass}{
\put(0,0){\bl}
\put(5,-4.5){\makebox(10,3){$\not\sim$}}
\put(5,-1.75){\makebox(10,3){$\sim$}}
\put(5,1.5){\makebox(10,3){$\not\sim$}}
}
%band stop
\newcommand{\bandstop}{
\put(0,0){\bl}
\put(5,-5){\makebox(10,3){$\sim$}}
\put(5,-1.75){\makebox(10,3){$\not\sim$}}
\put(5,1.5){\makebox(10,3){$\sim$}}
}
%attenuator
\newcommand{\attenuator}[1]{
\put(0,0){\bl}
\put(8,-3.5){\line(1,0){4}}
\put(10,-3.5){\line(0,1){7}}
\put(8,3.5){\line(1,0){4}}
  \ifx#1V
\put(8,-2){\vector(1,1){5}}
  \fi
}
%amplifier
\newcommand{\amplifier}{
\put(0,0){\bl}
\put(8,-2){\line(0,1){4}}
\put(8,-2){\line(2,1){4}}
\put(8,2){\line(2,-1){4}}
}
%corrector
\newcommand{\corrector}[1]{
\put(0,0){\bl}
\put(8,-3){\line(1,0){2}}
\put(10,-3){\line(0,1){6}}
\put(10,3){\line(1,0){2}}
\put(10,-5){\makebox(5,5){#1}}
}
%expander
\newcommand{\expander}{
\put(0,0){\bl}
\put(7,3){\line(1,0){6}}
\put(13,3){\line(0,-1){6}}
\put(13,3){\line(-1,-1){5}}
\put(10,-3){\vector(0,1){6}}
}
%compresor
\newcommand{\compresor}{
\put(0,0){\bl}
\put(7,3){\line(1,0){6}}
\put(13,3){\line(0,-1){6}}
\put(13,3){\line(-1,-1){5}}
\put(10,3){\vector(0,-1){7}}
}
%limiter
\newcommand{\limiter}[1]{
\put(0,0){\bl}
\put(7,-3){\line(1,0){6}}
\put(7,-3){\line(0,1){6}}
 \ifx#1B
\put(9,-3){\line(1,2){3}}
\put(12,3){\line(1,0){2}}
 \fi \ifx#1H
\put(7,-3){\line(1,2){3}}
\put(10,3){\line(1,0){2}}
 \fi \ifx#1L
\put(9,-3){\line(1,2){3}}
 \fi
}
%transformer
\newcommand{\transformer}{
\put(0,0){\bl}
\multiput(7,3)(4,0){2}{\line(1,0){2}}
\multiput(7,-3)(4,0){2}{\line(1,0){2}}
\multiput(9,-3)(2,0){2}{\line(0,1){6}}
}
%hybrid circuit
\newcommand{\hybrid}{
\put(0,0){\bl}
\put(8,0){\line(1,0){2}}
\put(10,-3){\line(0,1){6}}
\multiput(10,-3)(0,6){2}{\line(1,0){2}}
}
%balancing network
\newcommand{\balanc}{
\put(0,-5){\line(0,1){10}}
\put(0,-5){\line(1,0){10}}
\put(0,5){\line(1,0){10}}
\put(10,-5){\line(0,1){10}}
\multiput(2,-3)(0,6){2}{\line(1,0){6}}
\put(8,-3){\line(0,1){6}}
}

%%%%%%%basic logic circuit(n-input gate, counter, decoder,
%%%%%%%multiplexer, shift register)
%box for device
\newcommand{\ba}[2]{
\put(0,0){\line(0,1){#2}}
\put(0,0){\line(1,0){#1}}
\put(0,#2){\line(1,0){#1}}
\put(#1,0){\line(0,1){#2}}
}
%shift register
\newcommand{\shregister}[3]{
 \put(0,0){\ba{30}{45}}
\put(0,-7){\makebox(30,5){#2}}     %lower label
\put(0,47){\makebox(30,5){#3}}     %upper label
\put(9,0){\line(0,1){45}}
\put(22,0){\line(0,1){45}}
 \ifnum#1=8                         %8bit register
\put(10,38){\makebox(10,5){RG$<$}}     %label in box
\put(2,38){\makebox(5,5){\&A}}
\multiput(0,38)(0,5){2}{\line(-1,0){5}}
\put(23,38){\makebox(5,5){Q1}}
\put(23,34){\makebox(5,5){Q2}}
\put(23,30){\makebox(5,5){Q3}}
\put(23,26){\makebox(5,5){Q4}}
\put(23,22){\makebox(5,5){Q5}}
\put(23,18){\makebox(5,5){Q6}}
\put(23,14){\makebox(5,5){Q7}}
\put(23,10){\makebox(5,5){Q8}}
\put(22,10){\line(1,0){8}}
\put(0,10){\line(1,0){9}}
\put(-1.2,5){\makebox(5,5)[l]{$\rhd$}}
\put(2,0){\makebox(5,5){R}}
\put(-1,2){\circle{2}}
 \fi \ifnum#1=5                  %left right 5bit register
\put(10.5,38){\makebox(10,5){RG$<>$}}     %label in box
\put(2,38){\makebox(5,5){SI}}
\put(2,30){\makebox(5,5){A}}
\put(2,26){\makebox(5,5){B}}
\put(2,22){\makebox(5,5){C}}
\put(2,18){\makebox(5,5){D}}
\put(0,15){\line(1,0){9}}
\put(23,30){\makebox(5,5){A}}
\put(23,26){\makebox(5,5){B}}
\put(23,22){\makebox(5,5){C}}
\put(23,18){\makebox(5,5){D}}
\put(22,15){\line(1,0){8}}
\multiput(-1,12)(0,-5){2}{\circle{2}}
\put(2,5){\makebox(5,5){C2}}
\put(2,10){\makebox(5,5){C1}}
\put(2,0){\makebox(5,5){MC}}
 \fi
}
%reversible counter
\newcommand{\rcounter}[3]{
\put(0,0){\ba{30}{45}}
\put(0,-7){\makebox(30,5){#2}}     %lower label
\put(0,47){\makebox(30,5){#3}}     %upper label
\put(9,0){\line(0,1){45}}
\put(22,0){\line(0,1){45}}
\put(1.2,40){\makebox(5,5){$\rhd$CD}}
\put(1.2,35){\makebox(5,5){$\rhd$CU}}
\put(1,30){\makebox(5,5){\&L}}
\put(0,25){\makebox(5,5){A}}
\put(0,20){\makebox(5,5){B}}
\put(0,15){\makebox(5,5){C}}
\put(0,10){\makebox(5,5){D}}
\put(0,10){\line(1,0){9}}
\put(0,5){\makebox(5,5){L}}
\put(-1,7){\circle{2}}
\put(31,7){\circle{2}}
\put(31,2){\circle{2}}
\put(0,0){\makebox(5,5){R}}
\put(23,35){\makebox(5,5){A}}
\put(23,30){\makebox(5,5){B}}
\put(23,25){\makebox(5,5){C}}
\put(23,20){\makebox(5,5){D}}
\put(23,5){\makebox(5,5){B0}}
\put(23,0){\makebox(5,5){CA}}
\put(22,10){\line(1,0){8}}
  \ifnum#1=10                          %decadic counter
\put(10,38){\makebox(10,5){CT10}}     %label in box
  \fi  \ifnum#1=16                  %binary counter
\put(10,38){\makebox(10,5){CT2}}     %label in box
  \fi
}
%ripple counter
\newcommand{\counter}[3]{
\put(0,0){\ba{25}{40}}
\put(0,-7){\makebox(20,5){#2}}     %lower label
\put(0,42){\makebox(20,5){#3}}     %upper label
\put(7,0){\line(0,1){40}}
\put(18,0){\line(0,1){40}}
\put(0,35){\makebox(5,5){A}}
\put(0,34){\line(1,0){7}}
\put(0,20){\line(1,0){7}}
\put(0,14){\makebox(5,5){\&}}
\put(0,10){\makebox(5,5){R0}}
\put(18,35){\makebox(5,5){A}}
\put(18,34){\line(1,0){7}}
\put(18,28){\makebox(5,5){B}}
\put(18,23){\makebox(5,5){C}}
\put(18,18){\makebox(5,5){D}}
\put(0,12){\line(-1,0){5}}
\put(0,16){\line(-1,0){5}}
  \ifnum#1=10                          %decadic counter
\put(7.5,32){\makebox(10,5){CT10}}     %label in box
\put(1,28){\makebox(5,5){BD}}
\put(0,4){\makebox(5,5){\&}}
\put(0,0){\makebox(5,5){R9}}
\put(0,2){\line(-1,0){5}}
\put(0,6){\line(-1,0){5}}
  \fi  \ifnum#1=16                  %binary counter
\put(7.5,32){\makebox(10,5){CT2}}     %label in box
\put(1,28){\makebox(5,5){B}}
  \fi
}
%multiplexor
\newcommand{\mpx}[3]{
 \ifnum#1=8                     %8 channel multiplexor
\put(0,0){\ba{20}{55}}
\put(8,45){\makebox(10,5){MX}}     %label in box
\put(0,-7){\makebox(20,5){#2}}     %lower label
\put(0,57){\makebox(20,5){#3}}     %upper label
\put(0,0){\makebox(5,4){S}}
\put(0,6){\makebox(5,4){C}}
\put(0,10){\makebox(5,4){B}}
\put(0,14){\makebox(5,4){A}}
\put(0,20){\makebox(5,4){7}}
\put(0,24){\makebox(5,4){6}}
\put(0,28){\makebox(5,4){5}}
\put(0,32){\makebox(5,4){4}}
\put(0,36){\makebox(5,4){3}}
\put(0,40){\makebox(5,4){2}}
\put(0,44){\makebox(5,4){1}}
\put(0,48){\makebox(5,4){0}}
\put(1,51){\makebox(5,4){\&S}}
\put(7,0){\line(0,1){55}}
\put(0,5){\line(1,0){7}}
\put(0,19){\line(1,0){7}}
\put(-1,2){\circle{2}}
\put(21,25){\circle{2}}
\put(20,35){\line(1,0){10}}
 \fi \ifnum#1=16                   %16 channel multiplexor
\put(0,0){\ba{20}{95}}
\put(8,85){\makebox(10,5){MX}}     %label in box
\put(0,-7){\makebox(20,5){#2}}     %lower label
\put(0,97){\makebox(20,5){#3}}     %upper label
\put(0,0){\makebox(5,4){S}}
\put(0,8){\makebox(5,4){D}}
\put(0,12){\makebox(5,4){C}}
\put(0,16){\makebox(5,4){B}}
\put(0,20){\makebox(5,4){A}}
\put(0,26){\makebox(5,4){15}}
\put(0,30){\makebox(5,4){14}}
\put(0,34){\makebox(5,4){13}}
\put(0,38){\makebox(5,4){12}}
\put(0,42){\makebox(5,4){11}}
\put(0,46){\makebox(5,4){10}}
\put(0,50){\makebox(5,4){9}}
\put(0,54){\makebox(5,4){8}}
\put(0,58){\makebox(5,4){7}}
\put(0,62){\makebox(5,4){6}}
\put(0,66){\makebox(5,4){5}}
\put(0,70){\makebox(5,4){4}}
\put(0,74){\makebox(5,4){3}}
\put(0,78){\makebox(5,4){2}}
\put(0,82){\makebox(5,4){1}}
\put(0,86){\makebox(5,4){0}}
\put(1,90){\makebox(5,4){\&S}}
\put(7,0){\line(0,1){95}}
\put(0,5){\line(1,0){7}}
\put(0,25){\line(1,0){7}}
\put(-1,2){\circle{2}}
\put(21,45){\circle{2}}
 \fi
}
%BCD/Dec decoder
\newcommand{\bdecoder}[3]{
 \ifnum#1=10                    %BCD to 10 outputs
\put(0,0){\ba{20}{40}}
\put(0,-7){\makebox(20,5){#2}}     %lower label
\put(0,42){\makebox(20,5){#3}}     %upper label
\put(14,0){\line(0,1){40}}
\put(5,0){\line(0,1){40}}
\put(4.5,33){\makebox(10,5){B/D}}
\put(0,22.5){\makebox(5,5){A}}
\put(0,17.5){\makebox(5,5){B}}
\put(0,12.5){\makebox(5,5){C}}
\put(0,7.5){\makebox(5,5){D}}
\multiput(21,2)(0,4){10}{\circle{2}}
\put(14,-0.5){\makebox(5,5){9}}
\put(14,3.5){\makebox(5,5){8}}
\put(14,7.5){\makebox(5,5){7}}
\put(14,11.5){\makebox(5,5){6}}
\put(14,15.5){\makebox(5,5){5}}
\put(14,19.5){\makebox(5,5){4}}
\put(14,23.5){\makebox(5,5){3}}
\put(14,27.5){\makebox(5,5){2}}
\put(14,31.5){\makebox(5,5){1}}
\put(14,35.5){\makebox(5,5){0}}
 \fi \ifnum#1=16                        %BCD to 16 outputs
\put(0,0){\ba{20}{70}}
\put(0,-7){\makebox(20,5){#2}}      %lower label
\put(0,72){\makebox(20,5){#3}}      %upper label
\put(14,0){\line(0,1){70}}
\put(5,0){\line(0,1){70}}
\put(4.5,63){\makebox(10,5){DC}}
\put(0,37.5){\makebox(5,5){A}}
\put(0,32.5){\makebox(5,5){B}}
\put(0,27.5){\makebox(5,5){C}}
\put(0,22.5){\makebox(5,5){D}}
\put(0,10){\line(1,0){5}}
\put(0,5){\makebox(5,5){B}}
\put(0,0){\makebox(5,5){G}}
\multiput(-1,2)(0,5){2}{\circle{2}}
\multiput(21,68)(0,-4){16}{\circle{2}}
\put(14,5.5){\makebox(5,5){15}}
\put(14,9.5){\makebox(5,5){14}}
\put(14,13.5){\makebox(5,5){13}}
\put(14,17.5){\makebox(5,5){12}}
\put(14,21.5){\makebox(5,5){11}}
\put(14,25.5){\makebox(5,5){10}}
\put(14,29.5){\makebox(5,5){9}}
\put(14,33.5){\makebox(5,5){8}}
\put(14,37.5){\makebox(5,5){7}}
\put(14,41.5){\makebox(5,5){6}}
\put(14,45.5){\makebox(5,5){5}}
\put(14,49.5){\makebox(5,5){4}}
\put(14,53.5){\makebox(5,5){3}}
\put(14,57.5){\makebox(5,5){2}}
\put(14,61.5){\makebox(5,5){1}}
\put(14,65.5){\makebox(5,5){0}}
 \fi
}
%JK flip flop
\newcommand{\jkflip}[2]{
\put(0,0){\ba{20}{30}}
\put(6,0){\line(0,1){30}}
\put(0,-7){\makebox(20,5){#1}}      %lower label
\put(0,32){\makebox(20,5){#2}}      %upper label
\put(-1,5){\circle{2}}
\put(-1,10){\circle{2}}
\put(21,10){\circle{2}}
\put(0,22.5){\makebox(5,5){J}}
\put(0,17.5){\makebox(5,5){K}}
\put(0,3){\makebox(5,5){R}}
\put(0,8){\makebox(5,5){S}}
\put(10,23){\makebox(5,5){T}}
\put(14,17){\makebox(5,5){Q}}
\put(14,8){\makebox(5,5){$\overline{\rm Q}$}}
\put(4,15){\line(-3,1){4}}
\put(4,15){\line(-3,-1){4}}
}
%D flip flop
\newcommand{\dflip}[2]{
\put(0,-7){\makebox(20,5){#1}}      %lower label
\put(0,32){\makebox(20,5){#2}}      %upper label
\put(0,0){\ba{20}{30}}
\put(0,23){\line(1,0){6}}
\put(6,0){\line(0,1){30}}
\put(-1,5){\circle{2}}
\put(-1,10){\circle{2}}
\put(21,10){\circle{2}}
\put(0,24){\makebox(5,5){D}}
\put(0,3){\makebox(5,5){R}}
\put(0,8){\makebox(5,5){S}}
\put(10,23){\makebox(5,5){T}}
\put(14,17){\makebox(5,5){Q}}
\put(14,8){\makebox(5,5){$\overline{\rm Q}$}}
\put(4,15){\line(-3,1){4}}
\put(4,15){\line(-3,-1){4}}
}
%logic gate
\newcommand{\logic}[5]{
\ifnum#1=8                       %8 input gate
\put(5,-10){\ba{10}{20}}
\put(0,-17){\makebox(20,5){#4}}      %lower label
\put(0,12){\makebox(20,5){#5}}      %upper label
\put(8,5){\makebox(6,6)[r]{#3}}          %label in box
\multiput(0,-8)(0,2.25){8}{\line(1,0){5}}
      \ifx#2N                     %neg. output
\put(16,0){\circle{2}}
\put(17,0){\line(1,0){3}}
      \fi \ifx#2P                %direct output
\put(15,0){\line(1,0){5}}
          \fi
\else \ifnum#1=4                    %4 input gate
      \put(5,-10){\ba{10}{20}}
      \put(0,-17){\makebox(20,5){#4}}      %lower label
      \put(0,12){\makebox(20,5){#5}}      %upper label
      \put(8,5){\makebox(6,6)[r]{#3}}       %label in box
      \multiput(0,-6)(0,4){4}{\line(1,0){5}}
         \ifx#2N                 %neg. output
      \put(16,0){\circle{2}}
      \put(17,0){\line(1,0){3}}
         \fi \ifx#2P             %direct output
      \put(15,0){\line(1,0){5}}
             \fi
      \else
          \put(5,-6){\ba{8}{12}}
          \put(0,-14){\makebox(20,5){#4}}      %lower label
          \put(0,8){\makebox(20,5){#5}}      %upper label
          \put(6,1){\makebox(6,6)[r]{#3}}      %label in box
            \ifnum#1=1                    %1 input gate
          \put(0,0){\line(1,0){5}}
            \fi
            \ifnum#1=2                   %2 input gate
          \put(0,3){\line(1,0){5}}
          \put(0,-3){\line(1,0){5}}
            \fi
            \ifnum#1=3                   %3 input gate
          \put(0,0){\line(1,0){5}}
          \put(0,3){\line(1,0){5}}
          \put(0,-3){\line(1,0){5}}
            \fi
            \ifx#2N                   %neg. output
          \put(14,0){\circle{2}}
          \put(15,0){\line(1,0){5}}
            \fi \ifx#2P              %direct output
          \put(13,0){\line(1,0){7}}
               \fi
\fi \fi
}

%%%%%%%%some basic valves(diode, triode, pentode, heptode, tube)
%tube
\newcommand{\tube}[4]{
 \ifx#2R
\put(0,0){\focus{R}}
\put(2,0){\cathode{R}}
\put(5.5,-2.5){\gr{V}}
\multiput(5.5,2.5)(0,-5){2}{\line(-1,0){1}}
\put(0,0){\sct{R}}
\put(40,5){\makebox(10,6)[l]{#3}}
\put(40,-5){\makebox(20,6)[l]{#4}}
 \ifx#1E                    %electrostatic tube
\multiput(8.5,-2.5)(2,0){2}{\gr{V}}
\multiput(15,2)(5,0){2}{\anode{U}}
\multiput(15,-2)(5,0){2}{\anode{D}}
 \fi  \ifx#1M                %deflection coil tube
\multiput(8.5,-2.5)(2,0){4}{\gr{V}}
\multiput(18,-8)(5,0){2}{
  \multiput(0,0)(0,-2){2}{\oval(2,2)[l]}
  \put(0,1){\line(1,0){2}}
  \put(2,1){\line(0,-1){10}}
  \put(0,-3){\line(0,-1){6}}}
 \fi  \fi
\ifx#2L
\put(0,0){\focus{L}}
\put(-2,0){\cathode{L}}
\put(-5.5,-2.5){\gr{V}}
\multiput(-5.5,2.5)(0,-5){2}{\line(1,0){1}}
\put(0,0){\sct{L}}
\put(-50,5){\makebox(10,6)[r]{#3}}
\put(-60,-5){\makebox(20,6)[r]{#4}}
 \ifx#1E                    %electrostatic tube
\multiput(-8.5,-2.5)(-2,0){2}{\gr{V}}
\multiput(-15,2)(-5,0){2}{\anode{U}}
\multiput(-15,-2)(-5,0){2}{\anode{D}}
 \fi  \ifx#1M                %deflection coil tube
\multiput(-8.5,-2.5)(-2,0){4}{\gr{V}}
\multiput(-18,-8)(-5,0){2}{
  \multiput(0,0)(0,-2){2}{\oval(2,2)[l]}
  \put(0,1){\line(1,0){2}}
  \put(2,1){\line(0,-1){10}}
  \put(0,-3){\line(0,-1){6}}}
 \fi  \fi
}

%vacuum diode
\newcommand{\diode}[2]{
\put(0,0){\kolo}
\put(0,-4){\focus{U}}
\put(0,-2){\cathode{U}}
\put(0,2){\anode{U}}
\put(-13,5){\makebox(10,6)[r]{#1}}
\put(3,5){\makebox(20,6)[l]{#2}}
}
%triode
\newcommand{\triode}[2]{
\put(0,0){\valve}
\put(0,1){\focus{U}}
\put(0,3){\cathode{U}}
\put(-4,10){\gr{H}}
\put(0,17){\anode{U}}
\put(-13,20){\makebox(10,6)[r]{#1}}
\put(3,20){\makebox(20,6)[l]{#2}}
}
%pentode
\newcommand{\pentode}[2]{
\put(0,0){\valve}
\put(0,1){\focus{U}}
\put(0,3){\cathode{U}}
\multiput(-4,7)(0,3){3}{\gr{H}}
\put(0,17){\anode{U}}
\put(-13,20){\makebox(10,6)[r]{#1}}
\put(3,20){\makebox(20,6)[l]{#2}}
}
%heptode
\newcommand{\heptode}[2]{
\put(0,0){\valve}
\put(0,1){\focus{U}}
\put(0,3){\cathode{U}}
\multiput(-4,6.5)(0,2){5}{\gr{H}}
\put(0,17){\anode{U}}
\put(-13,20){\makebox(10,6)[r]{#1}}
\put(3,20){\makebox(20,6)[l]{#2}}
}
%\screen envelope
\newcommand{\sct}[1]{
 \ifx#1R
\put(0,-5){\line(0,1){10}}
\multiput(0,-5)(0,10){2}{\line(1,0){25}}
\put(25,5){\line(3,1){10}}
\put(25,-5){\line(3,-1){10}}
\put(35,0){\bezier{50}(0,8)(2,0)(0,-8)}
  \fi \ifx#1L
\put(0,-5){\line(0,1){10}}
\multiput(0,-5)(0,10){2}{\line(-1,0){25}}
\put(-25,5){\line(-3,1){10}}
\put(-25,-5){\line(-3,-1){10}}
\put(-35,0){\bezier{50}(0,8)(-2,0)(0,-8)}
  \fi
}
%tube envelope
\newcommand{\valve}{
\put(0,5){\oval(10,10)[b]}
\put(0,5.1){\oval(9.9,9.9)[b]}
\put(0,5.2){\oval(9.8,9.8)[b]}
\put(0,5.3){\oval(9.5,9.5)[b]}
\put(0,5.4){\oval(9.4,9.4)[b]}
\put(0,15){\oval(10,10)[t]}
\put(0,14.9){\oval(9.9,9.9)[t]}
\put(0,14.8){\oval(9.7,9.7)[t]}
\put(0,14.7){\oval(9.4,9.4)[t]}
\multiput(-5,5)(0.1,0){4}{\line(0,1){10}}
\multiput(5,5)(-0.1,0){4}{\line(0,1){10}}
}
%focus
\newcommand{\focus}[1]{
 \ifx#1U                     %up oriented
\put(0,0){\oval(4,4)[t]}
\put(-2,0){\line(0,-1){4}}
\put(2,0){\line(0,-1){4}}
 \fi \ifx#1R                 %right oriented
\put(0,0){\oval(4,4)[r]}
\put(0,-2){\line(-1,0){4}}
\put(0,2){\line(-1,0){4}}
 \fi \ifx#1L                 %left oriented
\put(0,0){\oval(4,4)[l]}
\put(0,-2){\line(1,0){4}}
\put(0,2){\line(1,0){4}}
 \fi
}
%cathode
\newcommand{\cathode}[1]{
 \ifx#1U                    %up oriented
\multiput(0,0)(0,0.1){5}{\bezier{20}(-3,0)(0,2)(3,0)}
  \fi \ifx#1R               %right oriented
\multiput(0,0)(0.1,0){5}{\bezier{20}(0,-3)(2,0)(0,3)}
  \fi  \ifx#1L              %left oriented
\multiput(0,0)(-0.1,0){5}{\bezier{20}(0,-3)(-2,0)(0,3)}
  \fi
}
%grid in valve
\newcommand{\gr}[1]{
 \ifx#1H          %horizontal
\multiput(0,0)(3,0){3}{\multiput(0,0)(0,0.1){3}{\line(1,0){2}}}
 \fi \ifx#1V
\multiput(0,0)(0,3){2}{\multiput(0,0)(0.1,0){4}{\line(0,2){2}}}
 \fi
}
%anode
\newcommand{\anode}[1]{
 \ifx#1U                   %up oriented
\multiput(-2,0)(0,0.1){5}{\line(1,0){4}}
\put(0,0){\line(0,1){3}}
  \fi \ifx#1D              %down oriented
\multiput(-2,0)(0,0.1){5}{\line(1,0){4}}
\put(0,0){\line(0,-1){3}}
  \fi 
}
%help labels
%vertical label
\newcommand{\vlabel}[2]{
\put(0,0){\makebox(10,6){#1}}
\put(0,-6){\makebox(10,6){#2}}
}
%horizontal label
\newcommand{\hlabel}[2]{
\put(0,0){\makebox(8,6){#1}}
\put(8,0){\makebox(8,6){#2}}
}
%%%special macros for most frequently used structures%%%%%
\newcommand{\tnet}{          %t network
\put(0,30){\hrez{}{}{0}}
\put(20,30){\hrez{}{}{0}}
\put(25,0){\vrez{}{}{0}}
\put(0,0){\hwire{50}}
\put(0,30){\pin{}}
\put(0,0){\pin{}}
\put(50,0){\pin{}}
\put(50,30){\pin{}}
\put(25,0){\node}
\put(25,30){\node}
}
\newcommand{\tbnet}{        %bridged t network
\put(0,0){\tnet}
\put(10,45){\hrez{}{}{0}}
\put(5,45){\hwire{5}}
\put(40,45){\hwire{5}}
\put(5,30){\vwire{15}}
\put(45,30){\vwire{15}}
\put(5,30){\node}
\put(45,30){\node}
}
\newcommand{\ttnet}{       %parallel t network
\put(5,30){\hrez{}{}{0}}
\put(35,30){\hrez{}{}{0}}
\put(30,0){\vrez{}{}{0}}
\put(0,0){\hwire{70}}
\put(0,30){\hwire{5}}
\put(65,30){\hwire{5}}
\put(0,30){\pin{}}
\put(0,0){\pin{}}
\put(70,0){\pin{}}
\put(70,30){\pin{}}
\put(30,0){\node}
\put(30,30){\node}
\put(5,40){\hrez{}{}{0}}
\put(35,40){\hrez{}{}{0}}
\put(40,0){\vrez{}{}{0}}
\put(40,0){\node}
\put(40,40){\node}
\put(5,30){\node}
\put(65,30){\node}
\put(5,30){\vwire{10}}
\put(65,30){\vwire{10}}
\put(40,30){\vwire{10}}
}
\newcommand{\hnet}{         %h network
\put(0,30){\hrez{}{}{0}}
\put(20,30){\hrez{}{}{0}}
\put(25,0){\vrez{}{}{0}}
\put(0,0){\hrez{}{}{0}}
\put(20,0){\hrez{}{}{0}}
\put(0,30){\pin{}}
\put(0,0){\pin{}}
\put(50,0){\pin{}}
\put(50,30){\pin{}}
\put(25,0){\node}
\put(25,30){\node}
}
\newcommand{\pinet}{         %pi network
\put(0,30){\hrez{}{}{0}}
\put(25,0){\vrez{}{}{0}}
\put(5,0){\vrez{}{}{0}}
\put(0,30){\pin{}}
\put(0,0){\pin{}}
\put(30,0){\pin{}}
\put(30,30){\pin{}}
\put(5,0){\node}
\put(5,30){\node}
\put(25,0){\node}
\put(25,30){\node}
\put(0,0){\hwire{30}}
}
\newcommand{\xnet}{          %lattice network
\put(5,0){\drez{U}{}{}{0}}
\put(5,35){\drez{D}{}{}{0}}
\put(25,20){\dwire{U}{15}}
\put(25,15){\dwire{D}{15}}
\put(7.5,0){\hrez{}{}{0}}
\put(7.5,35){\hrez{}{}{0}}
\put(0,0){\hwire{7.5}}
\put(0,35){\hwire{7.5}}
\put(37.5,0){\hwire{7.5}}
\put(37.5,35){\hwire{7.5}}
\put(0,35){\pin{}}
\put(0,0){\pin{}}
\put(45,0){\pin{}}
\put(45,35){\pin{}}
\put(5,0){\node}
\put(5,35){\node}
\put(40,0){\node}
\put(40,35){\node}
}
\newcommand{\lnet}[1]{   %ladder network
 \ifx#1T
\put(0,30){\hrez{}{}{0}}
 \fi
 \ifx#1P
\put(0,30){\hwire{30}}
 \fi
\put(25,0){\vrez{}{}{0}}
\put(20,30){\hrez{}{}{0}}
\put(45,0){\vrez{}{}{0}}
\put(25,0){\node}
\put(25,30){\node}
\put(45,0){\node}
\put(45,30){\node}
\put(0,0){\pin{}}
\put(0,30){\pin{}}
\put(0,0){\hwire{90}}
\put(60,30){\hrez{}{}{0}}
\put(90,0){\vrez{}{}{0}}
\multiput(52,30)(2,0){3}{\put(0,0){\hwire{1}}}
}
\endinput









