Graphics, Figures & TablesError using circ (circuit) package

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
dpa2007
Posts: 16
Joined: Sat Apr 19, 2014 1:39 pm

Error using circ (circuit) package

Post by dpa2007 »

Greetings all,
practicing with the example at page 11:
http://texdoc.net/texmf-dist/doc/latex/circ/circ.pdf
i'm getting an error,same in LyX and TeXMaker and writelatex

"undefined control sequence \R1 {510 \kOhm} l
when i change the code to:
\R1 {510 $k\Omega$} l worked fine in all three editors.
where is the mistake...?

Code: Select all

\documentclass{standalone}
%\usepackage[european]{circuitikz}
\usepackage[basic,box,gate,oldgate,ic,optics,physics]{circ}
\begin{document}
\begin{circuit}0
\npn1 {?} B l 						 % transistor
\frompin npn1C						 % draw from collector 
\- 1 u								 % some wire 
\nl\A1 {$I_C$} u 	 				 % amperemeter for current of collector
\atpin npn1B		  				 % continue drawing from base
\- 1 l							     % some wire 
\R1 {510 \kOhm} l 
\- 1 l 			   				 % some wire to the edge
\centerto A1 		 				 % draw centered to amperemeter 1
\nl\A2 {$I_B$} u 	 				 % amperemeter 2
\frompin A2b 		 				 % link amperemeter 2 with resistor
\vtopin R1r 
\frompin A1t 
\- 1 u 
\.1							 	   % junction
\frompin A2t 						  % wire to amperemeter 2
\vtopin .1
\htopin .1
\- 1 u
\cc\connection1 {$U_b$} c u 		   % driving voltage
\frompin npn1E
\- 1 d 
\GND1						   	   % ground
\end{circuit}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Error using circ (circuit) package

Post by Stefan Kottwitz »

Sorry that I did not see your question before. Luckily you found a workaround.

Obviously the circ author defined it somewhere else as a macro, but did not mention it.

My recommendation would be, use the modern siunitx package with \kohm for this and for all expressions with units:

Code: Select all

\documentclass{standalone}
%\usepackage[european]{circuitikz}
\usepackage[basic,box,gate,oldgate,ic,optics,physics]{circ}
\usepackage{siunitx}
\begin{document}
\begin{circuit}0
\npn1 {?} B l                                            % transistor
\frompin npn1C                                           % draw from collector 
\- 1 u                                                           % some wire 
\nl\A1 {$I_C$} u                                         % amperemeter for current of collector
\atpin npn1B                                             % continue drawing from base
\- 1 l                                                       % some wire 
\R1 \SI{510}{\kohm} l 
\- 1 l                                                   % some wire to the edge
\centerto A1                                             % draw centered to amperemeter 1
\nl\A2 {$I_B$} u                                         % amperemeter 2
\frompin A2b                                             % link amperemeter 2 with resistor
\vtopin R1r 
\frompin A1t 
\- 1 u 
\.1                                                                % junction
\frompin A2t                                              % wire to amperemeter 2
\vtopin .1
\htopin .1
\- 1 u
\cc\connection1 {$U_b$} c u                % driving voltage
\frompin npn1E
\- 1 d 
\GND1                                                      % ground
\end{circuit}
\end{document}
Stefan
LaTeX.org admin
dpa2007
Posts: 16
Joined: Sat Apr 19, 2014 1:39 pm

Error using circ (circuit) package

Post by dpa2007 »

Thank you very much for your answer!
The siunitx package version is:
2013-08-19 23:0
the latest that my MikTeX installation offered.

i ran the code and i'm getting the following error code:
Package: siunitx 2013/07/31 v2.5s A comprehensive (SI) units package
! Package siunitx Error: Support package expl3 too old.
See the siunitx package documentation for explanation.
i cannot use siunitx in any of my examples.
i can't see any units in pdf.
is it possible to conflict siunitx package with siunits package that i have also installed...?

is it a MikTeX installation problem and i should update the installation?

thanks in advanced!
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Re: Error using circ (circuit) package

Post by Stefan Kottwitz »

I think you should update your MiKTeX installation. expl3 and related LaTeX3 packages are not up to date, advanced packages "on the edge" like siunitx (from a LaTeX3 developer) depend on current versions, it should be in sync. An update should fix it, at least of expl3 and l3* packages.

Stefan
LaTeX.org admin
dpa2007
Posts: 16
Joined: Sat Apr 19, 2014 1:39 pm

Re: Error using circ (circuit) package

Post by dpa2007 »

Thank you very much,i will update my installation as soon as possible.
dpa2007
Posts: 16
Joined: Sat Apr 19, 2014 1:39 pm

Re: Error using circ (circuit) package

Post by dpa2007 »

Same error after update.
is it possible to be a path problem?
miktex is installed in program files,and not under C:\
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Re: Error using circ (circuit) package

Post by Stefan Kottwitz »

Which version of MiKTeX are you using? The most recent one is 2.9 (quite a time not changed). If I would like to have a modern well maintained TeX, I would install TeX Live 2014, maintained by the international TeX User Group. MiKTeX is maintained by one man, who did great work, but I don't know it can keep up with TeX Live. Just if you might consider an update, an older version usually still works well for common cases.

Stefan
LaTeX.org admin
dpa2007
Posts: 16
Joined: Sat Apr 19, 2014 1:39 pm

Error using circ (circuit) package

Post by dpa2007 »

Hello again,
MiTeX v 2.9.4196 after the latest update.
I am thinking also to move to TeXLive,don't have any experience in TeXLive but i seriously consider to install it.
after a few hours searching the internet i found an circuitikz example,
http://www.texample.net/tikz/examples/circuitikz/
that syntax work for me.
converting my examples in that syntax i don't have any problem with preview pane in LyX and compilation also.
also texmaker works fine with modified examples.
i have also load the SIunits package,with amssymb specification
\usepackage[amssymb]{SIunits}
and some working examples:

Code: Select all

\begin{circuitikz}
\draw (0,0) to [C, l=$10\micro\farad$] (2,0);
\end{circuitikz}[/latex]

[latex]\begin{circuitikz}
\draw  (0,0)
	to[C, l=$10\micro\farad$] (0,2) -- (0,3)
  to[R, l=$2.2\kilo\ohm$] (4,3) -- (4,2)
  to[L, l=$12\milli\henry$, i=$i_1$] (4,0) -- (0,0)
 (4,2) to[D*, *-*] (2,0) to [D*, -*] (0,2)
  to[R, l=$1\kilo\ohm$] (2,2)
  to[cV, v=$0.3\kilo\ohm i_1$] (4,2)  (2,0)
  to[I, i=$1\milli\ampere$:15, -*] (2,2) ; 
\end{circuitikz}

\begin{circuitikz}
\draw
 (0,0) node[ground] {}   to[V, v=$e(t)$, *-*] (0,2) to[C, l=$4\nano\farad$] (2,2)
  to [R, l=$\frac{1}{4}\kilo\ohm$, *-*] (2,0)
 (2,2) to[R, l=$1\kilo\ohm$] (4,2)
  to[C, l=$2\nano\farad$:-90, *-*] (4,0)
 (5,0) to[I, i=$a(t)$:-90, -*] (5,2) -- (4,2)
 (0,0) -- (5,0)
 (0,2) -- (0,3) to[L, l=$2\milli\henry$] (5,3) -- (5,2)
 {[anchor=south east] (0,2) node {1} (2,2) node {2} (4,2) node {3}} ;\end{circuitikz}

\begin{circuitikz}
\draw
 (0,0) node[anchor=east]{B}
  to[short, o-*] (1,0)
  to[R, l=$20\ohm$, *-*] (1,2)
  to [R, v=$v_x$, l=$10\ohm$] (3,2)
  to[short] (4,2) to[cI, i=$\frac{\siemens}{5}v_x$, *-*] (4,0)
   to[short] (3,0) to[R, l=$5\ohm$, *-*] (3,2)
 (3,0) -- (1,0)
 (1,2) to[short, *-o] (0,2)
  node[anchor=east]{A} ;
\end{circuitikz}

\begin{circuitikz}
\draw
 (0,2) to[I, i=$1\milli\ampere$] (2,2)
  to [R, l=$2\kilo\ohm$:-90, *-*] (0,0)
  to [R, l=$2\kilo\ohm$] (2,0)
  to[V, v=$2\volt$:-90] (2,2)
  to[cspst, l=$t_0$] (4,2) -- (4,1.5)
  to [generic, l=1, i=$i_1$, v=$v_1$] (4,-.5) -- (4,-1)
 (0,2) -- (0,-1) to[V, v=$4\volt$] (2,-1)
  to [R, l=$1\kilo\ohm$] (4,-1);

 \begin{scope}[xshift=7.5cm, yshift=.5cm]
  \draw [->] (-2,0)--(2.5,0) node[anchor=west] {$v_1 [\volt]$};
  \draw [->] (0,-2)--(0,2) node[anchor=west] {$i_1 [\milli\ampere]$};
  \draw (-1,0) node[anchor=north] {-2} (1,0) node[anchor=south] {2}
   (0,1) node[anchor=west] {4} (0,-1) node[anchor=east] {-4} (2,0)
   node[anchor=north west] {4} (-1.5,0) node[anchor=south east] {-3};
  \draw [thick]
   (-2,-1) -- (-1,1) -- (1,-1) -- (2,0) -- (2.5,.5);
  \draw [dotted]
   (-1,1) -- (-1,0) (1,-1) -- (1,0) (-1,1) -- (0,1) (1,-1) -- (0,-1);  \end{scope}
\end{circuitikz}
Next steps will be the cooperation of circuitikz and SIunits,
and the installation of TeXLive after a little more experimenting with MikTeX
Thanks again for your help!
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Error using circ (circuit) package

Post by Stefan Kottwitz »

Nice to see, that it works! TeXample is a partner site, specifically I'm maintaining it too, on the same server like this forum.

Yes, circuitikz is a very good option with TikZ, while circ is MetaFont based. There's a third way, the circuits library of TikZ. circuitikz is a great package with some outstanding features like transistors, while the circuits library may be a bit more customizable using styles.

Wo got some circuits topics on out Germn partner site TeXwelt.de, if you are interested. Code and pictures may be understandable, google translate could help further, just to see what people are talking about this.

Another nice overview is in this matheplanet article by cis, there you can see pictures of circuits elements.

Stefan
LaTeX.org admin
dpa2007
Posts: 16
Joined: Sat Apr 19, 2014 1:39 pm

Re: Error using circ (circuit) package

Post by dpa2007 »

Thank you again for your advices!
Post Reply