tikzplotlib icon indicating copy to clipboard operation
tikzplotlib copied to clipboard

Underscore in filenames in included graphics

Open Sbozzolo opened this issue 4 years ago • 3 comments

I didn't manage to simplify my code enough to generate a MWE because I don't understand when tikzplotlib decides to include the figure as external graphics. tikzplotlib 0.9.9 generated a file containing the following line

\addplot graphics [includegraphics cmd=\pgfimage,xmin=0, xmax=20, ymin=0, ymax=20] {MRI_quality_xy-000.png}

This won't compile because the underscores are not properly escaped. The correct one is

\addplot graphics [includegraphics cmd=\pgfimage,xmin=0, xmax=20, ymin=0, ymax=20] {MRI\_quality\_xy-000.png}

EDIT: I should have said: the latter compile (the former throws an error), but it doesn't seem to find the image. So, neither seems correct.

Sbozzolo avatar Aug 03 '21 18:08 Sbozzolo

An easy way to solve it would be to rename your image...

Just one question: Are your images saved in a subfolder, e.g., images? Then this path would also need to be given here, e.g., {images/MRI_quality_xy-00.png}.

(The option tex_relative_path_to_data allows to give a path which is automatically included. Unfortunately, for Windows the dashes are \, and therefore the option is not working, and you need to do this manually. See #509 that I just created.)

IsabellLehmann avatar Sep 09 '21 13:09 IsabellLehmann

An easy way to solve it would be to rename your image...

That's what I did. But it is not a solution, it is a workaround.

Just one question: Are your images saved in a subfolder, e.g., images? Then this path would also need to be given here, e.g., {images/MRI_quality_xy-00.png}.

Correct, I have the images a figures folder, so the directive ended up being {figures/MRIL}

Sbozzolo avatar Sep 09 '21 14:09 Sbozzolo

I think normally it should work unless you do something like using underscore package. graphics - Incompatibility of underscore package and includegraphics if there is an underscore in the file name - TeX - LaTeX Stack Exchange so it isn't really an issue with this package.

user202729 avatar Mar 30 '23 11:03 user202729