在 Beamer 中将公式与 TikZ 图片链接起来

在 Beamer 中将公式与 TikZ 图片链接起来

我想链接 TikZ 图片中的公式元素......

如同

使用投影仪解释公式

代码:

\documentclass[t]{beamer}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{color}
\usepackage{tcolorbox}

\begin{document}
\begin{frame}{}
    \begin{tcolorbox}
        \begin{center}  
            \begin{tikzpicture}[scale=1.0]
            %\tkzInit[xmax=4, ymax=6]
            %\tkzAxeXY
            %\tkzGrid
            %\tkzClip
            %
            \tkzDefPoint(0,3){A}
            \tkzDefPoint(0,0){B}
            \tkzDefPoint(6,0){C}

            \tkzDrawSegment(A,B)
            \tkzDrawSegment(A,C)
            \tkzDrawSegment(B,C)

            \tkzLabelPoints[below](B,C)
            \tkzLabelPoints[above](A)

            \tkzMarkRightAngle[size=0.4](A,B,C)

            \tkzLabelSegment[below,pos=.5](B,C){Side opposite to $\angle A$}
            \tkzLabelSegment[sloped](B,A){Side adjacent to $\angle A$}
            %\tkzLabelSegment[right,pos=.5,red](B,C){25 cm}
            \tkzLabelSegment[sloped](C,A){Hypotenuse}
            \tkzMarkAngle[size=0.8](A,C,B)
            \tkzMarkAngle[size=0.6](B,A,C)
            %\tkzMarkAngle[size=0.5,mark=|](C,B,A)
            \end{tikzpicture}
        \end{center}
    \end{tcolorbox}
    %
    \begin{tcolorbox}[opacityframe=0.5,colback=red!5!white,colframe=red!75!black]
        \begin{align*}
        \cos A = \frac{\text{Side adjacent to }\angle A}{Hypotenuse} =\frac{AB}{AC}
        \end{align*}
    \end{tcolorbox}
\end{frame}
%
\end{document}

在此处输入图片描述

答案1

与链接答案非常相似。使用记忆图片来记住节点,使用alias给标签命名,并使用overlay连接事物。

在此处输入图片描述

\documentclass[t]{beamer}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{color}
\usepackage{tcolorbox}
\newcommand{\tikznode}[2]{\relax
\ifmmode%
  \tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {$#2$};
\else
  \tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {#2};%
\fi}

\begin{document}
\begin{frame}{}
    \begin{tcolorbox}
        \begin{center}  
            \begin{tikzpicture}[scale=1.0,remember picture]
            %\tkzInit[xmax=4, ymax=6]
            %\tkzAxeXY
            %\tkzGrid
            %\tkzClip
            %
            \tkzDefPoint(0,3){A}
            \tkzDefPoint(0,0){B}
            \tkzDefPoint(6,0){C}

            \tkzDrawSegment(A,B)
            \tkzDrawSegment(A,C)
            \tkzDrawSegment(B,C)

            \tkzLabelPoints[below](B,C)
            \tkzLabelPoints[above](A)

            \tkzMarkRightAngle[size=0.4](A,B,C)

            \tkzLabelSegment[below,pos=.5,alias=lab2](B,C){Side opposite to $\angle A$}
            \tkzLabelSegment[sloped,alias=lab1](B,A){Side adjacent to $\angle A$}
            %\tkzLabelSegment[right,pos=.5,red](B,C){25 cm}
            \tkzLabelSegment[sloped,alias=lab3](C,A){Hypotenuse}
            \tkzMarkAngle[size=0.8](A,C,B)
            \tkzMarkAngle[size=0.6](B,A,C)
            %\tkzMarkAngle[size=0.5,mark=|](C,B,A)
            \end{tikzpicture}
        \end{center}
    \end{tcolorbox}
    %
    \begin{tcolorbox}[opacityframe=0.5,colback=red!5!white,colframe=red!75!black]
        \begin{align*}
        \cos A = \frac{\tikznode{Lab1}{\text{Side adjacent to }\angle A}}{%
        \tikznode{Lab3}{Hypotenuse}} =\frac{AB}{AC}
        \end{align*}
    \end{tcolorbox}
    \begin{tikzpicture}[overlay,remember picture]
     \draw[latex-latex] (Lab1) to[out=135,in=-90] (lab1.west);
     \draw[latex-latex] (Lab3.east) to[out=0,in=-45] (lab3.east);
    \end{tikzpicture}
\end{frame}
%
\end{document}

编辑:如果您想逐步展示连接,我建议您overlay-beamer-styles

\documentclass[t]{beamer}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{color}
\usepackage{tcolorbox}
\usetikzlibrary{overlay-beamer-styles} %<-added
\newcommand{\tikznode}[2]{\relax
\ifmmode%
  \tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {$#2$};
\else
  \tikz[remember picture,baseline=(#1.base),inner sep=0pt] \node (#1) {#2};%
\fi}

\begin{document}
\begin{frame}{}
    \begin{tcolorbox}
        \begin{center}  
            \begin{tikzpicture}[scale=1.0,remember picture]
            %\tkzInit[xmax=4, ymax=6]
            %\tkzAxeXY
            %\tkzGrid
            %\tkzClip
            %
            \tkzDefPoint(0,3){A}
            \tkzDefPoint(0,0){B}
            \tkzDefPoint(6,0){C}

            \tkzDrawSegment(A,B)
            \tkzDrawSegment(A,C)
            \tkzDrawSegment(B,C)

            \tkzLabelPoints[below](B,C)
            \tkzLabelPoints[above](A)

            \tkzMarkRightAngle[size=0.4](A,B,C)

            \tkzLabelSegment[below,pos=.5,alias=lab2](B,C){Side opposite to $\angle A$}
            \tkzLabelSegment[sloped,alias=lab1](B,A){Side adjacent to $\angle A$}
            %\tkzLabelSegment[right,pos=.5,red](B,C){25 cm}
            \tkzLabelSegment[sloped,alias=lab3](C,A){Hypotenuse}
            \tkzMarkAngle[size=0.8](A,C,B)
            \tkzMarkAngle[size=0.6](B,A,C)
            %\tkzMarkAngle[size=0.5,mark=|](C,B,A)
            \end{tikzpicture}
        \end{center}
    \end{tcolorbox}
    %
    \begin{tcolorbox}[opacityframe=0.5,colback=red!5!white,colframe=red!75!black]
        \begin{align*}
        \cos A = \frac{\tikznode{Lab1}{\text{Side adjacent to }\angle A}}{%
        \tikznode{Lab3}{Hypotenuse}} =\frac{AB}{AC}
        \end{align*}
    \end{tcolorbox}
    \begin{tikzpicture}[overlay,remember picture]
     \draw[latex-latex,visible on=<2->] (Lab1) to[out=135,in=-90] (lab1.west);
     \draw[latex-latex,visible on=<3->] (Lab3.east) to[out=0,in=-45] (lab3.east);
    \end{tikzpicture}
\end{frame}
%
\end{document}

在此处输入图片描述

相关内容