This is the jupytexmagic module.
Project description
Why jupytex?
This is a python package for rendering LaTeX in Jupyter notebook with native rendering capabilities. Jupyter uses MathJax to render LaTeX inside of Markdown cells, which is fine for most use cases; however, this does not provide the full set of tools that LaTeX has to offer (e.g. tikzpictures, complex figures). What we want is the ability to write content using Jupyter for dynamic content while not sacrificing the beauty of native LaTeX.
How Does it Work?
This is a custom ipython magic plugin
which allows users to create a new code cell, placing %%tex
at the top and
then put all of their LaTeX source code afterwards. Running the cell compiles
the code into .svg
format which is displayed following the cell.
Jupytex uses pdflatex
to compile your cell's code into PDF format, then
pdfcrop
to crop the content, and pdf2svg
to convert the PDF to .svg
format. Then this is displayed using the IPython module. The compilation is
fast, and has the upside of your LaTeX not needing to be rendered with
Javascript when viewed on the web.
The .svg
format is great because it doesn't lose any definition upon
zooming in on the compiled LaTeX and you can highlight text with your cursor,
which you cannot do with normal image formats like PNG/JPEG.
Usage
- run
pip install jupytexmagic
- create a new cell with
import jupytexmagic
and%load_ext jupytexmagic
- have fun! for tex cells, place
%%tex
at the top of your cell Note: see test/jupytexmagic.ipynb for an example run
If your tex compilation fails, you can use the %%texdebug
magic command
to display the output of pdflatex
when compiling for debugging purposes.
Current Limitations
Because jupytex presents the compiled LaTeX in .svg
format, it assumes
a standard page layout. Currently texify()
crops to content; although there
are slight things that are off about the margins. The goal is to fix this in
the next release!
Tests directory
Currently this directory contains a screenshot and jupytexmagic.ipynb
, a
notebook example run. Some ideas for testing could be to use selenium for
screenshotting and comparing images with known working versions.
Example Run Screenshot
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for jupytexmagic-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54c34d460ae0a900b3af7a9c5c9aeaaf5453e283f82f884bc68bf371163d03f5 |
|
MD5 | 39f8f806d241120f53ac89bcd14f2a4c |
|
BLAKE2b-256 | 710effd29a27a53ad118e6687d3b2e83a63be0ba0e05e9793b5e6514d17b2f93 |