2

I'm trying to speed-up compilation of my multi-tikz .tex file.

I found this topic and successfully applied the solution ; unfortunately, it doesn't work for animations inside the tikzfigure: Only the first view of the animation is rendered on the final pdf.

Question: Is there a way to make tikz external work with beamer's animations?

The tikzset I use for my animations is the following (found also on texSE):

\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
    },
}

Here is a full document that illustrate the issue:

\documentclass{beamer}
\usepackage{pgfplots}              % handle plots
\pgfplotsset{compat=1.13}
\usepgfplotslibrary{external}
    \tikzexternalize[mode=list and make, prefix=tikz/]
    \tikzset{external/system call={pdflatex \tikzexternalcheckshellescape
        -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}
    } % to let pdflatex work

\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
    },
}
\begin{document}

\begin{frame}
    \begin{tikzpicture}
        \node[draw] at (0,0) {auie};
        \pause
        \node[draw] at (1,0) {tsrn};
        \node[draw,visible on=<3->] at (1,1) {vdlj};
    \end{tikzpicture}
\end{frame}
\end{document}
  • 2
    Welcome to TeX.SE! Please provide us with a complete minimal example, i.e. document that starts with \dcoumentclass and ends with \end{document}. BT, perhaps something like this answer helps or is at least a good starting point. – marmot Oct 5 '18 at 16:42
  • created a complete minimal example – Jav Oct 5 '18 at 16:51
  • 1
    Thanks! Notice that visible on etc. is part of the very useful library overlay-beamer-styles, whose only disadvantage is that nobody can recall its name. ;-) – marmot Oct 5 '18 at 16:59
3

Thanks for your MWE! Here is an example entirely based on this answer. You will see that if you compile it the second time, the external pictures will be loaded, so compilation is faster.

\documentclass{beamer}
%\url{https://tex.stackexchange.com/q/119428/86}
\usepackage{tikz}

\usetikzlibrary{external}
\usetikzlibrary{overlay-beamer-styles}

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

\tikzexternalize

\begin{document}

\begin{frame}[t]{\texttt{overlay-beamer-styles} and \texttt{externalize}}
\begin{itemize}
  \item<1-> Image 1
  \item<2-> Image 2
  \item<3-> Image 3
\end{itemize}
  \tikzsetnextfilename{figure}
  \begin{tikzpicture}
    \node (1) {Overlay 1};
    \draw[-latex,visible on={<2->}] (1.east) -- ++ (1,0) node[right] (2) {Overlay 2};
    \draw[-latex,visible on={<3->}] (2.east) -- ++ (1,0) node[right] (3) {Overlay 3};
  \end{tikzpicture}
\end{frame}

\end{document}

enter image description here

  • it's recompiling the whole document (with figures) even if the change is not in a tikzpicture. BTW, the figures are wrong when I set \setbeameroption{show notes on second screen} – Jav Oct 9 '18 at 6:48
  • @Jav No, this is not true. It only recompiles when you change the figures. BTW, what is \setbeameroption{show notes on second screen}? On my distribution that just causes an error. – marmot Oct 9 '18 at 11:17
  • from pgfpages : allows to create a double sized frame with the frame on the left, and the notes on the right – Jav Oct 9 '18 at 11:20
  • @Jav Either make qualified statements or please refrain from posting random comments. I just told you that your command throws an error. So I do not think that your comment addresses this in any way. And the first part of your above comment is just not true. – marmot Oct 9 '18 at 11:23
  • Sorry from beeing unclear buddy, I have trouble replicating the (many) issues I face with advanced beamer usage. It's not random comment, it's an answer to your question « BTW wat is… ». I'm telling you what it is. – Jav Oct 9 '18 at 11:36

Your Answer

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

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