为什么 tikz 中的覆盖箭头没有出现在正确的位置?

为什么 tikz 中的覆盖箭头没有出现在正确的位置?

我正在尝试使用覆盖箭头来描述数学表达式的各个部分,tikz如下所示。但是,我无法正确定位箭头。

我得到的是: 在此处输入图片描述

我怎样才能正确放置它们,以将表达式的三个部分指向标签AAAABBBBBBBCCCCCCCCCC

\documentclass{beamer}

\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}

\begin{document}
    \begin{frame}
        \frametitle{Hello World}
        \begin{block}{Formulation}
        \tikzstyle{na} = [baseline=-.5ex]
                \vspace{0.6em}
                \begin{itemize}
                    \item Equation is 

                    \begin{equation}
                    \tikz[baseline]{\node[rounded corners,
                        fill=blue!10,draw=blue!30,anchor=base] (t12) {$AAAAA$};}
                    +p\,\,
                    \tikz[baseline]{\node[rounded corners,
                        fill=green!10,draw=green!30, anchor=base] (t22) {$BBBBB$};
                    }+q\,\,
                    \tikz[baseline]{\node[rounded corners,
                        fill=orange!10,draw=orange!30,anchor=base] (t32) {$CCCCCCC$};
                    }\nonumber
                    \end{equation}
                    AAAA\tikz[na] \node[coordinate] (n12) {}; \hfill
                      BBBBBBB\tikz[na] \node[coordinate] (n22) {};\hfill
                      \tikz[na] \node[coordinate] (n32) {};CCCCCCCCCC \\

                    \begin{tikzpicture}[overlay]
                    \path[->]<1-> (n12) edge[bend right](t12);
                    \path[->]<1-> (n22.north) edge[bend right](t22);
                    \path[->]<1-> (n32.west) edge[bend left](t32);
                    \end{tikzpicture}

               \end{itemize}                    
            \end{block}
    \end{frame}
\end{document}

提前致谢。

答案1

为了使 TikZ 能够正确地重用来自其他的坐标tikzpicture,您需要remember picture在环境/宏的选项中添加\tikz

因此,如果您只是将其remember picture作为选项添加到所有\tikz宏和tikzpicture环境中,您的代码就可以正常工作。或者,\tikzset{every picture/.append style={remember picture}}frame.

在此处输入图片描述

\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}

\begin{document}
    \begin{frame}
        \frametitle{Hello World}
        \begin{block}{Formulation}
                \vspace{0.6em}
                \tikzset{
                    na/.style={baseline=-.5ex},
                    % every picture/.append style={remember picture} % alternative to having remember picture everywhere below
                }
                \begin{itemize}
                    \item Equation is 

                    \begin{equation}
                    \tikz[baseline,remember picture]{\node[rounded corners,
                        fill=blue!10,draw=blue!30,anchor=base] (t12) {$AAAAA$};}
                    +p\,\,
                    \tikz[baseline,remember picture]{\node[rounded corners,
                        fill=green!10,draw=green!30, anchor=base] (t22) {$BBBBB$};
                    }+q\,\,
                    \tikz[baseline,remember picture]{\node[rounded corners,
                        fill=orange!10,draw=orange!30,anchor=base] (t32) {$CCCCCCC$};
                    }\nonumber
                    \end{equation}
                    AAAA\tikz[na,remember picture] \node[coordinate] (n12) {}; \hfill
                      BBBBBBB\tikz[na,remember picture] \node[coordinate] (n22) {};\hfill
                      \tikz[na,remember picture] \node[coordinate] (n32) {};CCCCCCCCCC \\

                    \begin{tikzpicture}[overlay,remember picture]
                    \path[->]<1-> (n12) edge[bend right](t12);
                    \path[->]<1-> (n22.north) edge[bend right](t22);
                    \path[->]<1-> (n32.west) edge[bend left](t32);
                    \end{tikzpicture}

               \end{itemize}                    
            \end{block}
    \end{frame}
\end{document}

相关内容