如何将 tikz 图片插入到 beamer 中?

如何将 tikz 图片插入到 beamer 中?

我有那张照片

\documentclass[12pt]{article}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\begin{center}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-4.3,-11.98) rectangle (33.88,6.3);
\draw (-0.48,-3.42) node[anchor=north west] {Official};
\draw (2.48,-0.54) node[anchor=north west] {Citizen};
\draw (0.62,-3.06)--node[above,sloped] {$b>0$}node[below,sloped] {bride} (2.8349953328119706,-1.0366869556044498);
\draw (0.6,-3.9)--  node[above,sloped] {$b=0$}node[below,sloped] {nobride}(2.753375039560603,-5.988773788373784);
\draw (3.5,-0.28)-- node[above,sloped] {pay}node[below,sloped] {end report} (5.708982562266176,1.7498758680283781);
\draw (4.14,-0.87)-- node[above,sloped] {pay}node[below,sloped] {silenty}(7.14,-0.87);
\draw (3.36,-1.06)--node[above,sloped] {refuse}node[below,sloped] {silently}  (5.502014662422205,-3.1604221447052696);
\end{tikzpicture}
\end{center}

\begin{center}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-4.3,-11.98) rectangle (33.88,6.3);
\draw (-0.48,-3.42) node[anchor=north west] {Official};
\draw (2.48,-0.54) node[anchor=north west] {Citizen};
\draw (0.62,-3.06)--node[above,sloped] {$b>0$}node[below,sloped] {bride} (2.8349953328119706,-1.0366869556044498);
\draw (0.6,-3.9)--  node[above,sloped] {$b=0$}node[below,sloped] {nobride}(2.753375039560603,-5.988773788373784);
\draw (3.5,-0.28)-- node[above,sloped] [red]{\textbf{pay}}node[below,sloped] [red]{\textbf{end report}} (5.708982562266176,1.7498758680283781);
\draw (4.14,-0.87)-- node[above,sloped] {pay}node[below,sloped] {silenty}(7.14,-0.87);
\draw (3.36,-1.06)--node[above,sloped] {refuse}node[below,sloped] {silently}  (5.502014662422205,-3.1604221447052696);
\end{tikzpicture}
\end{center}

\begin{center}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-4.3,-11.98) rectangle (33.88,6.3);
\draw (-0.48,-3.42) node[anchor=north west] {Official};
\draw (2.48,-0.54) node[anchor=north west] {Citizen};
\draw (0.62,-3.06)--node[above,sloped] {$b>0$}node[below,sloped] {bride} (2.8349953328119706,-1.0366869556044498);
\draw (0.6,-3.9)--  node[above,sloped] [red]{$\textbf{b=0}$}node[below,sloped] [red]{\textbf{nobride}}(2.753375039560603,-5.988773788373784);
\draw (3.5,-0.28)-- node[above,sloped] [red]{\textbf{pay}}node[below,sloped] [red]{\textbf{end report}} (5.708982562266176,1.7498758680283781);
\draw (4.14,-0.87)-- node[above,sloped] {pay}node[below,sloped] {silenty}(7.14,-0.87);
\draw (3.36,-1.06)--node[above,sloped] {refuse}node[below,sloped] {silently}  (5.502014662422205,-3.1604221447052696);
\end{tikzpicture}
\end{center}
\end{document}

我需要将其插入到一个框架中,但什么也没发生。当然,beamer 已设置在文档上

答案1

可以使用新命令更改每张幻灯片的颜色:

\documentclass[12pt]{beamer}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\begin{frame}[t]

 \newcommand*\nodeonecolor{}
 \newcommand*\nodetwocolor{}
 \only<2->{\renewcommand*\nodeonecolor{red}}
 \only<3->{\renewcommand*\nodetwocolor{red}}

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=0.9cm,y=0.7cm]
\clip(-4.3,-11.98) rectangle (33.88,6.3);
\draw (-0.48,-3.42) node[anchor=north west] {Official};
\draw (2.48,-0.54) node[anchor=north west] {Citizen};
\draw (0.62,-3.06)--node[above,sloped] {$b>0$}node[below,sloped] {bride} (2.8349953328119706,-1.0366869556044498);
\draw (0.6,-3.9)--  node[above,sloped] [\nodetwocolor]{$\textbf{b=0}$}node[below,sloped] [\nodetwocolor]{\textbf{nobride}}(2.753375039560603,-5.988773788373784);
\draw (3.5,-0.28)-- node[above,sloped] [\nodeonecolor]{\textbf{pay}}node[below,sloped] [\nodeonecolor]{\textbf{end report}} (5.708982562266176,1.7498758680283781);
\draw (4.14,-0.87)-- node[above,sloped] {pay}node[below,sloped] {silenty}(7.14,-0.87);
\draw (3.36,-1.06)--node[above,sloped] {refuse}node[below,sloped] {silently}  (5.502014662422205,-3.1604221447052696);
\end{tikzpicture}

\end{frame}
\end{document}

相关内容