4

I am drawing a simple circuit with circuitikz package. I am struggling with colors and thickness.

\documentclass{report}
\usepackage{circuitikz}
\begin{document}

      \begin{center}
       \begin{circuitikz}[scale=1.2]
          \draw[thick]
      (0,3) node[left]{\textbf{RE \ }} to [R, l=$R_e$,color=red,*-] (3,3)
      (3,3) -- (3,4)
      to [C, l=$C_d$] (6,4) -- (6,3)
      to [short, -*] node[right]{\textbf{ \ WE}} (7,3)
      (3,3) -- (3,2) to [R, l_=$R_t$] (6,2) -- (6,3);
      \draw[gray,thin,dashed](2.8,1) rectangle (6.2,5)
      node[pos=0,below,xshift=60]{Metal};
       \draw[cyan,thin,dashed](0.5,1) rectangle (2.5,5)
      node[pos=0,below,xshift=35]{Solution};
        \end{circuitikz} 
    \end{center}

\end{document}

As you can see, the right node is also red, it should be black. And the thickness parameter only affects to the circuit elements, not the lines. How can I fix that?


Well, I made some changes. The color of the node seems to be changed. However, the thicknes of the lines does not. After checking the circuitikz package documentation, it seems there is no way of changing the thickness of the lines (conductors).

Here is the new code (I have edited the question according to other users suggerences):

\documentclass{report}
\usepackage{xcolor,circuitikz}
\begin{document}

\begin{center}
   \begin{circuitikz}[scale=1.2]
  \draw[gray,thin,dashed,fill=gray!3](2.8,1) rectangle (6.2,5)
  node[pos=0,below,xshift=60]{Metal};
   \draw[cyan,thin,dashed,fill=cyan!4,opacity=0.5](0.5,1) rectangle (2.5,5)
  node[pos=0,below,xshift=35]{Solution};
  \draw[thick]
  (0,3) [short, *-] node[left]{\textbf{RE \ }} to (0.1,3)
  to [R, l=$R_e$,color=green, bipole nodes={none}{none}] (3,3)
  (3,3) -- (3,4)
  to [cC, l=$C_d$,color=red, bipole nodes={none}{none}] (6,4) -- (6,3)
  to [short, -*] node[right]{\textbf{ \ WE}} (7,3)
  (3,3) -- (3,2) to [R, l_=$R_t$, color=yellow, bipole nodes={none}{none}]     (6,2) -- (6,3); 
    \end{circuitikz} 
\end{center}
\end{document}

The result can be found below. (Since I have a bunch of packages in the original document, I hope not to forget any for this case)

Circuit obtained

5
  • Welcome. // Sorry, nobody can see anything, as you didn't add a screenshot to your question. Your code won't compile the way it is: it is incomplete and gives an error (center). That's not our standard, here. Please EDIT your question accordingly.
    – MS-SPO
    Mar 20 at 6:56
  • See, if tex.stackexchange.com/questions/439536 can help you.
    – Zarko
    Mar 20 at 7:06
  • 1
    About colors, did you read ch. "7 Colors" and about the problems associated? See "Basically, you should have no problem if:" there. Manual: mirror.marwan.ma/ctan/graphics/pgf/contrib/circuitikz/doc/…
    – MS-SPO
    Mar 20 at 8:12
  • The node (better call it pole) is red because you set it in the to[R, color=red, *-] command. Try node[circ]{} to[R, color=red]...
    – Rmano
    Mar 20 at 15:33
  • @Rmano, I did something like that, but then the label "RE" cannot be placed at the left of the pole. I finally got a solution, maybe not the best, but it works. Thank you. Mar 20 at 16:58

2 Answers 2

3

If I extend your code fragment to an MWE (Minimal Working example) and aa wee bit change your code with every node/.append style = {font=\bfseries} to circuitikz option and add \ctikzset{bipoles/thickness=1} to scheme code body, I et the following result:

enter image description here

\documentclass[margin=3mm]{standalone}
\usepackage{circuitikz}

\begin{document}
       \begin{circuitikz}[
every node/.append style = {font=\bfseries}       
                        ]
\ctikzset{bipoles/thickness=1}
\draw[thick]
      (0,3) node[left]{RE} to [R, l=$R_e$,color=red,*-] (3,3)
      (3,3) -- (3,4)
      to [C, l=$C_d$] (6,4) -- (6,3)
      to [short, -*] (7,3)  node[right]{WE}
      (3,3) -- (3,2) to [R, l_=$R_t$] (6,2) -- (6,3);
      \draw[gray,thin,dashed](2.8,1) rectangle (6.2,5)
      node[pos=0,below,xshift=60]{Metal};
       \draw[cyan,thin,dashed](0.5,1) rectangle (2.5,5)
      node[pos=0,below,xshift=35]{Solution};
        \end{circuitikz} 
\end{document}
  • Your code can be further simplified, but let first clarify what is your problem. So far I guessing that culprit is in added \ctikzset.
  • Please edit your question, extend your code fragment to MWE, add image of scheme obtained by your code and by it clarify, what is the problem.

Addendum:

  • Sorry, but I was not able figured out what is your problem
  • So, my original answer above and slightly modified bel is based on guessing.
  • Both anticipate, that you lik that thickness of lines and elements are the same. This is achieved by added \ctikzset˙ with bipoles/thickness=1 (thickness of element drawing is defined relative to thickness of connections lines with given factor: 1 means the same thickness, 2 that element is draw with twice more thick lines, etc.).
  • Node on the right side of scheme is already black.
  • Node on the left is drawn as part of resistor $R_e$, so it has the sam color. To make it black, you can write it separately (see MWE below).
  • For shorter and consistent code in both MWE's are added nodes style definition.
  • Input and output nodes are writen on simpler, correct way.
  • To new MWE is added new capacitor style (as I prefer to be drawn)
  • in MWE below are for scheme used relative coordinates, for rectangle, which are drive by lines using orthogonal coordinates, are preserved for simplicity of code, absolute:

\documentclass[margin=3mm]{standalone}
\usepackage{circuitikz}

\begin{document}
       \begin{circuitikz}[
every node/.append style = {font=\bfseries},
  F/.style = {draw=#1, dashed},
lbl/.style = {font=\bfseries, text=#1, pos=0.25, below}
                        ]
\ctikzset{bipoles/thickness=1,
          bipoles/capacitor/height=0.4,
          bipoles/capacitor/width=0.1
          }
\draw[thick]
      (0,0) node[left] {RE}
            to [short, o-]          ++ (0.5,0)
            to [R=$R_e$,color=red]  ++ (1.5,0)
            to [short, -*]          ++ (0.7,0) coordinate (A)
            -- ++ (0,1)
            to [C=$C_d$]            ++ (1.5,0)
            -- ++ (0,-1) coordinate (B)
            to [short, *-o]         ++ (1,0)  node[right] {WE}
      (A)   -- ++ (0,-1)
            to [R=$R_t$]            ++ (1.5,0)
            -- ++ (0,1);
\draw[F=cyan]   (0.5,-1.5) -| ++ (1.5,3.5) node[lbl=cyan] {Solution} -| cycle;
\draw[F=gray]   (2.5,-1.5) -| ++ (2.0,3.5) node[lbl=gray] {Metal}    -| cycle;
        \end{circuitikz}
\end{document}
3
  • 1
    Thanks. My compile with the original code, extended, gave the same image. For me this doesn‘t really match the problem description …
    – MS-SPO
    Mar 20 at 7:50
  • 1
    @MS-SPO, you are right. Answerjust show, what OP codes produce, but as I mentioned in last sentence in answer, OP should clarify, what is the problem.
    – Zarko
    Mar 20 at 10:19
  • 1
    @Zarko I'm sorry for the problems in the question, it's my first time using this blog. I guess I forgot to add a document class and the package of circiutikz. There is no more options applied for this case. Anyway, I solved the problem of the node, and according to documentation of circuitikz, only the thickness of the elements can be modified. Conductors will remain the same. Correct me if I am mistaken. The image obtained with the code posted is the same as Zarko (but rentangle 'labels' are a little displaced to right) Mar 20 at 13:59
0

Thanks for updating your code and question.

Based on this here's a suggestion:

  • you don't need to draw the whole circuit in one path
  • use several \draw statements for it, i.e. at least one for components and one for connections (so you can chose thickness as needed)
  • the draw-options do hold for that path as given, either specified via [] for this one, or generalized via style, as shown in other answers here

To demonstrate I put a silly short, thickness 1/2pt, dashed into a separate \draw statement, and your original path with 5pt. It's still tikz, after all.

demo

circuitikz-thickness-and-colors?noredirect=1#comment1687761_680081

\documentclass{report}
\usepackage{xcolor,circuitikz}
\begin{document}

\begin{center}
   \begin{circuitikz}[scale=1.2]
      \draw[gray,thin,dashed,fill=gray!3]
            (2.8,1) rectangle (6.2,5)
                    node[pos=0,below,xshift=60]{Metal};
       \draw[cyan,thin,dashed,fill=cyan!4,opacity=0.5]
            (0.5,1) rectangle (2.5,5)
                    node[pos=0,below,xshift=35]{Solution};
                    
    % ~~~ suggestion:
    %     split this single path into several
    %     i.e. draw components and connections by several \draw statements
    
      \draw[line width=5pt]
        (0,3) [short, *-] node[left]{\textbf{RE \ }} to (0.1,3)
        to [R, l=$R_e$,color=green, bipole nodes={none}{none}] (3,3)
         (3,3) -- (3,4)
        to [cC, l=$C_d$,color=red, bipole nodes={none}{none}] (6,4) -- (6,3)
        to [short, -*] node[right]{\textbf{ \ WE}} (7,3)
        (3,3) -- (3,2) to [R, l_=$R_t$, color=yellow, bipole nodes={none}{none}]     (6,2) -- (6,3); 
        
      \draw [line width=.5pt, dashed] (0,3)  to [short](3,6);
    \end{circuitikz} 
\end{center}
\end{document}
2
  • 1
    oh men! just simple like that! I was specifying \draw command according to the thickness scale (very thin, thin, thick, etc) but that only affects the circuit elements. That is what I was looking for: a simple answer. This kind of dummy issues (almost) always have a simple solution, but the devil is in the details. Thank you so much! Mar 20 at 18:26
  • No problem: it takes a while to master Tikz and LaTeX. Wishing you great circuits.
    – MS-SPO
    Mar 20 at 18:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .