#StackBounty: #tikz-pgf #pgfplots #tikz-external #tabu pgf/tikz externalization + tabu: makefile and legend to name problems

Bounty: 50

I am having troubles with the combination of tabu and pgf/tikz exernalization.
Please consider the code snippet below which I try to compile using lualatex or pdflatex using texlive 2018.

documentclass{book}

usepackage{filecontents}
newcommand{legendname}{defaultlegendname}

begin{filecontents*}{test.tikz}
tikz{begin{axis}[
        width=4cm,height=4cm,
        ]
        addplot +[]%
        table[row sep=crcr] {%
            1 1\
            2 4\
        };
        label{testAAA}
    end{axis}
    begin{axis}[
        legend to name=legendname,
        width=4cm,height=4cm,
        at={(4.1cm,0cm)}
        ]
        %
        addlegendimage{/pgfplots/refstyle={testAAA}}addlegendentry{AAA}%
        addplot +[red]%
        table[row sep=crcr] {%
            1 2\
            5 10\
        };
        addlegendentry{BBB}%
end{axis}}

end{filecontents*}

usepackage{tikz,pgfplots,pgfplotstable,subcaption,tabu}
usetikzlibrary{external}
tikzexternalize[mode=list and make]
begin{document}
    begin{figure}
        begin{tabu} to linewidth {X}
            renewcommand{legendname}{fig1-legend}ref{legendname}\
            tikzsetnextfilename{fig1}subcaptionbox{}{input{test.tikz}}\
        end{tabu}
    end{figure}
end{document}

My compilation procedure is as follows:
1) Lualatex which gives me the heads-up that there are figures to be updated.

The figfile and makefile are given as:

% cat test.figlist
fig1
% cat test.makefile
fig1.pdf:
        lualatex -shell-escape -halt-on-error -interaction=batchmode -jobname "fig1" "deftikzexternalrealjob{test}input{test}"

fig1.pdf: fig1.md5

2) make -f test.makefile which completes without errors

3) 2 times lualatex. Now there is no heads-up for figures to be updated (I would have expected so, because the legend is not yet externalized). Instead, I get the following updated makefile

% cat test.makefile
fig1.pdf:
        lualatex -shell-escape -halt-on-error -interaction=batchmode -jobname "fig1" "deftikzexternalrealjob{test}input{test}"

fig1.pdf: fig1.md5
fig1.pdf: FORCEREMAKE

4) I run the makefile again, to let latex know that there are references which are not yet up-to-date, but it gives me

% make -f test.makefile
make: *** No rule to make target 'FORCEREMAKE', needed by 'fig1.pdf'.  Stop.

5) Due to the bogus makefile, I run the command in the makefile manually. That works without problems.

6) I run lualatex again, to see whether he noticed that the legend still needs to be build. But still he doesn’t notices and, hence, also doesn’t update figlist or makefile

Consequently, I also see the actual figure with question marks for the legend.
Outside/without the tabu environment, it seems to work fine. But I have several multi-panel figures where tabu is very handy.

What am I doing wrong here?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.