In short, \only<>{}
does not render the braced material at all except on the named slides, while \onslide<>
renders the material until the next \onslide
, sort of like an \item
, but, on the off slides, covers it (according to the preference given in \setbeamercovered
; i.e. transparent or invisible). There are other alternatives, for example, \uncover<>{}
, which functions like \only
but acts like \onslide
; i.e. takes a specific chunk of text and covers or uncovers it as appropriate.
There are some circumstances where they work differently. For example, using \onslide
in one of the amsmath
equation environments (I have found) produces horrible bugs:
\usepackage{amsmath}
...
\begin{align*}
a & \onslide<+-> b % Bad
a & \uncover<+->{b}% Good
\end{align*}
Presumably this is because align
does what the manual calls "wicked things" in processing its contents.
You also ask about the overlayarea
and overprint
environments; these are fancy versions of \uncover
and \onslide
respectively, that reserve the space for an entire sequence of uncoverings. The overprint
environment does so automatically but only allows you to uncover in an "itemized" fashion by using \onslide
successively, and the overlayarea
environment requires you to say exactly the size of the overlay area but allows you to use any Beamer constructs inside; it will then produce the requisite number of slides with various material appearing in that area (including necessary empty space) on each one.
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
If
{text}
is present and indeed starts with a brace,\onslide
will just fall through to\only
,\visible
or\uncover
, respectively.However if there is no brace, it will fall though to
\only
,\beamer@noargsvisibleonslide
and\beamer@noargsonslide
which I vaguely presume are the switch variants of\visible
and\uncover
. (I really don't like the "can be switch or have an argument" style, so I'm not very motivated to dig deeper into this right now. ;) )