我正在准备使用 的演示文稿beamer
。我想tikz
分两步展示使用 编写的图片。
这是我的第一次尝试:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}
\usetheme{Berlin}
\begin{document}
\begin{frame}
\begin{center}
\begin{tikzpicture}
\draw[gray, thick] (-3,2) -- (3,2);
\draw[gray, thick, dotted] (-3.5, 2) -- (-3,2);
\draw[gray, thick, dotted] (3, 2) -- (3.5,2);
\draw[gray, thick] (-3,0) -- (3,0);
\draw[gray, thick, dotted] (-3.5, 0) -- (-3,0);
\draw[gray, thick, dotted] (3, 0) -- (3.5,0);
\draw[gray, thick] (-2,1) ellipse (0.6 and 1);
\draw[gray, thick] (-1,1) ellipse (0.6 and 1);
\draw[gray, thick] (0,1) ellipse (0.6 and 1);
\draw[gray, thick] (-2.5,1) ellipse (0.6 and 1);
\draw[gray, thick] (-1.5,1) ellipse (0.6 and 1);
\draw[gray, thick] (-0.5,1) ellipse (0.6 and 1);
\draw[red, very thick] (0.5,1) ellipse (0.6 and 1);
\draw[gray, thick] (1,1) ellipse (0.6 and 1);
\draw[gray, thick] (1.5,1) ellipse (0.6 and 1);
\draw[gray, thick] (2,1) ellipse (0.6 and 1);
\draw[gray, thick] (2.5,1) ellipse (0.6 and 1);
\draw (3.5, 1) node [anchor = west]{$M$};
\pause
\draw (0.5, 0) node [anchor = north, red]{$N$};
\draw[red, very thick] (-3.3,1.7) -- (2.6,1.7);
\draw[red, very thick, dotted] (-3.8, 1.7) -- (-3.3,1.7);
\draw[red, very thick, dotted] (2.6, 1.7) -- (3.1,1.7);
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
\pause
即我刚刚在环境中使用了命令tikzpicture
。不幸的是,这个结果并不令人满意,因为底部的蓝色条纹(由主题产生Berlin
)不是立即出现的,而是在第二步出现的。
我该如何解决我的问题?
任何帮助都将不胜感激。非常感谢!
答案1
不要使用\pause
命令,而要使用\onslide
命令。
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}
\usetheme{Berlin}
\begin{document}
\begin{frame}
\begin{center}
\begin{tikzpicture}
\onslide<1->{
\draw[gray, thick] (-3,2) -- (3,2);
\draw[gray, thick, dotted] (-3.5, 2) -- (-3,2);
\draw[gray, thick, dotted] (3, 2) -- (3.5,2);
\draw[gray, thick] (-3,0) -- (3,0);
\draw[gray, thick, dotted] (-3.5, 0) -- (-3,0);
\draw[gray, thick, dotted] (3, 0) -- (3.5,0);
\draw[gray, thick] (-2,1) ellipse (0.6 and 1);
\draw[gray, thick] (-1,1) ellipse (0.6 and 1);
\draw[gray, thick] (0,1) ellipse (0.6 and 1);
\draw[gray, thick] (-2.5,1) ellipse (0.6 and 1);
\draw[gray, thick] (-1.5,1) ellipse (0.6 and 1);
\draw[gray, thick] (-0.5,1) ellipse (0.6 and 1);
\draw[red, very thick] (0.5,1) ellipse (0.6 and 1);
\draw[gray, thick] (1,1) ellipse (0.6 and 1);
\draw[gray, thick] (1.5,1) ellipse (0.6 and 1);
\draw[gray, thick] (2,1) ellipse (0.6 and 1);
\draw[gray, thick] (2.5,1) ellipse (0.6 and 1);
\draw (3.5, 1) node [anchor = west]{$M$};
}
\onslide<2>{
\draw (0.5, 0) node [anchor = north, red]{$N$};
\draw[red, very thick] (-3.3,1.7) -- (2.6,1.7);
\draw[red, very thick, dotted] (-3.8, 1.7) -- (-3.3,1.7);
\draw[red, very thick, dotted] (2.6, 1.7) -- (3.1,1.7);
}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}