在 tikzpicture 环境中将文本放在 \only 下时出现问题

在 tikzpicture 环境中将文本放在 \only 下时出现问题

在幻灯片 2 中,我想在节点“ODE soln”的左侧放置一个“文本”(不是“节点”)“Hello”(如代码中所述)。无法做到这一点

\documentclass{beamer} 

\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage{tikz}
\usetikzlibrary{calc}

\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}
\usetheme{AnnArbor}

\begin{document}

\begin{frame}
  \frametitle{Intuition: Continued...}
  \tikzstyle{format} = [draw, thin, fill=blue!20]
  \begin{itemize}
  \item<1-> Recall the proof of tracking lemma  
    \begin{tikzpicture}[auto,>=latex', thick]
      \path[use as bounding box] (-5,0.5) rectangle (10,-2);
\only<1>{
      \path[->]<1-> node[format] (link) {Algorithm};
}
\only<2->{ 
     % Want to put "Hello" to the left of the node "O.D.E soln" 
      \path[->]<2-> node[format, below of=link] (incl) {O.D.E soln.:};
}
    \end{tikzpicture}
  \item<3->  Solution
  \end{itemize}
\end{frame}

\end{document}

答案1

您已命名的“ODE-soln”节点incl。您可以\node使用

\node[left=of incl] {Hello};

这需要\usetikzlibrary{positioning}\node是 的简写 \path node

下面是一个完整的示例。我还将其更改below of=below=of,因为PGF/TikZ 中“right of=”和“right=of”之间的区别,并且我将 改为 ,\tikzstyle{name}=[<options>]因为\tikzset{name/.style={<options>}}建议使用后者。最后,我将您现有的两个节点 改为\node[format] {...};

\documentclass{beamer} 

\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,arrows,shapes}

\usetheme{AnnArbor}

\begin{document}

\begin{frame}
  \frametitle{Intuition: Continued...}
  \tikzset{format/.style={draw, thin, fill=blue!20}}
  \begin{itemize}
  \item<1-> Recall the proof of tracking lemma  
    \begin{tikzpicture}[auto,>=latex', thick]
      \path[use as bounding box] (-5,0.5) rectangle (10,-2);
\only<1>{
      \node[format] (link) {Algorithm};
}
\only<2->{ 
     % Want to put "Hello" to the left of the node "O.D.E soln" 
      \node[format, below=of link] (incl) {O.D.E soln.:};
      \node[left=of incl] {Hello};
}
    \end{tikzpicture}
  \item<3->  Solution
  \end{itemize}
\end{frame}

\end{document}

相关内容