Skip to main content

Cell magic for PGF/TikZ-to-SVG rendering in Jupyter

Project description

itikz

https://img.shields.io/pypi/v/itikz.svg https://img.shields.io/travis/jbn/itikz.svg Documentation Status

Cell magic for PGF/TikZ-to-SVG rendering in Jupyter

Usage

Install it:

pip install itikz

Import it:

import itikz

Use it (this example from Austin):

%%itikz
\documentclass[tikz]{standalone}

\newcommand{\tikzAngleOfLine}{\tikz@AngleOfLine}
    \def\tikz@AngleOfLine(#1)(#2)#3{%
        \pgfmathanglebetweenpoints{%
        \pgfpointanchor{#1}{center}}{%
        \pgfpointanchor{#2}{center}}
    \pgfmathsetmacro{#3}{\pgfmathresult}%
    }

\newcommand{\tikzMarkAngle}[3]{
    \tikzAngleOfLine#1#2{\AngleStart}
    \tikzAngleOfLine#1#3{\AngleEnd}
    \draw #1+(\AngleStart:0.4cm) arc (\AngleStart:\AngleEnd:0.4cm);
}

\begin{document}
    \begin{tikzpicture}
        \coordinate (O) at (0, 0);
        \coordinate (z) at (3, 3);
        \coordinate (a) at (3, 0);

        \draw [->, thick] (-1, 0) -- (5, 0);
        \draw [->, thick] (0, -1) -- (0, 5);

        \draw (O) -- (z);
        \draw (O) -- (z) node[above, midway]{$r$};
        \draw (a) -- (z) node[right, midway]{$a$};
        \draw (O) -- (a) node[below, midway]{$b$};

        \draw (z) node[circle, fill, inner sep=1pt]{} node[right]{$z$};
        \draw (O) node[left, yshift=-0.25cm]{$O$};
        \draw (O) node[xshift=0.55cm, yshift=0.2cm]{$\phi$};

        \tikzMarkAngle{(O)}{(a)}{(z)}
    \end{tikzpicture}
\end{document}

Todo

Add argparse options for optional non-removal of artifacts.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.0.1 (2018-10-12)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

itikz-0.0.1.tar.gz (9.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page