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};

% main.tex

\tikzexternalize[mode=list and make,prefix=tikz/]
  visible on/.style={alt={#1{}{invisible}}},
  alt/.code args={<#1>#2#3}{%
    \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
  beamer externalizing/.style={%
    execute at end picture={%

\tikzset{every picture/.style={beamer externalizing}}


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.

  • The issue then is can I produce automatically all the pdf I need using standalone with overlay ? – Pierre Marchand Apr 25 '19 at 13:12
  • Ah, you are using the beamer version of tikz. Note that each overlay is a separate image/page, whereas standalone typically generates only one image/page. – John Kormylo Apr 25 '19 at 13:21
  • Exactly, so I wonder if there is a way to get pass this. For example, I know that you can produce a frame for each overlay version of the your page using standaloneframe (but I did not succeed in outsourcing this). Or may be there is some trick to produce several pdf and include them like I did with external and Tikz – Pierre Marchand Apr 25 '19 at 13:26
  • 1
    Does it help? tex.stackexchange.com/a/168705/1952 – Ignasi Apr 25 '19 at 14:25
  • It is a nice workaround to produce several frames, good to know thanks ! But my main question is more about pictures, rather than frames. – Pierre Marchand Apr 25 '19 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.