在 tikzpicture 中绘制一个指向节点边缘的箭头

在 tikzpicture 中绘制一个指向节点边缘的箭头

我已经写了这个乳胶文档:

\documentclass[dvipsnames,aspectratio=169,10pt,fleqn]{beamer}
\usetheme{Madrid}

\usefonttheme{serif}
\usecolortheme[named=Mahogany]{structure}


\usepackage{tikz}

\usetikzlibrary{arrows,shapes,mindmap,trees,backgrounds}
\tikzstyle{every picture}+=[remember picture]
\tikzstyle{na} = [baseline=-.5ex]
\tikzset{
    invisible/.style={opacity=0,text opacity=0},
    visible on/.style={alt=#1{}{invisible}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
    },
}

\tikzset{
  background fill/.style={fill=#1},
  background fill/.default={white},
  fill on/.style={alt=#1{}{background fill}},
}

\tikzset{
  background draw/.style={draw=#1},
  background draw/.default={white},
  draw on/.style={alt=#1{}{background draw}},
}

\tikzset{
  background filldraw/.style 2 args={draw=#1, fill=#2},
  background filldraw/.default={white}{white},
  filldraw on/.style={alt=#1{}{background filldraw}},
}

\tikzset{
  background shade/.style={#1},
  background shade/.default={top color=white, bottom color=white},
  shade on/.style={alt=#1{}{background shade}},
}

\tikzset{
  background shadedraw/.style 2 args={draw=#1, #2},
  background shadedraw/.default={white}{top color=white, bottom color=white},
  shadedraw on/.style={alt=#1{}{background shadedraw}},
}



\newcommand{\tikzmark}[1]{\tikz[remember picture] \node[coordinate] (#1) {#1};}

\setbeamerfont{caption}{size=\tiny}
\setlength\abovecaptionskip{0pt}
\setbeamertemplate{caption}[numbered]

\usetikzlibrary{positioning, shapes.arrows,shadows.blur}
\usetikzlibrary{arrows,shapes,backgrounds}



\begin{document}

\begin{frame}
\frametitle{Example}

    \begin{columns}
    \begin{column}{.5\textwidth}

    \centering
    \begin{tikzpicture}[]
                \node [inner sep=0pt,above right]
                {\includegraphics[width=0.4\textwidth]{test.png}};

                \path (1.3,0.7) coordinate (Nodefig);
    \end{tikzpicture}

    \end{column}


    \begin{column}{.5\textwidth}

     \tikz[baseline]{ \node[align=center] (n1) {Test};}

    \end{column}
    \end{columns}




 \begin{tikzpicture}[overlay]
         \draw<1-> [thin, red,opacity=.3, fill=red,fill opacity=0.2](Nodefig) ellipse (2cm and 1.5cm);

         \path[->,line width=0.8pt,color=BrickRed]<1-> (n1) edge [out=-180, in=0] (Nodefig);
 \end{tikzpicture}

\end{frame}



\end{document}

结果如下:

在此处输入图片描述

但是,我希望箭头正好停在红色椭圆的边缘。我查看了不同的帖子,但仍然无法得到我想要的。我想,这里的问题是我在 tikzpicture 中工作,并且像上面那样命令,西或东似乎不起作用。

有人能给我胶水吗?谢谢

答案1

您可以使用节点形状,而不必手动绘制椭圆ellipse。这样箭头就会自动停在节点的边缘:

\documentclass[dvipsnames,aspectratio=169,10pt,fleqn]{beamer}
\usetheme{Madrid}

\usefonttheme{serif}
\usecolortheme[named=Mahogany]{structure}


\usepackage{tikz}

\usetikzlibrary{arrows,shapes,mindmap,trees,backgrounds}
\tikzset{every picture/.append style={remember picture}}
\tikzset{na/.style={baseline=-.5ex}}
\tikzset{
    invisible/.style={opacity=0,text opacity=0},
    visible on/.style={alt=#1{}{invisible}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
    },
}

\tikzset{
  background fill/.style={fill=#1},
  background fill/.default={white},
  fill on/.style={alt=#1{}{background fill}},
}

\tikzset{
  background draw/.style={draw=#1},
  background draw/.default={white},
  draw on/.style={alt=#1{}{background draw}},
}

\tikzset{
  background filldraw/.style 2 args={draw=#1, fill=#2},
  background filldraw/.default={white}{white},
  filldraw on/.style={alt=#1{}{background filldraw}},
}

\tikzset{
  background shade/.style={#1},
  background shade/.default={top color=white, bottom color=white},
  shade on/.style={alt=#1{}{background shade}},
}

\tikzset{
  background shadedraw/.style 2 args={draw=#1, #2},
  background shadedraw/.default={white}{top color=white, bottom color=white},
  shadedraw on/.style={alt=#1{}{background shadedraw}},
}



\newcommand{\tikzmark}[1]{\tikz[remember picture] \node[coordinate] (#1) {#1};}

\setbeamerfont{caption}{size=\tiny}
\setlength\abovecaptionskip{0pt}
\setbeamertemplate{caption}[numbered]

\usetikzlibrary{positioning, shapes.arrows,shadows.blur}
\usetikzlibrary{arrows,shapes,backgrounds}



\begin{document}

\begin{frame}
\frametitle{Example}

    \begin{columns}
    \begin{column}{.5\textwidth}

    \centering
    \begin{tikzpicture}[]
                \node [inner sep=0pt,above right]
                {\includegraphics[width=0.4\textwidth]{example-image-duck}};

                \path (1.3,0.7) coordinate (Nodefig);
    \end{tikzpicture}

    \end{column}


    \begin{column}{.5\textwidth}

     \tikz[baseline]{ \node[align=center] (n1) {Test};}

    \end{column}
    \end{columns}




 \begin{tikzpicture}[overlay]
         \node<1-> [thin, red,opacity=.3, fill=red,fill opacity=0.2,ellipse,minimum width=2cm,minimum height=1.5cm] (foo)  at (Nodefig) {};

         \path[->,line width=0.8pt,color=BrickRed]<1-> (n1) edge [out=-180, in=0] (foo);
 \end{tikzpicture}

\end{frame}



\end{document}

在此处输入图片描述

相关内容