Short version
Is it possible to use standalone to produce externally my figures with overlays and include them directly in my main document ?
More details
Using the answers of the question Beamer overlays, tikz external and custom file name and Integrating latexmk and TikZ external mode=list and make I have been able to outsource my Tikz pictures while using overlay.
More precisely, I have the following tex files
% tikz/fig.tex
\begin{tikzpicture}[transform canvas={scale=0.5}]
\node[visible on=<1->] at (0,0) {Overlay 1};
\node[visible on=<2>] at (2,0) {Overlay 2};
\end{tikzpicture}
% main.tex
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[mode=list and make,prefix=tikz/]
\tikzset{
invisible/.style={opacity=0},
visible on/.style={alt={#1{}{invisible}}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
},
}
\makeatletter
\newcommand*{\overlaynumber}{\number\beamer@slideinframe}
\tikzset{
beamer externalizing/.style={%
execute at end picture={%
\tikzifexternalizing{%
\ifbeamer@anotherslide
\pgfexternalstorecommand{\string\global\string\beamer@anotherslidetrue}%
\fi
}{}%
}%
},
external/optimize=false
}
\let\orig@tikzsetnextfilename=\tikzsetnextfilename
\renewcommand\tikzsetnextfilename[1]{\orig@tikzsetnextfilename{#1-\overlaynumber}}
\makeatother
\tikzset{every picture/.style={beamer externalizing}}
\begin{document}
\begin{frame}{Example}
\begin{figure}
\only<1>{\tikzsetnextfilename{fig}}
\only<2>{\tikzsetnextfilename{fig}}
\input{tikz/fig.tikz}
\end{figure}
\end{frame}
\end{document}
Then, I can use latexmk with the following .latexmkrc
our %externalflag = ();
$lualatex = 'internal mylualatex %O %S %B';
sub mylualatex {
print "Hello world\n";
our %externalflag;
my $n = scalar(@);
my @args = @[0 .. $n - 2];
my $base = $_[$n - 1];
system 'lualatex', @args;
if ($? != 0) {
return $?
}
if ( !defined $externalflag->{$base} ) {
$externalflag->{$base} = 1;
system ("$make -j8 -f $base.makefile");
}
return $?;
}
and it will produce all the figures (in my example two because I have two overlays) in parallel using make. The only issue now is that I would like to use standalone to be able to work directly on my picture and not recompiling the whole document each time.
I saw in the doc of standalone that it should be possible to generate frames with standaloneframe, but it is not really what I want since I want only pictures, and I did not succeed in including the resulting frame in my main document using \includestandalone anyway.
externalandTikz– Pierre Marchand Apr 25 '19 at 13:26tikzpicture? – BambOo Apr 18 '20 at 10:41