Search code examples
pathgnuplot

Gnuplot epslatex files output path problem


I have a problem in Gnuplot. When I set the output filename with a relative path to save the .tex and .eps files in a different folder, the relative path is also included in the \includegraphics command in the .tex file.

For example, if I set the output file to be two levels above the current directory:

set terminal epslatex color size 6, 3
# ...
set output "../../filename.tex"
# ...

The \includegraphics command keeps that path when the file is already two levels above and searches two extra levels above of that directory instead of searching in the current directory:

% ...
\put(0,0){\includegraphics{../../filename}}%
% ...

It would be great to fix this issue in future versions, allowing to set the output path and file name (that appears in \includegraphics command) separately.


Solution

  • Work-around:

    Instead of including the full path (or relative path) in the file name, set it temporarily as your working directory:

     olddir = system("pwd")
     cd '../..'
     set output "filename.tex"
     plot <whatever>
     cd olddir