itikz icon indicating copy to clipboard operation
itikz copied to clipboard

Problem multiple itikz images in a single notebook

Open jeroenvuurens opened this issue 6 years ago • 4 comments

  • itikz version: 0.1.3
  • Python version: 3.7.1
  • Operating System: Ubuntu 18.04

Description

I am experiencing problems when a notebook contains more than one itikz drawing. Somehow the text labels in the second drawing is corrupted. In the below example, if you enter the code into three separate cells, in the second plot instead of a and y the text labels show x and z.

What I Did

%load_ext itikz

%%itikz --implicit-pic --file-prefix aa- --tikz-libraries=positioning,shapes,shadows,arrows \tikzstyle{node}=[circle, draw=black, text centered, text width=0.5cm] \node[node] (I-0) at (0,-0) {$x$}; \node[node] (O-0) at (3,-0) {$z$};

%%itikz --implicit-pic --file-prefix ab- --tikz-libraries=positioning,shapes,arrows \tikzstyle{node}=[circle, draw=black, text centered, text width=0.5cm] \node[node] (I-0) at (0,0) {$a$}; \node[node] (G-0) at (3,-0) {$y$};

jeroenvuurens avatar Jun 17 '19 11:06 jeroenvuurens

Sorry for the delay!

I think I know what's happening. Are you using Jupyter lab or Jupyter notebook? I'm assuming the latter, as I replicated the problem in notebook but failed to do so in lab. If you're using notebook, give it a try in lab and see if the problem persists. (I don't mean this as a solution; it's diagnostic.)

jbn avatar Jul 05 '19 16:07 jbn

It does work with jupyter lab but still failed with nbconvert which is not convenient for any command line conversion in scripts.

darrivau avatar Nov 19 '19 18:11 darrivau

I'm not sure if there is an easy fix here. The SVGs are isolated at generation time so you can extract them and process accordingly, but in a joined document they share IDs and get garbled. It would be nice if there was a way to mangle identifiers so they didn't do this but I'm not aware of a simple way of doing so.

(Leaving this open in case anyone does find one.)

jbn avatar Jan 04 '20 17:01 jbn

How do you work around this problem? I've resorted to using itikz to generate an SVG and then just drop the cell and embed the result (as an image). I wish there was a better option!

vargonis avatar Oct 12 '20 09:10 vargonis