Labels with arrows for an equation
There are a couple of problems:
If you want to use things like
P_T
in the\tikzmark
, you need math modeYour previous definition of
\tikzmark
containedoverlay
as option, this hides the width of the content, thus all your letters were superimposed.To get line breaks in your descriptions, you can use pass the
text width
option to the node.if you load the
metropolis
theme, there is no need to load its outer, inner and font themes a second time.
And please don't listen to @marmot and accept his answer :)
\documentclass{beamer}
\usetheme[progressbar=frametitle]{metropolis}
\setbeamertemplate{frame numbering}[fraction]
\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}
Your code compiles beautifully if you use the tricks of this answer. But you should really accept samcarter's nice answer. There it is explained why you got the error. Torbjørn's answer solves that problem by using \ifmmode
to check whether the node is in a math environment. I also appended a text width to the nodes of the picture, as suggested by samcarter, and shortened the arrows a bit.
\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}
You can center the equation brute force using \vfill
. in
and out
are just the angles of the ingoing or outgoing path, something like an impact angle and the analog for the outgoing path. By default, TikZ starts the node at a position that it finds appropriate. You could overrule this e.g. by
\draw[->,thick] (identitydescr.north east) to [in=-90,out=90] (identity);
but I do not like the result. If you change the impact and outgoing angles
\draw[->,thick] (identitydescr) to [in=-45,out=45] (identity);
you get
Another parameter to play with is looseness
, which gets varied in the animation
\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}