3

How can i fill the interior of a capacitor and label it using a greek letter in order to represent a dieletric inside the capacitor?

My Code:

\documentclass{article}

\usepackage{tikz}
\usepackage{circuitikz}

\begin{document}

\begin{figure}[h!]

\begin{center}

\begin{circuitikz}

 \draw (0,0)

  to[battery1,v=$\epsilon$] (0,2) % The voltage source
  to[short] (2,2)
  to[C=$C_1$] (2,0) % The resistor
  to[short](4,0)
  to[C=$C_2$](4,2)
  to[short] (2,2);
  \draw(2,0)
  to[short](0,0);
  \end{circuitikz}
  \caption{My first circuit.}
  \end{center}
  end{figure}

  \end{document}
  • 1
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. At the moment, your question is very short! – user31729 Jul 2 '15 at 23:04
3

You can use the name key to give the element a name that can then be used to perform actions (for example, filling or adding labels) using some anchors:

\documentclass{article}
\usepackage{circuitikz}

\begin{document}

\begin{figure}
\centering
\begin{circuitikz}
  \draw (0,0)
    to[battery1,v=$\epsilon$] (0,2) % The voltage source
    to[short] (2,2)
    to[C=$C_1$,name=a] (2,0) % The resistor
    to[short](4,0)
    to[C=$C_2$,name=b](4,2)
    to[short] (2,2);
  \draw(2,0)
    to[short](0,0);
  \fill[fill=orange!40] 
    ([yshift=\pgflinewidth]a.se) 
      rectangle 
    ([yshift=-\pgflinewidth]a.nw);   
  \node at (a.center) {$\scriptstyle\alpha$};
  \fill[fill=cyan!40] 
    ([yshift=-\pgflinewidth]b.se) 
      rectangle 
    ([yshift=\pgflinewidth]b.nw);   
  \node[label={60:$\scriptstyle\beta$}] at (b.center) {};
\end{circuitikz}
\caption{My first circuit.}
\end{figure}

\end{document}

The result:

enter image description here

Remarks

  • I changed the center environment to the \centering switch inside figure to avoid adding extra vertical space.

  • !h as placement specifier for a float is a recipe for disaster; use a less restrictive option or, better yet, none at all.

  • In the circuitikz implementation for bipoles, se is the chosen designation for the south east anchor, and nw is the one for the north west anchor. The shifts are needed to avoid the filling erasing half of the lines forming the capacitor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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