Overlay Problem In Beamer [closed]

I am trying to get the following several items to appear on one frame, but show up only one slide at a time, disappearing after each slide. Here is the code, but it is wrong and I do not know where.

\begin{frame}[t]
\frametitle{Slope of a Tangent Line}

% The following two lines I want to appear on one slide:
\only<1>Consider the function $f(x)$ and the tangent line at the point $(a,f(a))$: \bigskip
\begin{center}\includegraphics[width=3.5in]{fig1}\end{center} \pause

%The following two lines I want to appear on another
\only<2>To find the slope of the tangent to $f(x)$ at this point, we begin by looking at the secant line through the point $(a,f(a))$ and some other point $(x,f(x))$. The graph would be:
\begin{center}\includegraphics[width=3.5in]{fig2}\end{center} \pause

\end{frame}


After adding in the braces, I still am getting the following:

The problem is that the images has not changed at all, and now there is text on the bottom.

Here is the most current code:

  \begin{frame}[t]
\frametitle{Slope of a Tangent Line}

\only<1->{Consider the function $f(x)$ and the tangent line at the point $(a,f(a))$: \bigskip
\begin{center}\includegraphics[width=3.5in]{fig1}\end{center} }

\only<2>{To find the slope of the tangent to $f(x)$ at this point, we begin by looking at the secant line through the point $(a,f(a))$ and some other point $(x,f(x))$. The graph would be:
\begin{center}\includegraphics[width=3.5in]{fig2}\end{center}}

\only<3>{The point $(x,f(x))$ that we chose was arbitrary. We could have chosen any point that we wanted, so now let's choose a point that is closer to $(a,f(a))$ and look at the secant through those two points.
\begin{center}\includegraphics[width=3.5in]{fig3}\end{center}}

\only<4>{Again, let's move the point $(x,f(x))$ even closer to $(a,f(a))$ and see what the secant looks like. \bigskip
\begin{center}\includegraphics[width=3.5in]{fig4}\end{center}}

\only<5>{Notice that each time we move the second point $(x,f(x))$ closer to $(a,f(a))$, the secant through those two points moves closer to the tangent.
\begin{center}\includegraphics[width=3.5in]{fig5}\end{center}}

\only<6>{Notice that each time we move the second point $(x,f(x))$ closer to $(a,f(a))$, the secant through those two points moves closer to the tangent.
\begin{center}\includegraphics[width=3.5in]{fig6}\end{center}}

\end{frame}


closed as unclear what you're asking by TeXnician, Stefan Pinnow, CarLaTeX, Werner, ZarkoApr 26 '17 at 6:06

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• \begin{frame}{Slope ....}\only<1->{Consider ... }\only<2>{To find ....}\end{frame}. The curly braces matter, as the hyphen after 1. – Fran Feb 18 '17 at 17:56
• Besides the missing braces your code is right. – TeXnician Feb 18 '17 at 18:01
• \only<1>{item 1 item2} \only<2>{item3 item4} ... If you mean item of itemize lists may be you want use \item<1> ... – Fran Feb 18 '17 at 18:02
• @Quantitative: Missing braces: the {...} after \only that limit the scope of that command. – Fran Feb 18 '17 at 18:05
• If you want to delete the question, do it yourself. – egreg Apr 19 '17 at 21:53

You are only missing some braces. The \only<slides>{Text} needs those to get all your content. In any other case it just uses the next token (for the first example "C") and shows only that only on slide 1.

In addition you should remove your \pause macros as they are useless after a \only macro.

Update: For your purpose (especially in updated code) it is important to just have a slide number for \only (in <>). Do not use a hyphen.

\documentclass[demo]{beamer}

\begin{document}
\begin{frame}[t]
\frametitle{Slope of a Tangent Line}

% The following two lines I want to appear on one slide:
\only<1>{Consider the function $f(x)$ and the tangent line at the point $(a,f(a))$: \bigskip
\begin{center}\includegraphics[width=3.5in]{fig1}\end{center}}
%The following two lines I want to appear on another
\only<2>{To find the slope of the tangent to $f(x)$ at this point, we begin by looking at the secant line through the point $(a,f(a))$ and some other point $(x,f(x))$. The graph would be:
\begin{center}\includegraphics[width=3.5in]{fig2}\end{center}}
\end{frame}
\end{document}

• see update, I uploaded pics – user124586 Feb 18 '17 at 18:18

Example of code containing the missing braces and removing the unnecessary \pauses:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\begin{document}
\begin{frame}[t]
\frametitle{Slope of a Tangent Line}

% The following two lines I want to appear on one slide:
\only<1>{Consider the function $f(x)$ and the tangent line at the point $(a,f(a))$: \bigskip
\begin{center}\includegraphics[height=1.5in]{fig1}\end{center}}

%The following two lines I want to appear on another
\only<2>{To find the slope of the tangent to $f(x)$ at this point, we begin by looking at the secant line through the point $(a,f(a))$ and some other point $(x,f(x))$. The graph would be:
\begin{center}\includegraphics[height=1.5in]{fig2}\end{center}}

\end{frame}
\end{document}


EDIT: 5 seconds too slow

EDIT2: For your most current code you should remove the - from the first \only<1->:

\begin{frame}[t]
\frametitle{Slope of a Tangent Line}

\only<1>{Consider the function $f(x)$ and the tangent line at the point $(a,f(a))$: \bigskip %here I removed the '-' from \only<1->
\begin{center}\includegraphics[width=3.5in]{fig1}\end{center} }

\only<2>{To find the slope of the tangent to $f(x)$ at this point, we begin by looking at the secant line through the point $(a,f(a))$ and some other point $(x,f(x))$. The graph would be:
\begin{center}\includegraphics[width=3.5in]{fig2}\end{center}}

\only<3>{The point $(x,f(x))$ that we chose was arbitrary. We could have chosen any point that we wanted, so now let's choose a point that is closer to $(a,f(a))$ and look at the secant through those two points.
\begin{center}\includegraphics[width=3.5in]{fig3}\end{center}}

\only<4>{Again, let's move the point $(x,f(x))$ even closer to $(a,f(a))$ and see what the secant looks like. \bigskip
\begin{center}\includegraphics[width=3.5in]{fig4}\end{center}}

\only<5>{Notice that each time we move the second point $(x,f(x))$ closer to $(a,f(a))$, the secant through those two points moves closer to the tangent.
\begin{center}\includegraphics[width=3.5in]{fig5}\end{center}}

\only<6>{Notice that each time we move the second point $(x,f(x))$ closer to $(a,f(a))$, the secant through those two points moves closer to the tangent.
\begin{center}\includegraphics[width=3.5in]{fig6}\end{center}}

\end{frame}


BTW: You might consider adding more frames if your one frame doesn't contain any persistent information.

• BTW: You forgot one \pause in the second \only. – TeXnician Feb 18 '17 at 18:13
• see update, I uploaded pics – user124586 Feb 18 '17 at 18:18
• @TeXnician I saw that, too, and removed it in an edit. @Quantitative You put a <1-> in the first \only  resulting in the first image to be on each slide. That's the error I think. – Skillmon Feb 19 '17 at 8:28