<jupyter_start><jupyter_text>Load TikZ magic:<jupyter_code>%load_ext tikzmagic<jupyter_output><empty_output><jupyter_text>Single command figure:<jupyter_code>%tikz \draw (0,0) rectangle (1,1);<jupyter_output><empty_output><jupyter_text>Multi command figure:<jupyter_code>%%tikz
\draw (0,0) rectangle (1,1);
\filldraw (0.5,0.5) circle (.1);<jupyter_output><empty_output><jupyter_text>Add a LaTeX preamble defining a custom color:<jupyter_code>preamble = '''
    \definecolor{myblue}{RGB}{66,164,233}
'''
%%tikz -x $preamble
\draw[fill=myblue] (0,0) rectangle (1,1);<jupyter_output><empty_output><jupyter_text>Set custom scaling factor and figure size and generate jpg output:<jupyter_code>%%tikz --scale 2 --size 300,300 -f jpg
\draw (0,0) rectangle (1,1);
\filldraw (0.5,0.5) circle (.1);<jupyter_output><empty_output><jupyter_text>Set custom scaling factor and figure size and generate svg output:<jupyter_code>%%tikz --scale 2 --size 300,300 -f svg
\draw (0,0) rectangle (1,1);
\filldraw (0.5,0.5) circle (.1);<jupyter_output><empty_output><jupyter_text>Set custom scaling factor and figure size and generate png output:<jupyter_code>%%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);<jupyter_output><empty_output><jupyter_text>Load figure from file:<jupyter_code>%%tikz -s 400,400 -sc 1.2 -f png
\input{grid.tikz}<jupyter_output><empty_output><jupyter_text>Load TikZ libraries:<jupyter_code>%%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);<jupyter_output><empty_output><jupyter_text>Load LaTeX packages:<jupyter_code>%%tikz -p pgfplots -f svg
\begin{axis}[
  xlabel=$x$,
  ylabel={$f(x) = x^2 - x +4$}
]
\addplot {x^2 - x +4};
\end{axis}<jupyter_output><empty_output><jupyter_text>Choose utf-8 encoding:<jupyter_code>%%tikz -p kotex -e utf-8
\node {unicode}
child {node {한글}}
child {node {Korean}
};<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20411927451583153, 'fraction_numerical': 0.05502612972640639, 'mean_word_length': 4.863063063063063, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '312518', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1480, 'n_tokens_neox': 1402, 'n_words': 312, 'path': 'tikzmagic_test.ipynb', 'repo_name': 'DavidPowell/ipython-tikzmagic', 'size': '3253'}