#!/usr/bin/env python # coding: utf-8 # # IPython extension for drawing circuit diagrams with LaTeX/Circuitikz # Robert Johansson # # [http://github.com/jrjohansson/ipython-circuitikz](http://github.com/jrjohansson/ipython-circuitikz) # ## Requirements # This IPython magic command uses the following external dependencies: `pdflatex`, `pdfcrop`, the [Circuitikz](http://www.ctan.org/pkg/circuitikz) package and # # * for PNG output: `convert` from ImageMagick # * for SVG output: `pdf2svg` # ## Installation # In[1]: get_ipython().run_line_magic('install_ext', 'http://raw.github.com/jrjohansson/ipython-circuitikz/master/circuitikz.py') # ## Load the extension # In[2]: get_ipython().run_line_magic('reload_ext', 'circuitikz') # ## Example: SQUID # In[3]: get_ipython().run_cell_magic('circuitikz', 'filename=squid dpi=125', '\n\\begin{circuitikz}[scale=1]\n\\draw ( 0, 0) [short, *-] node[anchor=south] {$\\Phi_J$} to (0, -1);\n\n% right\n\\draw ( 0, -1) to (2, -1) to node[anchor=west] {$\\Phi_{J}^2$} (2, -2) to (3, -2)\n to [barrier, l=$E_J^2$] (3, -4) to (2, -4)to (2, -5) to (0, -5) node[ground] {};\n\\draw ( 2, -2) to (1, -2) to [capacitor, l=$C_J^2$] (1, -4) to (1, -4) to (2, -4);\n\n% left\n\\draw ( 0, -1) to (-2, -1) to node[anchor=west] {$\\Phi_{J}^1$} (-2, -2) to (-3, -2)\n to [capacitor, l=$C_J^1$] (-3, -4) to (-2, -4) to (-2, -5) to (0, -5); \n\\draw (-2, -2) to (-1, -2) to [barrier, l=$E_J^1$] (-1, -4) to (-1, -4) to (-2, -4);\n\\end{circuitikz}\n') # ## Example: Transmission line # In[4]: get_ipython().run_cell_magic('circuitikz', 'filename=tm dpi=150', '\n\\begin{circuitikz}[scale=1.25]\n\n\\draw (-1,0) node[anchor=east] {} to [short, *-*] (1,0);\n\\draw (-1,2) node[anchor=east] {} to [inductor, *-*, l=$\\Delta x L$] (1,2);\n\\draw (-1,0) to [open, l=$\\cdots$] (-1,2); \n\\draw (3, 0) to (1, 0) to [capacitor, l=$\\Delta x C$, *-*] (1, 2) to [inductor, *-*, l=$\\Delta x L$] (3, 2);\n\\draw (5, 0) to (3, 0) to [capacitor, l=$\\Delta x C$, *-*] (3, 2) to [inductor, *-*, l=$\\Delta x L$] (5, 2);\n\\draw (7, 0) to (5, 0) to [capacitor, l=$\\Delta x C$, *-*] (5, 2) to [inductor, *-*, l=$\\Delta x L$] (7, 2);\n\\draw (9, 0) to (7, 0) to [capacitor, l=$\\Delta x C$, *-*] (7, 2) to [inductor, *-*, l=$\\Delta x L$] (9, 2);\n\\draw (9,0) node[anchor=east] {} to [short, *-*] (9,0);\n\\draw (10,0) to [open, l=$\\cdots$] (10,2);\n\n\\end{circuitikz}\n')