It's a sync problem; if you add \thebeamerpauses
in some places (to get the value of the beamerpauses
counter), you can see what's going on:
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{default}
\begin{document}
\begin{frame}
\begin{itemize}[<+->]
\item A\thebeamerpauses
\item B\thebeamerpauses
\item C\thebeamerpauses
\end{itemize}\thebeamerpauses
\pause
Some text.\thebeamerpauses
\end{frame}
\end{document}
At the end of the itemize
environment the counter has a value of four, and \pause
steps it to 5, so the text will appear on the fifth slide.
To obtained the expected result you can use the optional argument of \pause
and the value of the beamerpauses
counter:
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{default}
\begin{document}
\begin{frame}
\begin{itemize}[<+->]
\item A
\item B
\item C
\end{itemize}
\pause[\thebeamerpauses]
Some text.
\end{frame}
\end{document}
Another option is to use \onslide<+->
instead of \pause
:
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{default}
\begin{document}
\begin{frame}
\begin{itemize}[<+->]
\item A
\item B
\item C
\end{itemize}
\onslide<+->{Some text.}
\end{frame}
\end{document}
If you're happy to swap out the smooth plot for a hobby
curve then you can use a feature of that package to plot only part of the curve. In short, I wanted to be able to compute a curve but only draw parts of it. So I added a blank
key which means that the current segment is not drawn. However it is still used as part of the computation of the curve meaning that the curve is the same whether or not that segment is drawn.
By applying the blank
key to the coordinates in the right order, I can successively reveal parts of the curve as you require. The mechanism for applying a style on a particular slide comes from Matthew Leingang's answer to How to make beamer overlays with Tikz node.
I tried to fit the basic idea of your curve. If you need a more precise fit then you need to add more control points.
\documentclass{beamer}
%\url{https://tex.stackexchange.com/q/116482/86}
\usepackage{tikz}
\usetikzlibrary{patterns,hobby}
\tikzset{
onslide/.code args={<#1>#2}{%
\only<#1>{\pgfkeysalso{#2}}%
},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}%
}
}
\begin{document}
\begin{frame}{Real Gases}
\begin{tikzpicture}
\draw<6->[green!20, pattern color =green!20, thin,pattern=north west lines] (0,-5) rectangle (2,2) node[rotate=90,midway,above,font=\tiny,text=green!30!black] {repulsive forces dominant};
% drawn first so appear as underlay
\draw<6->[red!0, pattern color =red!20, thin,pattern=north west lines] (2,-5) rectangle (10,2) node[midway,above,font=\tiny,text=red!30!black] {attractive forces dominant};
\draw[thick,->] (0,0) --(10,0) node[above left=0.2,font=\tiny] {Separation};
\draw[thick,->] (0,-5) --(0,2) node[rotate=90, near end,above,font=\tiny] {Potential Energy};
\draw<2->[color=blue, thick,-,use Hobby shortcut] ([out angle=-70]1.35,2) .. ([onslide=<-4>{blank}]2,0) .. ([onslide=<-3>{blank}]3,-4) .. ([onslide=<-3>{blank}]4,-5) .. ([onslide=<-2>{blank}]5,-4.5) .. ([onslide=<-2>{blank}]8,-0.3) .. ([in angle=180]10,0);
\end{tikzpicture}
\end{frame}
\end{document}
Best Answer
Here is a possible solution:
The result:
This solution is almost identical to Move TikZ cloud in a better position using beamer: you first mark the word in which the callout will appear, then you simply declare the callout on that position.
The
\mycallout
command is defined to fit your requirements: by default the text behind it is still visible even if I think should be better to make it opaque. For this reason, I let the possibility to the user to do this: in the optional second argument just set the opacity equal to 1, as did in the example.Notice that two compilation runs are needed in order to achieve the result: the first one to compute the position of the markers, the second to draw the callout.
Let's analyze step by step the required TikZ code needed. A part from the libraries, at first we encounter
This piece of code is taken from Mindmap tikzpicture in beamer (reveal step by step) (I've added a
text opacity
because it makes more robust the method): it is a way to show correctly TikZ-based animations. What I mean with correctly? TikZ-based animations may suffer of the so called jumping effect (here along the site you can find several question on this regard link to questions) and that code addresses it. What he actually does is to force the visibility of nodes and paths to be completely transparent when they should not be visible: you decide where nodes and paths should be visible by selecting overlay specifications by means of the keyvisible on=<overlay specifications>
.Let's now have a look to:
This is the command responsible to create the callouts. As said in the comment he need some arguments:
<>
to decide the right overlay specifications (similarly as you insert them with Beamer) that actually are the ones in which the visibility, as stated in the previous paragraph, is not transparent, but nodes or paths are opaque;The node is realized with the syntax
\tikz[options]\node[options]at(pos){text};
; the options to be passed to\tikz
areremember picture,overlay
because the callout should be drawn in overlay andremember picture
permits to remember previous nodes, marked for example with the\tikzmark
command. The options passed to the node are simply the ones needed to create a calloutdraw,rectangle callout,anchor=pointer,callout relative pointer={(230:1cm)}
, to fix the aspect of italign=center, fill=cyan!20, text width=2cm,
and to set its visibility#2,visible on=<#1>,
(recall that#2
by default isopacity=0.8,text opacity=1
). Notice that, actually, the code used for overlays set itself the opacity of nodes (complete opaque or transparent), thus to not have problems the opacity of the callout should be declared before.Finally we have the
\tikzmark
command:It simply defines a void node with a label: the node is aligned with a baseline that place it vertically in the middle of a line. The node it will be remembered by means of the label you give to it and is used subsequently as the starting point in which the callout pointers.
After a suggestion in chat by Speravir, here is an interactive solution: it is based on the
ocgx
package and some ideas are stolen from Interactive PDF, Latex and Article of the Future.The code:
How it works? Now there's no need of overlay specifications, since the command
\explainword
is realized in such a way that it actually is an ocgx button able to make visible the callout when one clicks on the word. It needs two arguments: the first one is the identifier (for the\tikzmark
macro and for the ocgx button) and the second one the text/word to be explained.When both words in the example are clicked the result is:
Note
This requires always two compilation runs and, for me, the solution works only with Adobe Reader.
BTW: I've organized a little better the style of the callout and now it could be customized more easily (see as reference the second work explained).