Closed RafaelArutjunjan closed 4 years ago
Yeah, that should be fixed. Feel free to do a PR.
From my current understanding of the architecture of the JuliaTeX ecosystem it would probably be best to modify the TEX() function?
When saving a particular TikzPicture, there could be a check whether it contains objects of type Image (I have not idea how one would best implement such a check concretely). If so, perform a second check whether the files are to be saved to a different directory and add the necessary directory prefix to all the .png files to be saved.
I'm thinking something along the lines of:
# Check if Plottable contains Objects of type Image
if occursin('/',filename)
prefix = filename[1:findlast('/',filename)]
# prepend the prefix containing the path of the directory to the filename of all the Image Objects such that
# "tmp_0000001.png" -> prefix * "tmp_0000001.png"
end
A secondary question that must be answered is whether the plotHelper() function should be modified as well. That is, should the reference in the \addplot command also be modified from "tmp_0000001.png" to "SomeFolder/tmp_0000001.png"? Should the user be given a choice through some global variable?
For my personal use case, I would like to save source files in some folder and import them into larger tex documents via \input{SubFolder/MyPlot.tex}. Therefore, the code in "MyPlot.tex" would have to reference the directory "SubFolder" for the image. On the other hand, one can globally add a list of image directories in LaTeX via \graphicspath{{SubFolder/}}, eliminating the need for a reference to "SubFolder" in "MyPlot.tex". As a result, I don't feel that a modification of the plotHelper() function is necessary.
Any input on how to practically implement this would be appreciated.
Actually, can't you just do this?
save("Subfolder/ImagePlot.tex", PGFPlots.Image(f, (-2,2), (-2,2), filename="Subfolder/ImagePlot.png"))
You're right, that is exactly the kind of fix I was looking for - I feel kind of stupid that I didn't recognize this myself.
Thank you for your help!
When saving an image plot to a .tex file in a subfolder using the save() function, the .png that is generated still ends up in the parent directory.
Minimal example for some function f:
save("Subfolder/ImagePlot.tex", PGFPlots.Image(f, (-2,2), (-2,2)))
The ImagePlot.tex file will be in "Subfolder", however, the image file "tmp_10000000000001.png" is saved to the same folder as the Julia file.It would be nice to be able to keep the two source files together. Is there maybe some quick fix that I am missing?