Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider the following MWE. If \tikzpicturedependsonfile is commented out, the code runs as expected. A.dep is created stating the dependency of A.pdf on A.dat. Now, lets try to add the tikz source file A.tikz as a dependency.

However, if \tikzpicturedependsonfile is included in the code, then \tikzsetnextfilename does not have any effect and main-figure0.pdf is created instead of A.pdf.

MWE:

\documentclass{report}
\usepackage{tikz,tikzscale,pgfplots,pgfplotstable}
\pgfplotsset{compat=1.7}
\usetikzlibrary{external}
\tikzexternalize[mode=list and make]
%
\begin{filecontents}{A.tikz}
  \begin{tikzpicture}
    \begin{axis}
      \addplot [] table [header=false] {A.dat};
    \end{axis}
  \end{tikzpicture}
\end{filecontents}
%
\begin{filecontents}{A.dat}
  1 1 
  2 2 
\end{filecontents}
%
\begin{document}
  \newcommand{\figFilename}{}
  \renewcommand{\figFilename}{A}
  \tikzsetnextfilename{\figFilename}
  \tikzpicturedependsonfile{\figFilename.tikz}
  \input{\figFilename.tikz}
\end{document}

The aim of this activity is to add the source file (A.tikz) for the tikzpicture to the dependency along with the data file (A.dat) which is added by default. Once this is achieved, any time a tikzpicture has been edited, it will get recompiled automatically.

share|improve this question

2 Answers 2

up vote 6 down vote accepted

This is a bug in the external library (present in PGF 2.10 and the copy shipped with pgfplots 1.7).

I have fixed it; it will be contained in the next PGF release. An updated copy is also shipped with pgfplots releases (provided you say \usepgfplotslibrary{external} instead of the tikz one).

The effect of the bug is that "get next filename" resets (a) the value which has been set by \tikzsetnextfilename and (b) the value of export next.

If you cannot wait, a work-around appears to be to move \tikzsetnextfilename after your line with \tikzpicturedependsonfile.

share|improve this answer
    
Do you perhaps know, when will the next official PGF/TikZ release be available? It is about 2.5 years since the last one. –  Pygmalion Jun 3 '13 at 8:34

Same cause as your other question (tikzscale and \tikzsetnextfilename do not work together), the filename gets globally reset after any call to \tikzexternalgetnextfilename. In this case, such a call is made by \tikzpicturedependsonfile. This one surely is a bug in TikZ!

Workaround (get \tikzpicturedependsonfile to reset the name if it calls \tikzexternalgetnextfilename):

\documentclass{report}
\usepackage{tikz,pgfplots,pgfplotstable}
\pgfplotsset{compat=1.7}
\usetikzlibrary{external}

\makeatletter
\def\tikzpicturedependsonfile@ACTIVE#1{%
    \begingroup
    \tikzexternalgetcurrentfilename\tikzpicturedependsonfile@name
    \ifx\tikzpicturedependsonfile@name\pgfutil@empty
        \tikzexternalgetnextfilename\tikzpicturedependsonfile@name
        \expandafter\tikzsetnextfilename\expandafter{\tikzpicturedependsonfile@name}
    \fi
    \expandafter\tikzexternalfiledependsonfile\expandafter{\tikzpicturedependsonfile@name}{#1}%
    \endgroup
}%
\makeatother

\tikzexternalize[mode=list and make]
%
\begin{filecontents}{A.tikz}
  \begin{tikzpicture}
    \begin{axis}
      \addplot [] table [header=false] {A.dat};
    \end{axis}
  \end{tikzpicture}
\end{filecontents}
%
\begin{filecontents}{A.dat}
  1 1 
  2 2 
\end{filecontents}
%
\begin{document}
  \newcommand{\figFilename}{}
  \renewcommand{\figFilename}{A}
  \tikzsetnextfilename{\figFilename}
  \tikzpicturedependsonfile{\figFilename.tikz}
  \input{\figFilename.tikz}
\end{document}
share|improve this answer
    
Lets wait for @christian-feuersanger 's comment. –  devendra Dec 19 '12 at 1:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.