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

Load it:

%load_ext 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.

0.0.2 (2018-10-13)

  • Emit error messages.

0.0.3 (2018-10-16)

  • Add line magic usage

  • Change to load_ext pattern

0.0.4 (2018-10-16)

  • Add argparse parsing for line and cell magic

  • Add –temp-dir option to reduce clutter

  • Add –file_prefix for organization

0.0.5 (2018-10-16)

  • Add Quickstart notebook as a demo

  • Remove print statements introduced during debugging

0.0.6 (2018-10-16)

  • Add ITIKZ_TEMP_DIR environmental variable usage

  • Add –implicit-pic

0.0.7 (2018-10-16)

  • Add –scale arg

  • Add –tikz-libraries

  • Add –tex-packages

  • Add –implicit-standalone

0.0.8 (2018-10-16)

  • Add jinja2 templating

  • Add jinja2 interpolated code debug printing

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.8.tar.gz (10.8 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