pgf-tikz / pgf

A Portable Graphic Format for TeX
https://pgf-tikz.github.io/
1.12k stars 106 forks source link

Gnuplot can't find the file when `$aux_dir` is set #1334

Open jdujava opened 4 months ago

jdujava commented 4 months ago

Brief outline of the bug

When compiling via latexmk with nontrivial $aux_dir, the ___.gnuplot file is put under aux_dir. Because the invocation of gnuplot tries to find it in project root directory, it can not produce ___.table.

There is a following workaround, namely manually changing directory to aux_dir before calling gnuplot

\pgfkeys{/pgf/plot/gnuplot call={cd `aux_dir` && gnuplot}}

However, this is rather impractical.

Is there a possibility to implement something like remembering full path of ___.gnuplot file (or relative path to root of project), and automatically changing directory before invoking gnuplot? This would have the advantage of automatically working with packages like robust-externalize, which can put (some) files in different directories.

Minimal working example (MWE)

# .latexmkrc
$aux_dir = '.aux';
$pdflatex = 'pdflatex --shell-escape';
% example.tex
\documentclass[a4paper,12pt]{article}

\usepackage{tikz}

%% Without following line, invocation of gnuplot will not find ___.gnuplot file
% \pgfkeys{/pgf/plot/gnuplot call={cd .aux && gnuplot}}

\begin{document}

\section{Minimal Working Example}

\begin{tikzpicture}[domain=0:4]
    \draw[domain=-3.141:3.141,smooth] plot[parametric,id=parametric-example] function{t*cos(t),t*sin(t)};
\end{tikzpicture}

\end{document}
muzimuzhi commented 4 months ago

@user202729's answer to TeX-SX question "Access value of -output-directory" may help.