在 tikz 中写入路径

在 tikz 中写入路径

我正在尝试连接一些节点,tikz但有些东西无法正常工作。关于第三条路径:

1-) 我怎样才能让它向左移动或从“第三个量”的顶部向等式中指定项的中心底部移动?目前它正在向上移动并到达左侧。

2-) 是否可以将“第二数量”和“第三数量”放在同一行?

\documentclass{beamer} %
\usetheme{CambridgeUS}
\usepackage[latin1]{inputenc}
\usefonttheme{professionalfonts}
\usepackage{times}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}

\author{Author}
\title{Presentation title}

\begin{document}

\tikzstyle{every picture}+=[remember picture]

\everymath{\displaystyle}


\begin{frame}
\frametitle{Description}

\tikzstyle{na} = [baseline=-.5ex]

First quantity
    \tikz[na] \node[coordinate] (n1) {};

\begin{equation*}
 A = B +
    \tikz[baseline]{
        \node[fill=blue!20,anchor=base] (t1)
        {$ 2C\times D$};
    } +
    \tikz[baseline]{
        \node[fill=red!20, ellipse,anchor=base] (t2)
        {$F\otimes G$};
    } +
    \tikz[baseline]{
        \node[fill=green!20,anchor=base] (t3)
        {$H$};
    }
\end{equation*}

Second quantity
    \tikz[na]\node [coordinate] (n2) {};
        \begin{flushright}
        \tikz[na]\node [coordinate] (n3) {};
Third quantity (check p.46)
\end{flushright}

\begin{tikzpicture}[overlay]
    \path[->]<1-> (n1) edge [bend left] (t1);
    \path[->]<1-> (n2) edge [bend right] (t2);
    \path[->]<1-> (n3) edge [bend left](t3);
\end{tikzpicture}
\end{frame}

\end{document}

答案1

如果我理解正确的话,对于 1),使用out=90,in=270而不是bend leftedge画线。对于 2),删除环境flushright,并在属于和 的\hfill节点之间添加一个。Second..Third ..

(我可能误解了你对第一个问题的意思,如果你想要不同的东西,请发表评论。)

在此处输入图片描述

\documentclass{beamer} %
\usetheme{CambridgeUS}
\usepackage[latin1]{inputenc}
\usefonttheme{professionalfonts}
\usepackage{times}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}

\author{Author}
\title{Presentation title}

\begin{document}

\tikzstyle{every picture}+=[remember picture]

\everymath{\displaystyle}


\begin{frame}
\frametitle{Description}

\tikzstyle{na} = [baseline=-.5ex]

First quantity
    \tikz[na] \node[coordinate] (n1) {};

\begin{equation*}
 A = B +
    \tikz[baseline]{
        \node[fill=blue!20,anchor=base] (t1)
        {$ 2C\times D$};
    } +
    \tikz[baseline]{
        \node[fill=red!20, ellipse,anchor=base] (t2)
        {$F\otimes G$};
    } +
    \tikz[baseline]{
        \node[fill=green!20,anchor=base] (t3)
        {$H$};
    }
\end{equation*}

\bigskip

Second quantity
    \tikz[na]\node [coordinate] (n2) {}; \hfill
        \tikz[na]\node [coordinate] (n3) {};
Third quantity (check p.46)


\begin{tikzpicture}[overlay]
    \path[->]<1-> (n1) edge [bend left] (t1);
    \path[->]<1-> (n2) edge [bend right] (t2);
    \path[->]<1-> (n3) edge [out=90,in=270](t3);
\end{tikzpicture}
\end{frame}

\end{document}

如果您希望箭头从单词中间开始,则有几个选项。一个是将 移动到\tikz\node...单词之间,因为这是定义起点的地方。在这种情况下,您可能希望将其向上移动一点,因此不要使用样式na,而是添加类似 的内容baseline=-1.5ex

第二种选择是将单词本身放在节点中,因此不要说Second quantity\tikz\node...,而是使用。然后,您可以从(或)\tikz[na]\node(n2){Second quantity};开始箭头。以下代码演示了这两个选项。n2.southnorth

在此处输入图片描述

\documentclass{beamer}
\usetheme{CambridgeUS}
\usepackage[latin1]{inputenc}
\usefonttheme{professionalfonts}
\usepackage{times}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}

\author{Author}
\title{Presentation title}

\tikzset{every picture/.append style={remember picture},
na/.style={baseline=-.5ex}}

\everymath{\displaystyle}
\begin{document}
\begin{frame}
\frametitle{Description}
First quantity
    \tikz[na] \node[coordinate] (n1) {};

\begin{equation*}
 A = B +
    \tikz[baseline]{
        \node[fill=blue!20,anchor=base] (t1)
        {$ 2C\times D$};
    } +
    \tikz[baseline]{
        \node[fill=red!20, ellipse,anchor=base] (t2)
        {$F\otimes G$};
    } +
    \tikz[baseline]{
        \node[fill=green!20,anchor=base] (t3)
        {$H$};
    }
\end{equation*}

\bigskip

% first option: place the text in a node, refer to nodename.south (or north)
\tikz[na]\node(n2){Second quantity};
\hfill
% second option: move the coordinate node between the words, and move the baseline a bit upwards.
Third \tikz[baseline=-1.5ex]\node [coordinate] (n3) {};quantity (check p.46)

\begin{tikzpicture}[overlay]
    \path[->]<1-> (n1) edge [bend left] (t1);
    \path[->]<1-> (n2.south) edge [bend right] (t2);
    \path[->]<1-> (n3) edge [out=90,in=270](t3);
\end{tikzpicture}
\end{frame}

\end{document}

相关内容