0

If I try to compile the circuit in this answer, it gives me the weird error:

Undefined control sequence \draw

on the line

\draw (oa.+) -| (gnn) node[ground]{}; 

and the following ones.

I exactly copied the code in the answer, compiling it as it is, without modifications.

Is it normal? How could it be fixed?

  • 1
    Load circuitikz with option siunitx and use that integration as designed: V=1<\volt>, for example. The syntax may have changed since that answer was posted, which could explain the error. – Paul Gessler Mar 24 '15 at 18:24
  • @PaulGessler Thank you, it works! Do you want to write an answer? – BowPark Mar 24 '15 at 18:32
2

The siunitx integration has changed since the answer in question was written. Nowadays, you can use siunitx conveniently with circuitikz by loading circuitikz with the option siunitx and then using syntax of the form

R=1<\kilo\ohm>

and similarly for the others. These changes make the error message go away. Here's the fully corrected code:

\documentclass{article}  
\usepackage[american,siunitx]{circuitikz}  
\usetikzlibrary{positioning}  

\begin{document}  
\begin{circuitikz}[on grid]  
\draw   (0,1) node {Basic opamp};  
% Define coordinates and nodes  
\node (vi)  {};   
\node (a) [right=2 of vi] [label=below:$a$]{};  
\node[ground](gnn)  [below=1.0 of a,xshift=5mm] {};  
\node[ground](gnp)  [below=2.5 of vi] {};  
\node[op amp](oa)   [right=2 of a, yshift=-5mm]{};   
\node (vo)  [right=0.6 of oa.out]{};  
\node[ground](gnd)  [below=2 of vo] {};  

% connect coordinates, inputs, outputs, and components, i.e. draw the circuit  
\draw (gnp) to[V=1<\volt>] (vi);  
\draw (vi)  to[R=1<\kilo\ohm>] (oa.-);   
\draw (oa.+) -| (gnn) node[ground]{};  
\draw (oa.out)  to[short]   (vo);  
\draw (vo)  to[R=1<\kilo\ohm>]  (gnd);  
\end{circuitikz}  
\end{document}

enter image description here

Update: Maybe my code style is less than ideal or a little bit esoteric, but here is how I personally would code your circuit:

\documentclass{standalone}
\usepackage[american,siunitx]{circuitikz}

\begin{document}
\begin{circuitikz} \draw
  (0,0) node[op amp] (oa) {}
  (oa.out) to[short] ++(0.6,0) coordinate (vo)
  (oa.-) coordinate (a) node[below] {$a$}
  to[R,l_=1<\kilo\ohm>] ++(-2,0) coordinate (vi)
  ++(0,-2.25) node[ground] (gnp) {}
  to[V=1<\volt>] (vi)
  (vo) to[R=1<\kilo\ohm>] (vo |- gnp)
  node[ground] (gnd) {}
  (oa.+) to[short] ++(-0.25,0) node[ground] (gnn) {}
;\end{circuitikz}
\end{document}

The output is slightly different because I changed some spacings to my taste:

enter image description here

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.