nschloe / tikzplotlib

:bar_chart: Save matplotlib figures as TikZ/PGFplots for smooth integration into LaTeX.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Underscore in filenames in included graphics

Sbozzolo opened this issue · 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.

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.)

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}

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.