Load TikZ magic:


In [1]:
%load_ext tikzmagic

Single command figure:


In [2]:
%tikz \draw (0,0) rectangle (1,1);


Multi command figure:


In [3]:
%%tikz
\draw (0,0) rectangle (1,1);
\filldraw (0.5,0.5) circle (.1);


Add a LaTeX preamble defining a custom color:


In [4]:
preamble = '''
    \definecolor{myblue}{RGB}{66,164,233}
'''

In [5]:
%%tikz -x $preamble
\draw[fill=myblue] (0,0) rectangle (1,1);


Set custom scaling factor and figure size and generate jpg output:


In [6]:
%%tikz --scale 2 --size 300,300 -f jpg
\draw (0,0) rectangle (1,1);
\filldraw (0.5,0.5) circle (.1);


Set custom scaling factor and figure size and generate svg output:


In [7]:
%%tikz --scale 2 --size 300,300 -f svg
\draw (0,0) rectangle (1,1);
\filldraw (0.5,0.5) circle (.1);


Set custom scaling factor and figure size and generate png output:


In [8]:
%%tikz -s 400,400 -sc 1.2 -f png
\draw [style=help lines, step=2]                (-1,-1)    grid        (+7,+7);
\draw [line width=0.5mm, fill=blue!40!white]    (+2,+2)    rectangle    (+4,+4);
 
\draw [blue!60!white] (  2,  2) node[anchor=north east] {$(i  ,j  )$};
\draw [blue!60!white] (  4,  2) node[anchor=north west] {$(i+1,j  )$};
\draw [blue!60!white] (  4,  4) node[anchor=south west] {$(i+1,j+1)$};
\draw [blue!60!white] (  2,  4) node[anchor=south east] {$(i  ,j+1)$};

\filldraw [color=gray]    (0,0) circle (.1);
\filldraw [color=gray]    (0,2) circle (.1);
\filldraw [color=gray]    (0,4) circle (.1);
\filldraw [color=gray]    (0,6) circle (.1);
\filldraw [color=gray]    (2,0) circle (.1);
\filldraw [color=black]    (2,2) circle (.1);
\filldraw [color=black]    (2,4) circle (.1);
\filldraw [color=gray]    (2,6) circle (.1);
\filldraw [color=gray]    (4,0) circle (.1);
\filldraw [color=black]    (4,2) circle (.1);
\filldraw [color=black]    (4,4) circle (.1);
\filldraw [color=gray]    (4,6) circle (.1);
\filldraw [color=gray]    (6,0) circle (.1);
\filldraw [color=gray]    (6,2) circle (.1);
\filldraw [color=gray]    (6,4) circle (.1);
\filldraw [color=gray]    (6,6) circle (.1);


Load figure from file:


In [9]:
%%tikz -s 400,400 -sc 1.2 -f png
\input{grid.tikz}


Load TikZ libraries:


In [10]:
%%tikz -l arrows,matrix -f svg
\matrix (m) [matrix of math nodes, row sep=3em, column sep=4em] {
A & B \\
C & D \\
};
\path[-stealth, line width=.4mm]
(m-1-1) edge node [left ] {$ac$} (m-2-1)
(m-1-1) edge node [above] {$ab$} (m-1-2)
(m-1-2) edge node [right] {$bd$} (m-2-2)
(m-2-1) edge node [below] {$cd$} (m-2-2);


Load LaTeX packages:


In [11]:
%%tikz -p pgfplots -f svg
\begin{axis}[
  xlabel=$x$,
  ylabel={$f(x) = x^2 - x +4$}
]
\addplot {x^2 - x +4};
\end{axis}


Choose utf-8 encoding:


In [12]:
%%tikz -p kotex -e utf-8
\node {unicode}
child {node {한글}}
child {node {Korean}
};