jbn / itikz

Cell and line magic for PGF/TikZ-to-SVG rendering in Jupyter notebooks
MIT License
62 stars 9 forks source link

Symbols gets messed up in Notebook #28

Open buergi opened 3 years ago

buergi commented 3 years ago

Description

In the first cell I'm trying to write D_p which works, in the second one I'm writing S_p and it writes D_p as well. grafik

Same here, but even the numbers are messed up. grafik

The generated SVG is correct, it seems the problem is that the browser seems to mix the content of the nodes when multiple SVGs are embedded in one notebook. I have now idea if this is possible, but it seems to be the case. Any ideas how to fix this?

What I Did

Here is the code again

%load_ext itikz

%%itikz --implicit-pic --temp-dir
\node at (0,0) {$D_p = 200 \mathrm{mm}$};
\node at (5,0) {$S_p = 200 \mathrm{mm}$};

%%itikz --implicit-pic --temp-dir
\node at (0,0) {$A_p = 500 \mathrm{mm}$};
\node at (7,0) {$B_p = 500 \mathrm{mm}$};
spielhuus commented 3 years ago

The problem seems to be pdf2svg. it creates the same id's in all the pictures, but with embedded SVG images, they have to be unique over the whole page. dvisvgm seems to work. I have uninstalled pdf2svg and created a shell script that calls dvisvgm.

/usr/bin/pdf2svg

!/bin/bash

dvisvgm --pdf --output=$2 $1

it would be great if pdf2svg would be replaced with dvisvgm in itikz.

tombackstrom commented 2 years ago

If you do not have the root credentials to access /usr/bin/ and if you're using anconda, then you can apply @spielhuus solution but put the script in your anaconda3/bin -folder instead.

In addition, on my system, dvisvgm outputs a status message, which gets displayed as an error message in the notebook. To reduce verbosity, change the script to

#!/bin/bash
dvisvgm --pdf --output=$2 -v0 $1