Thursday 18 June 2009

Installing Latex packages inc circuitikz and siunitx




Not conforming to standards but simple:
mkdir ~/downloads/latex/circuitikz


Navigate to:
circuitikz

Save all the files to
 ~/downloads/latex/circuitikz 


Make sure .bashrc contains:

# for latex packages, installed to ~/latex/:
export TEXINPUTS=/home/login/downloads/latex//:


Open a terminal and run:
 sudo texhash 


Test:

\ctikzset{bipoles/length = 1.4 cm} % careful of whitespace here with /, and when using 5: NO WHITESPACE!
\begin{circuitikz}[scale = 1.2]
\draw (0, 0) node[anchor = east] {B}
to[short, o-*] (1,0)
to [R=20<\ohm>, *-*] (1,2)
to [R=10<\ohm>, v=$v_{x}$] (3,2) -- (4,2)
to [cI = $\frac{\siemens}{5} v_{x}$, *-*] (4,0) -- (3,0)
to [R = 5<\ohm>, *-*] (3,2) % no whitespace between 5 and
(3,0) -- (1,0)
(1,2) to [short, -o] (0,2) node[anchor = east] {A};
\end{circuitikz}


Beware whitespaces (as noted). Do not use them between numbers and units, or the following error will occur:

! Package siunitx Error: Invalid character `20 ' in numerical input.

See the siunitx package documentation for explanation.
Type H for immediate help.
...

l.44 to [R=20 <\ohm>, *-*] (1,2)
^^M


Turns out, circuitikz required siunitx also, and the manual wasn't so helpful in that
only a .pdf was present, and copy/paste from the .pdf changed the * and - characters.

So, check http://home.dei.polimi.it/mredaelli/circuitikz/examples.html
for real examples but consider also, siunitx - if you were wondering why 1*10^{5} looks
so crap in tex!

3 comments:

  1. oh! this is the simplest example of circuitikz I have found :D thanks, I'm having a lot of problems drawing circuits.

    ReplyDelete
    Replies
    1. Thanks for commenting, estebarb! :) I'm glad it helped. I didn't realise you'd commented until now (2015!).
      m.

      Delete
    2. Thanks for commenting, estebarb! :) I'm glad it helped. I didn't realise you'd commented until now (2015!).
      m.

      Delete