Beamer TikZ 更改锚点

Beamer TikZ 更改锚点

我无法更改某个节点的锚点。我的代码是:

\begin{frame}
\frametitle{Utility Maximisation}

\begin{itemize}
    \item Expected Utility of Future Wealth
        \tikz[remember picture, overlay, baseline=-.5ex]\node (n1) {};
\end{itemize}

\begin{equation*}
\begin{aligned}
& \underset{w}{\text{maximise}} 
& & \tikz[baseline]{
        \node[fill=blue!20,anchor=base] (t1)
            {$\mathbb{E}[U(W_{t+1})] $};
    } \\
& \text{subject to}
& & W_{t+1} = (1 + 
\tikz[baseline]{
        \node[fill=red!20,anchor=base] (t3)
            {$ r^P_{t+1} $};
    } )
    \tikz[baseline]{
            \node[fill=yellow!20,anchor=base] (t4)
                {$ W_t $}; 
    } \\
&&& \tikz[baseline]{
        \node[fill=green!20,anchor=base] (t2)
            {$ \boldsymbol w \cdot \boldsymbol \iota = 1 $};
        } \\
&&& \tikz[baseline]{
        \node[fill=cyan!20,anchor=base] (t5)
            {$ \boldsymbol w \ge 0 $ };
    }
\end{aligned}
\end{equation*}

\begin{itemize}
    \item No Shorting
        \tikz[remember picture, overlay, baseline=-.5ex]\node (n5) {};
    \item Portfolio Constraint
        \tikz[remember picture, overlay, baseline=-.5ex]\node (n2) {};
    \item Portfolio Return
        \tikz[remember picture, overlay, baseline=-.5ex]\node (n3) {};
    \item Current Wealth
        \tikz[remember picture, overlay, baseline=-.5ex]\node (n4) {};
\end{itemize}

\begin{tikzpicture}[overlay]
    \path[->]<1-> (n1) edge [bend left] (t1);
    \path[->]<1-> (n5) edge [out=0, in=-90] (t5);
    \path[->]<1-> (n2) edge [out=0, in=-90] (t2);
    \path[->]<1-> (n3) edge [out=0, in=-90] (t3);
    \path[->]<1-> (n4) edge [out=0, in=-90] (t4);
\end{tikzpicture}

\end{frame}

我希望 (t2) 锚点位于节点框的东南角,这样它就不会穿过下面的框。我尝试将锚点更改为“东南”,但这没有任何效果。抱歉,这是一个愚蠢的问题(我今天才开始使用 TikZ)。

答案1

为此,您可以轻松设置到达点,方法是:

\path[->]<1-> (n2) edge [out=0, in=-90] (t2);

改成:

\path[->]<1-> (n2) edge [out=0, in=-90] (t2.south east);

这是我的 MWE(remember picture当您致电时我添加了一些\tikz):

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
\begin{frame}
\frametitle{Utility Maximisation}

\begin{itemize}
    \item Expected Utility of Future Wealth
        \tikz[remember picture, overlay, baseline=-.5ex]\node (n1) {};
\end{itemize}

\begin{equation*}
\begin{aligned}
& \underset{w}{\text{maximise}} 
& & \tikz[remember picture,baseline]{
        \node[fill=blue!20,anchor=base] (t1)
            {$\mathbb{E}[U(W_{t+1})] $};
    } \\
& \text{subject to}
& & W_{t+1} = (1 + 
\tikz[remember picture,baseline]{
        \node[fill=red!20,anchor=base] (t3)
            {$ r^P_{t+1} $};
    } )
    \tikz[remember picture,baseline]{
            \node[fill=yellow!20,anchor=base] (t4)
                {$ W_t $}; 
    } \\
&&& \tikz[remember picture,baseline]{
        \node[fill=green!20,anchor=base] (t2)
            {$ \boldsymbol w \cdot \boldsymbol \iota = 1 $};
        } \\
&&& \tikz[remember picture,baseline]{
        \node[fill=cyan!20,anchor=base] (t5)
            {$ \boldsymbol w \ge 0 $ };
    }
\end{aligned}
\end{equation*}

\begin{itemize}
    \item No Shorting
        \tikz[remember picture, overlay, baseline=-.5ex]\node (n5) {};
    \item Portfolio Constraint
        \tikz[remember picture, overlay, baseline=-.5ex]\node (n2) {};
    \item Portfolio Return
        \tikz[remember picture, overlay, baseline=-.5ex]\node (n3) {};
    \item Current Wealth
        \tikz[remember picture, overlay, baseline=-.5ex]\node (n4) {};
\end{itemize}

\begin{tikzpicture}[remember picture,overlay]
    \path[->]<1-> (n1) edge [bend left] (t1);
    \path[->]<1-> (n5) edge [out=0, in=-90] (t5);
    \path[->]<1-> (n2) edge [out=0, in=-90] (t2.south east);
    \path[->]<1-> (n3) edge [out=0, in=-90] (t3);
    \path[->]<1-> (n4) edge [out=0, in=-90] (t4);
\end{tikzpicture}

\end{frame}


\end{document}

结果是:

在此处输入图片描述

另一个选项是指定您想要指向的锚点的角度:

\path[->]<1-> (n1) edge [bend left] (t1.17);
\path[->]<1-> (n2) edge [out=0, in=-90] (t2.340);

要得到:

在此处输入图片描述

我更喜欢后一种情况,箭头并不正好位于角落里:您需要根据自己的思维来计算角度(这并不难),但结果确实更好。

相关内容