Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I can draw an AC source manually:

\begin{tikzpicture}
  \draw (0,0) sin (1,1) cos (2,0) sin (3,-1) cos (4,0);
  \draw (2,0) circle (2.5);
\end{tikzpicture}

alt text

How do I declare an ACsource symbol so that I can just write the following, or something similar and more correct:

\draw (0,5) to [ACsource={volt=220}] (5,5);

Also, when I am able to declare it as a symbol, will it already behave the same way as the other default symbols in the circuits library? To illustrate, will it behave like this resistor, drawing connector lines and labels in the appropriate places? I also want the ACsource to be the proper size that obeys keys like small circuit symbols, huge circuit symbols, etc.

\draw (0,0) to [resistor={ohm=5}] (5,0);

In response to @morbusg's answer:

I'm using LaTeX. Here's my MWE:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}
\tikzset{circuit declare symbol = ac current source}
\tikzset{%
          ac current source IEC graphic/.style={%
            circuit symbol lines,
            circuit symbol size = width 2 height 2,
            shape = generic circle IEC,
            /pgf/generic circle IEC/before background={%
              \pgfpathmoveto{\pgfpoint{-0.8pt}{0pt}}
              \pgfpathsine{\pgfpoint{0.4pt}{0.4pt}}
              \pgfpathcosine{\pgfpoint{0.4pt}{-0.4pt}}
              \pgfpathsine{\pgfpoint{0.4pt}{-0.4pt}}
              \pgfpathcosine{\pgfpoint{0.4pt}{0.4pt}}
              \pgfusepath{stroke}
            },
            transform shape
          }
}
\tikzset{%
          circuit ee IEC/.append style={%
            {set ac current source graphic = ac current source IEC graphic}
          }
}

\begin{document}
  \begin{tikzpicture}[circuit ee IEC]
    \draw node [ac current source, info=230V] {};
  \end{tikzpicture}
\end{document}

When I try to compile that, I'd get the following error:

Package pgfkeys Error: I do not know the key '/tikz/set ac current source graphic = ac current source IEC graphic' and I am going to ignore it. Perhaps you misspelled it.

@morbusg's solution works perfectly with Plain TeX, but I'm using LaTeX. Perhaps I'm missing something?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

I found a solution that perfectly suits my requirements. alt text

\documentclass{minimal}

\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}
\tikzset{circuit declare symbol = ac source}
\tikzset{set ac source graphic = ac source IEC graphic}
\tikzset{
         ac source IEC graphic/.style=
          {
           transform shape,
           circuit symbol lines,
           circuit symbol size = width 3 height 3,
           shape=generic circle IEC,
           /pgf/generic circle IEC/before background=
            {
             \pgfpathmoveto{\pgfpoint{-0.8pt}{0pt}}
             \pgfpathsine{\pgfpoint{0.4pt}{0.4pt}}
             \pgfpathcosine{\pgfpoint{0.4pt}{-0.4pt}}
             \pgfpathsine{\pgfpoint{0.4pt}{-0.4pt}}
             \pgfpathcosine{\pgfpoint{0.4pt}{0.4pt}}
             \pgfusepathqstroke
            }
          }
        }

\begin{document}
  \begin{tikzpicture}[circuit ee IEC]
    \draw (0,0)    to [ac source={info={110V 60Hz},near start},resistor={near end}] (3,0);
    \draw (0,-1.5) to [ac source={volt=220,near start}, inductor={near end}]        (3,-1.5);
  \end{tikzpicture}
\end{document}
share|improve this answer
add comment

This first one is a Plain-TeX version which has some extra definitions for "including" the ac source graphic as a toggleable (IEC/US/etc.) shape for circuits.ee. This is not necessary; see further below for a stripped-down LaTeX-version.

\input tikz
\usetikzlibrary{circuits.ee.IEC}
\tikzset{circuit declare symbol = ac current source}
\tikzset{ac current source IEC graphic/.style={
    circuit symbol lines,
    circuit symbol size=width 2 height 2,
    shape=generic circle IEC,
    /pgf/generic circle IEC/before background={
    \pgfpathmoveto{\pgfpoint{-0.8pt}{0pt}} 
    \pgfpathsine{\pgfpoint{0.4pt}{0.4pt}} 
    \pgfpathcosine{\pgfpoint{0.4pt}{-0.4pt}} 
    \pgfpathsine{\pgfpoint{0.4pt}{-0.4pt}} 
    \pgfpathcosine{\pgfpoint{0.4pt}{0.4pt}} 
    \pgfusepath{stroke}
    },
    transform shape
  }
}
\tikzset{circuit ee IEC/.append style=
  {set ac current source graphic = ac current source IEC graphic}
}

\tikzpicture[circuit ee IEC]
  \draw node[ac current source, huge circuit symbols,info=230V] {};
  \draw (1,0) node[ac current source, small circuit symbols,info=230V] {};
\endtikzpicture
\bye

Image

EDIT: LaTeX (without the extra definitions):

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}
\tikzset{ac source/.style={
  circuit symbol lines,
  circuit symbol size = width 2 height 2,
  shape = generic circle IEC,
  /pgf/generic circle IEC/before background={
    \pgfpathmoveto{\pgfpoint{-0.8pt}{0pt}}
    \pgfpathsine{\pgfpoint{0.4pt}{0.4pt}}
    \pgfpathcosine{\pgfpoint{0.4pt}{-0.4pt}}
    \pgfpathsine{\pgfpoint{0.4pt}{-0.4pt}}
    \pgfpathcosine{\pgfpoint{0.4pt}{0.4pt}}
    \pgfusepath{stroke}
  },
  transform shape
}}
\begin{document}
  \begin{tikzpicture}[circuit ee IEC,small circuit symbols]
    \node[ac source,volt=230] {};
  \end{tikzpicture}
\end{document}
share|improve this answer
    
Oh, there's a small (insignificant) typo, so just s/ac current source/ac source/g if you will. –  morbusg Dec 21 '10 at 11:56
    
+1 Works perfectly with Plain TeX, but I'm using LaTeX. See my edits on my question. –  Kit Dec 27 '10 at 11:54
    
You can just edit your answer. –  TH. Dec 27 '10 at 14:06
    
Your answers provided important insights. I eventually found a solution that's suited to my needs. See my answer below. –  Kit Dec 29 '10 at 4:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.