I'm writing an article that involves a lot of diagrammatic calculus, that is, there is a big TikZ picture with nodes and lines and that picture gets modified slightly in each step of the calculation. Say, the label of a line changes or a line becomes dotted or vanishes.

Now I find myself thinking that this would be so easy if I were writing a beamer presentation. Then I would just write the whole picture with all modifications in it and modify it by using overlays. For example, I could use \visible<...>{...} to make a line vanish in a later part of the calculation. See an example I made "by hand" here:

enter image description here

But I have article as document class and I don't want to change that. Is there a way to use beamer's overlay specifications in a tikzpicture and then have, say, an align environment where each line is one overlay of the picture?

EDIT: Thanks for the inventive idea of actually creating a separate beamer file and including its output. But I really don't want to go to the trouble of creating external files and adjusting margins manually. This looks like far too much work and trouble for a result that doesn't look appropriate for my purposes. I personally would rather stick to TikZ styles and PGF keys to hack my way around it.

EDIT 2: Finding Liam's question here asking something similar, I'd like to rephrase my question: Given my picture drawn with beamer overlay specifications, is there a way to extract the picture how it would have looked like on frame $n$?

  • Just to clarify, you want the pictures next to each other, no animation? – Johannes_B Nov 28 '14 at 18:05
  • That's right. Or below each other, for that matter. I want to be able to print it at the end with all the steps of the calculations in it. – Turion Nov 28 '14 at 18:07
  • Though it’s said to be out of date, I still sometimes use texpower with document classes like pdfscreen; texpower may do what you want. – Thérèse Nov 28 '14 at 19:53
  • beamer is quite different from other classes. In particular, it parses stuff differently and redefines many commands in order to make stuff work with overlay specifications. I doubt there is a general solution which does not involve essentially reproducing that functionality. And that would depend, among other things, on your document class. And you'd have to be careful not to load other packages which tried to redefine the same commands. If you wanted something which would work for some specific form of overlay specification or with something similar to an overlay specification.... – cfr Feb 23 '15 at 23:06

You can use standalone class with beamer option which allows to use all beamer overlay constructs. This will create a pdf with as much as pages as overlays. Each of these pages can be cropped with pdfcrop and you'll get a new pdf file with one adjusted overlay in each page. Finally you can include all of them in your article with page= includegraphics option or with recent tcolorbox rater library.

As an example I've adapted the code from my answer to drawing(uncover) a curve bit-by-bit using tikzpcture and beamer and \onslide just eliminating frame titles:


% A simple empty decoration, that is used to ignore the last bit of the path

% Declare the actual decoration.
        next state=middle

        next state=final


% Create a key for easy access to the decoration
\tikzset{middle segment/.style={decoration={middle},decorate, segment length=#1}}


\begin{frame}{} %<- no title for better cropping
\onslide<5->{\draw[green!20, pattern color =green!20, thin,pattern=north west lines] (0,-5) rectangle (2,2)  node[rotate=90,midway,above] {\tiny{\textcolor{green!30!black}{repulsive forces dominant}}};}% drawn first so appear as underlay
\onslide<5->{\draw[red!0, pattern color =red!20, thin,pattern=north west lines] (2,-5) rectangle (10,2)  node[midway,above] {\tiny{\textcolor{red!30!black}{attractive forces dominant}}};}

\onslide<1->{\draw[thick,->] (0,0) --(10,0) node[above left=0.2] {\tiny{Separation}};}
\onslide<1->{\draw[thick,->] (0,-5) --(0,2) node[rotate=90, near end,above] {\tiny{Potential Energy}};}

\onslide<2>{\draw[middle segment=0.3,color=blue, thick,-] plot[smooth] coordinates{\mypath};}
\onslide<3>{\draw[middle segment=0.6,color=blue, thick,-] plot[smooth] coordinates{\mypath};}
\onslide<4>{\draw[middle segment=0.8,color=blue, thick,-] plot[smooth] coordinates{\mypath};}
\onslide<5>{\draw[color=blue, thick,-] plot[smooth] coordinates{\mypath};}


The result has been pdfcrop-ed and included in an article file like this:


\begin{tcbraster}[raster columns=2, raster equal height]
\tcbincludegraphics[graphics options={page=1}]{214474-crop}
\tcbincludegraphics[graphics options={page=2}]{214474-crop}
\tcbincludegraphics[graphics options={page=3}]{214474-crop}
\tcbincludegraphics[graphics options={page=4}]{214474-crop}
\tcbincludegraphics[graphics options={page=5}]{214474-crop}

enter image description here

2nd version

It could be easier. Command \tcbincludepdf{pdffile.pdf} inside a tcbraster environment includes one page after page from dffile.pdf. Therefore, same results as previous code could be obtaned with just:


\begin{tcbraster}[raster columns=2, raster equal height]

Here's a possibility, which I also posted at this related question. It's a little parser to interpret the Beamer-style overlay specifications of the forms \only<->, \only<a->, \only<-b>, \only<a-b>, and \only<a> and test them against a macro \slide.


    \advance\c@only@begin by -1\relax
    \advance\c@only@end by 1\relax

    % No hyphen in original.
      % \only<a->
      % \only<a-b> or \only<-b>; #2 contains 'b-'


  \begin{tikzpicture}[every node/.style={anchor=base,circle, draw}]
    \draw (0,0) rectangle (6,2);
    \node at (1,1) {a};
    \only<2->{ \node at (2,1) {b}; }
    \only<2-3>{ \node at (3,1) {c}; }
    \only<3>{ \node at (4,1) {d}; }
    \only<-4>{ \node at (5,1) {e}; }



This compiles to enter image description here

  • Wow! Make a package out of it! – Turion Oct 20 '15 at 6:02

Haven't tried this with a tikzpicture, but since you say it'd be easy if it were in beamer, I'll use beamer pages as included graphics:

enter image description here

Main tex file:


x &= \fbox{\begin{minipage}[c]{2.5in}{\vspace{0pt}\includegraphics[page=1]{\jobname-beamer.pdf}}\end{minipage}} \\
     % Ref: http://texblog.net/latex-archive/graphics/includegraphics-top-align/
   &= \fbox{\begin{minipage}[c]{2.5in}{\vspace{0pt}\includegraphics[page=2]{\jobname-beamer.pdf}}\end{minipage}}

with an associated beamer file of:

\geometry{width=2in, height=2in, paperwidth=2in, paperheight=2in}
\setbeamertemplate{navigation symbols}{}




  • That's a nice idea, but doesn't look good in terms of fonts and margins. I added some graphics in the question. – Turion Nov 28 '14 at 19:46
  • 1
    Do you have a minimal tikzpicture you can show? Should be easy enough to modify margins or other sizes in beamer. – Mike Renfro Nov 28 '14 at 19:55
  • I really don't want to go to the trouble of creating external files and adjusting margins manually. – Turion Dec 1 '14 at 11:45

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.