如何仅使用 tikz 图片和方程式之间的叠加

如何仅使用 tikz 图片和方程式之间的叠加

我这里有一个可行的示例。我想一次显示一个 tikzpicture 和一个方程式。我不知道如何在这里只使用覆盖。

\documentclass{beamer}


\usepackage{tikz}
\usetikzlibrary{shapes, shadows, arrows}

\tikzset{
  basic/.style  = {draw, text width=2cm, drop shadow, font=\sffamily, rectangle},
  root/.style   = {basic, rounded corners=2pt, thin, align=center,
                   fill=green!30},
  level 2/.style = {basic, rounded corners=6pt, thin,align=center, fill=green!60,
                   text width=8em},
  level 3/.style = {basic, thin, align=left, fill=pink!60, text width=6.5em}
}

\mode<presentation>

\begin{document}

\begin{frame}

    \begin{tikzpicture}
      level 1/.style={sibling distance=40mm},
      edge from parent/.style={->,draw},
      >=latex]

    % root of the the initial tree, level 1
    \node[root](start) {Mass Balance};
    \draw[->,very thick](0,0) (1.2,0)--(1.9,0);
    \draw[->,very thick](-1.8,0)--(-1.1,0);
    \draw[->,very thick](0,0.6)--(0,1.4);
    \draw[->,very thick](0,-1.4)--(0,-0.6);
    \node[right of =start,xshift=2.5cm](spatialpos){$q_c(t,x+\Delta x,\tau)$};
    \node[left of =start,xshift=-1.7cm](spatialneg){$q_c(t,x,\tau)$};
    \node[above of =start,yshift=0.8cm](agepos){$c(t,x,\tau+\Delta \tau)$};
    \node[below of =start,yshift=-0.8cm](ageneg){$c(t,x,\tau)$};
    \draw[->,very thick](-4,-3)--(-4,0);
    \draw[->,very thick](-4,-3)--(-0.5,-3);
    \node[below of = ageneg,yshift=0.2cm](spatial){Spatial dim};
    \node[left of = spatialneg,yshift=0.4cm](age){Age dim.};
    \end{tikzpicture}


        \begin{align*}
         \rho \Delta x \Delta y \Delta z \Delta \tau \partial_t c_i(t,x,\tau) \\
        &= \rho \Delta x \Delta y \Delta z \Delta \tau (p_i-d_i)  \\
        &- \rho \Delta y, \Delta z \Delta \tau [q_{i,x}(t,x+\Delta x/2, y, z, \tau)\\
        &\qquad - q_{i,x}(t,x - \Delta x/2, y, z, \tau)]\\
        &- \rho \Delta x, \Delta z \Delta  \tau [q_{i,y}(t,x,y+\Delta y/2, y, z, \tau)\\
        &\qquad - q_{i,y}(t,x,y - \Delta y/2, z, z, \tau)]\\
        &- \rho \Delta x \Delta y \Delta \tau[q_{i,z}(t,x,y,z+\Delta z/2, \tau) \\
        &\qquad - q_{i,z}(t,x,y,z-\Delta z/2, \tau)]\\
            &- \rho \Delta x \Delta y \Delta \tau[q_{i,z}(t,x,y,z+\Delta z/2, \tau) \\
        &\qquad - q_{i,z}(t,x,y,z-\Delta z/2, \tau)] \\
        \end{align*}

\end{frame}

\end{document}

答案1

语法\only

\only<overlay specification>{text} 

或者

\only{text}<overlay specification>

tikzpicture并且您几乎可以在 os 位置使用任何东西(特别是或显示的方程式) text

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{shapes, shadows, arrows}

\tikzset{
  basic/.style  = {draw, text width=2cm, drop shadow, font=\sffamily, rectangle},
  root/.style   = {basic, rounded corners=2pt, thin, align=center,
                   fill=green!30},
  level 2/.style = {basic, rounded corners=6pt, thin,align=center, fill=green!60,
                   text width=8em},
  level 3/.style = {basic, thin, align=left, fill=pink!60, text width=6.5em}
}

\mode<presentation>

\begin{document}

\begin{frame}

    \only<1>{\begin{tikzpicture}
      level 1/.style={sibling distance=40mm},
      edge from parent/.style={->,draw},
      >=latex]

    % root of the the initial tree, level 1
    \node[root](start) {Mass Balance};
    \draw[->,very thick](0,0) (1.2,0)--(1.9,0);
    \draw[->,very thick](-1.8,0)--(-1.1,0);
    \draw[->,very thick](0,0.6)--(0,1.4);
    \draw[->,very thick](0,-1.4)--(0,-0.6);
    \node[right of =start,xshift=2.5cm](spatialpos){$q_c(t,x+\Delta x,\tau)$};
    \node[left of =start,xshift=-1.7cm](spatialneg){$q_c(t,x,\tau)$};
    \node[above of =start,yshift=0.8cm](agepos){$c(t,x,\tau+\Delta \tau)$};
    \node[below of =start,yshift=-0.8cm](ageneg){$c(t,x,\tau)$};
    \draw[->,very thick](-4,-3)--(-4,0);
    \draw[->,very thick](-4,-3)--(-0.5,-3);
    \node[below of = ageneg,yshift=0.2cm](spatial){Spatial dim};
    \node[left of = spatialneg,yshift=0.4cm](age){Age dim.};
    \end{tikzpicture}}


        \only<2>{\begin{align*}
         \rho \Delta x \Delta y \Delta z \Delta \tau \partial_t c_i(t,x,\tau) \\
        &= \rho \Delta x \Delta y \Delta z \Delta \tau (p_i-d_i)  \\
        &- \rho \Delta y, \Delta z \Delta \tau [q_{i,x}(t,x+\Delta x/2, y, z, \tau)\\
        &\qquad - q_{i,x}(t,x - \Delta x/2, y, z, \tau)]\\
        &- \rho \Delta x, \Delta z \Delta  \tau [q_{i,y}(t,x,y+\Delta y/2, y, z, \tau)\\
        &\qquad - q_{i,y}(t,x,y - \Delta y/2, z, z, \tau)]\\
        &- \rho \Delta x \Delta y \Delta \tau[q_{i,z}(t,x,y,z+\Delta z/2, \tau) \\
        &\qquad - q_{i,z}(t,x,y,z-\Delta z/2, \tau)]\\
            &- \rho \Delta x \Delta y \Delta \tau[q_{i,z}(t,x,y,z+\Delta z/2, \tau) \\
        &\qquad - q_{i,z}(t,x,y,z-\Delta z/2, \tau)] \\
        \end{align*}}

\end{frame}

\end{document}

在此处输入图片描述

相关内容