6

I'm having trouble changing the anchor point on for one of my nodes. My code is:

\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}

I would like the (t2) anchor point to be on the south east corner of the nodes box so it doesn't pass through the box below. I've tried changing the anchor point to "south east" but this doesn't have any effect. Sorry if this is a dumb question (I've only started using TikZ today).

  • It's generally encouraged to post full compilable examples, starting from \documentclass. That saves others the work of having to complete the code. – Jake Jun 22 '12 at 15:09
5

For this purpose you can easily set the arrival point when you say:

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

Change it into:

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

Here is my MWE (I added some remember picture when you call \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}

The result is:

enter image description here

Another option could be to specify the angle of the anchor you want to point to:

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

to get:

enter image description here

In latter case, that I prefer, the arrow is not placed exactly in the corner: you need to compute by mind the angle (it is not difficult), but the result is really better.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.