带有箭头的方程式标签

带有箭头的方程式标签

我正在尝试采用第二种解决方案“使用 Tikz 标记方程的变量而不使用 itemize”对于我的等式,P_t= P_T G_T G_t H_f

代码如下:

\documentclass{beamer}
\usetheme[progressbar=frametitle]{metropolis}
\setbeamertemplate{frame numbering}[fraction]
\useoutertheme{metropolis}
\useinnertheme{metropolis}
\usefonttheme{metropolis}
\usecolortheme{spruce}
\setbeamercolor{background canvas}{bg=white}
\definecolor{mygreen}{rgb}{.125,.5,.25}
\usecolortheme[named=mygreen]{structure}
\setbeamercovered{transparent=15}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{>=stealth}
\newcommand{\tikzmark}[3][]{\tikz[overlay,remember picture,baseline] \node [anchor=base,#1](#2) {#3};}
\begin{document}
\begin{frame}[t]{Channel model}
        \begin{itemize}
            \item<1-> The power coupled into the IC, $P_t$ is
        \end{itemize}
            \begin{equation*}
                P_t = \tikzmark{identity}{P_T} \tikzmark[red]{G}{G_T}\, 
                \tikzmark[blue]{L}{G_t} \tikzmark[purple]{C}{H_f}
            \end{equation*}

            \begin{tikzpicture}[overlay, remember picture,node distance =1.5cm]
                \node (identitydescr) [below left=of identity ]{transmitted power of the sender};
                \draw[,->,thick] (identitydescr) to [in=-90,out=90] (identity);
                \node[red] (Gdescr) [below =of G]{gain of the transmitter antenna};
                \draw[red,->,thick] (Gdescr) to [in=-90,out=90] (G);
                \node[blue,xshift=1cm] (Ldescr) [above right =of L]{gain of the box antenna};
                \draw[blue,->,thick] (Ldescr) to [in=45,out=-90] (L.north);
                \node[purple] (Cdescr) [below right =of C]{attenuation of the transmitted power};
                \draw[purple,->,thick] (Cdescr) to [in=-90,out=90] (C.south);
            \end{tikzpicture}
    \end{frame}
\end{document}

但它不像上面链接的解决方案那样工作。代码中似乎有几个问题,比如tikzmark不适用于数学运算G_T。此外,标签不能分成几行。我试过了,\\但它不起作用。我还想能够将放置tikzpicture在文本下方的某个部分。现在它覆盖了第一行文本,或者如果我将放入tikzpictureitemize 环境中,箭头和标签会出现位移。

我想知道如何控制用入角和出角指定的箭头的弯曲和位置。

问候

答案1

存在以下几个问题:

  • 如果你想使用类似的东西P_T\tikzmark你需要数学模式

  • 您之前将\tikzmark包含定义overlay为选项,这会隐藏内容的宽度,因此所有字母都叠加了。

  • 为了在描述中获得换行符,您可以使用将text width选项传递给节点。


请不要听信@marmot 并接受他的回答:)

\documentclass{beamer}

\usetheme[progressbar=frametitle]{moloch}% modern fork of the metropolis theme
\setbeamertemplate{page number in head/foot}[totalframenumber]
\usecolortheme{spruce}
\setbeamercolor{background canvas}{bg=white}
\definecolor{mygreen}{rgb}{.125,.5,.25}
\usecolortheme[named=mygreen]{structure}
\setbeamercovered{transparent=15}
\usepackage{pgfplots}


\usepackage{amsmath} % loaded automatically by beamer
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{>=stealth}

\newcommand{\tikzmark}[3][]{\tikz[remember picture,baseline] \node [anchor=base,#1](#2) {$#3$};}

\begin{document}
\begin{frame}[t]{Channel model}
    \begin{itemize}
        \item<1-> The power coupled into the IC, $P_t$ is
    \end{itemize}
        \begin{equation*}
            P_t = \tikzmark{identity}{P_T}\tikzmark[red]{G}{G_T}
            \tikzmark[blue]{L}{G_t}\tikzmark[purple]{C}{H_f}
        \end{equation*}
       \begin{tikzpicture}[overlay, remember picture,node distance =1.5cm]
            \node[,text width=2cm] (identitydescr) [below left=of identity ]{transmitted power of the sender};
            \draw[,->,thick] (identitydescr) to [in=-90,out=90] (identity);
            \node[red,text width=2cm] (Gdescr) [below =of G]{gain of the transmitter antenna};
            \draw[red,->,thick] (Gdescr) to [in=-90,out=90] (G);
            \node[blue,xshift=1cm,text width=2cm] (Ldescr) [above right =of L]{gain of the box antenna};
            \draw[blue,->,thick] (Ldescr) to [in=45,out=-90] (L.north);
            \node[purple,text width=2cm] (Cdescr) [below right =of C]{attenuation of the transmitted power};
            \draw[purple,->,thick] (Cdescr) to [in=-90,out=90] (C.south);
        \end{tikzpicture}
\end{frame}
\end{document}

在此处输入图片描述

答案2

如果你使用以下技巧,你的代码可以很好地编译这个答案.但你真的应该接受samcarter 的回答很好。其中解释了为什么会出现错误。Torbjørn 的回答通过使用检查节点是否处于数学环境中解决了该问题\ifmmode。我还按照 samcarter 的建议,在图片的节点上附加了文本宽度,并稍微缩短了箭头。

\documentclass{beamer}
\usetheme[progressbar=frametitle]{metropolis}
\setbeamertemplate{frame numbering}[fraction]
\useoutertheme{metropolis}
\useinnertheme{metropolis}
\usefonttheme{metropolis}
\usecolortheme{spruce}
\setbeamercolor{background canvas}{bg=white}
\definecolor{mygreen}{rgb}{.125,.5,.25}
\usecolortheme[named=mygreen]{structure}
\setbeamercovered{transparent=15}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{>=stealth}
% https://tex.stackexchange.com/a/402466/121799
\newcommand{\tikzmark}[3][]{
\ifmmode
\tikz[remember picture,baseline=(#2.base)] \node [inner sep=0pt,#1](#2) {$#3$};
\else
\tikz[remember picture,baseline=(#2.base)] \node [inner sep=0pt,#1](#2) {#3};
\fi
}
\begin{document}
\begin{frame}[t]{Channel model}
        \begin{itemize}
            \item<1-> The power coupled into the IC, $P_t$ is
        \end{itemize}
            \begin{equation*}
                P_t = \tikzmark{identity}{P_T} \tikzmark[red]{G}{G_T}\, 
                \tikzmark[blue]{L}{G_t} \tikzmark[purple]{C}{H_f}
            \end{equation*}

            \begin{tikzpicture}[overlay, remember picture,node distance =1.5cm,
            every node/.append style={text width=3cm,align=center},
            shorten >=1pt]
                \node (identitydescr) [below left=of identity ]{transmitted power of the sender};
                \draw[,->,thick] (identitydescr) to [in=-90,out=90] (identity);
                \node[red] (Gdescr) [below =of G]{gain of the transmitter antenna};
                \draw[red,->,thick] (Gdescr) to [in=-90,out=90] (G);
                \node[blue,xshift=1cm,yshift=-0.6cm] (Ldescr) [above right =of L]{gain of the box antenna};
                \draw[blue,->,thick] (Ldescr) to [in=45,out=-90] (L.north);
                \node[purple] (Cdescr) [below right =of C]{attenuation of the transmitted power};
                \draw[purple,->,thick] (Cdescr) to [in=-90,out=90] (C.south);
            \end{tikzpicture}
    \end{frame}
\end{document}

在此处输入图片描述

您可以使用 强力居中方程\vfillinout只是进入或离开路径的角度,类似于撞击角和离开路径的模拟。默认情况下,TiZ 在它认为合适的位置启动节点。你可以推翻这个,例如

\draw[->,thick] (identitydescr.north east) to [in=-90,out=90] (identity);

但我不喜欢这个结果。如果你改变撞击和出射角度

\draw[->,thick] (identitydescr) to [in=-45,out=45] (identity);

你得到

在此处输入图片描述

另一个要玩的参数是looseness,它在动画中会发生变化

\documentclass{beamer}
\usetheme[progressbar=frametitle]{metropolis}
\setbeamertemplate{frame numbering}[fraction]
\useoutertheme{metropolis}
\useinnertheme{metropolis}
\usefonttheme{metropolis}
\usecolortheme{spruce}
\setbeamercolor{background canvas}{bg=white}
\definecolor{mygreen}{rgb}{.125,.5,.25}
\usecolortheme[named=mygreen]{structure}
\setbeamercovered{transparent=15}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{>=stealth}
% https://tex.stackexchange.com/a/402466/121799
\newcommand{\tikzmark}[3][]{
\ifmmode
\tikz[remember picture,baseline=(#2.base)] \node [inner sep=0pt,#1](#2) {$#3$};
\else
\tikz[remember picture,baseline=(#2.base)] \node [inner sep=0pt,#1](#2) {#3};
\fi
}
\begin{document}
\foreach \X in {0.5,0.6,...,1.2,1.4,...,2}
{\begin{frame}[t]{Channel model}
        \begin{itemize}
            \item<1-> The power coupled into the IC, $P_t$ is
        \end{itemize}
        \vfill
            \begin{equation*}
                P_t = \tikzmark{identity}{P_T} \tikzmark[red]{G}{G_T}\, 
                \tikzmark[blue]{L}{G_t} \tikzmark[purple]{C}{H_f}
            \end{equation*}
\vfill
            \begin{tikzpicture}[overlay, remember picture,node distance =1.5cm,
            every node/.append style={text width=3cm,align=center},
            shorten >=1pt,looseness=\X]
                \node (identitydescr) [below left=of identity ]{transmitted power of the sender};
                \draw[,->,thick] (identitydescr) to [in=-90,out=90] (identity);
                \node[red] (Gdescr) [below =of G]{gain of the transmitter antenna};
                \draw[red,->,thick] (Gdescr) to [in=-90,out=90] (G);
                \node[blue,xshift=1cm] (Ldescr) [above right =of L]{gain of the box antenna};
                \draw[blue,->,thick] (Ldescr) to [in=45,out=-90] (L.north);
                \node[purple] (Cdescr) [below right =of C]{attenuation of the transmitted power};
                \draw[purple,->,thick] (Cdescr) to [in=-90,out=90] (C.south);
            \end{tikzpicture}
    \end{frame}}
\end{document}

在此处输入图片描述

相关内容