Installation
Prerequisites
Jupyter-TikZ is a Python (3.10+) and IPython Magics library. However, in order for Jupyter-TikZ to work properly, some non-Python dependencies need to be installed first:
- LaTeX
- Poppler
LaTeX
LaTeX must be installed using one of the following distributions:
You can test if a LaTeX distribution is installed by using the following command:
pdflatex --version
© 1982 D. E. Knuth, © 1996-2023 Hàn Thế Thành
TeX is a trademark of the American Mathematical Society.
Poppler
This application requires Poppler's pdftocairo. You must install it beforehand.
Conda - Platform Independent
conda install -c conda-forge poppler
Windows
Download Poppler for Windows here. You must add the bin folder to your PATH.
Linux
Most distributions come with pdftocairo. If it is not installed, refer to your package manager to install poppler-utils.
Mac
Install using brew:
brew install poppler
Checking the Installation
Finally, you can check if the pdftocairo utility is installed by using the following command in your terminal:
pdftocairo -v
Copyright 2005-2024 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1996-2011, 2022 Glyph & Cog, LLC
Using custom pdftocairo path
Alternatively, if you are facing issues, you can configure the pdftocairo location (exclusive for use in jupyter_tikz) by setting the environment variable JUPYTER_TIKZ_PDFTOCAIROPATH:
import os
custom_pdftocairo_path = os.path.join(
os.getenv("LOCALAPPDATA"), "Poppler", "Library", "bin", "pdftocairo.exe"
) # (1)!
os.environ["JUPYTER_TIKZ_PDFTOCAIROPATH"] = custom_pdftocairo_path
- The directory of
pdftocairobinary.
Jinja2
Note
Since version 0.5, Jinja2 is installed automatically, so it is no longer necessary to install this dependency manually.
Install Jupyter TikZ
You can install jupyter-tikz by using the following command in your terminal:
pip install jupyter-tikz # (1)!
- You can install with your favorite package manager, i.e.,
poetry.
Adding TikZ Syntax highlight
If you are using Jupyter Lab 4. You can add LaTeX highlight to %%tikz magic cells by using JupyterLab-lsp and editing this part of the code in JupyterLab-lsp in the file extractor.ts:
new RegExpForeignCodeExtractor({
language: 'latex',
pattern: '^%%(latex|tikz)( .*?)?\n([^]*)', // Add tikz support to this line
foreignCaptureGroups: [3],
isStandalone: false,
fileExtension: 'tex'
}),
Now, you will have LaTeX syntax code highlighting for %%tikz magic cells, as demonstrated below:

For more information refer to this link.