在Beamer中使用Tikz定位命令的\onslide、\visible和\only

3
我有以下图片: enter image description here 我希望在我的beamer演示文稿中以特定顺序显示它的元素。目前,我正在尝试在第二张幻灯片中显示a_1、a_2。我正在使用以下代码:
\documentclass{beamer}
\usepackage{textcomp}
\usepackage{tikz}
\usetheme{Madrid}
\begin{document}
\begin{frame}{}
 \usetikzlibrary{shapes,arrows, positioning, calc}  
 
\tikzset{%
  block/.style    = {rounded corners, draw, thick, circle, minimum height = 3em,
    minimum width = 3em, fill = yellow!50},
  point/.style    = {coordinate}, % Input
}
\begin{tikzpicture}[auto, thick, node distance=2cm, >=triangle 45]
%\node[block] (A1) at (0,0) {$A_1$};
%\node[block, right  = 1cm of A1] (A2) {$A_2$};
\node[below  = of A1] (a1) {{\visible<2->{$a_1$}}};
\node[below  = of A2] (a2) {{\visible<2->{$a_2$}}};
\node[below  = of A1] (a1) {$a_1$};
\node[below  = of A2] (a2) {$a_2$};
\draw[->] (A1.south) ++(0,-0.3) -- ++(0, -1.3);
\draw[->] (A2.south) ++(0,-0.3) -- ++(0, -1.3);
\end{tikzpicture}
\end{frame}
\end{document}

但我只得到了这个:

我遇到了一些错误,比如:“未知的箭头类型 'triangle 45'”和“在(of A1)中未知的运算符 'o' 或 'of'”。 这是我第一次使用Tikz,我对像\onslide、\only或\visible这样的beamer工具并不熟悉。我想我可以创建不同的图像,每帧一个,然后用\includegraphics和\pause添加它们,但如果我能够在不创建不同图片的情况下实现相同的结果,那将更加实用。非常感谢您的任何帮助。

1个回答

7
  • 在导言部分而不是幻灯片内加载你的tikz库

  • 你可以使用overlay-beamer-styles库来控制节点的外观

\documentclass{beamer}
\usepackage{textcomp}
\usepackage{tikz}
\usetheme{Madrid}

 \usetikzlibrary{shapes,arrows, positioning, calc}  
 \usetikzlibrary{overlay-beamer-styles}
 
\tikzset{%
  block/.style    = {rounded corners, draw, thick, circle, minimum height = 3em,
    minimum width = 3em, fill = yellow!50},
  point/.style    = {coordinate}, % Input
}


\begin{document}
\begin{frame}{}
\begin{tikzpicture}[auto, thick, node distance=2cm, >=triangle 45]
\node[block] (A1) at (0,0) {$A_1$};
\node[block, right  = 1cm of A1] (A2) {$A_2$};
\node[below  = of A1, visible on=<2->] (a1) {$a_1$};
\node[below  = of A2, visible on=<2->] (a2) {$a_2$};
\draw[->] (A1.south) ++(0,-0.3) -- ++(0, -1.3);
\draw[->] (A2.south) ++(0,-0.3) -- ++(0, -1.3);
\end{tikzpicture}
\end{frame}
\end{document}

enter image description here


箭头怎么办?能否让它们与a_1和a_2一起显示出来? - Peanojr

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接