Text below equation with hf-tikz
I'd use an array
with top alignment:
\documentclass[aspectratio=169]{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{mathtools}
\usepackage{hf-tikz}
\begin{document}
\begin{frame}
\frametitle{Text under equation blocks}
\[
a =
\onslide<2->%
\begin{array}[t]{@{}c@{}}
\tikzmarkin{a}\onslide<1-> b\onslide<2->\tikzmarkend{a}\\
\scriptstyle\text{\alert{text1}}
\end{array}
\onslide<1->+
\onslide<3->%
\begin{array}[t]{@{}c@{}}
\tikzmarkin{b}\onslide<1-> c\onslide<3->\tikzmarkend{b}\\
\scriptstyle\text{\color{brown}text2}
\end{array}
\]
\end{frame}
\end{document}
The slight misalignment is due to manually taking screen shots
Using the markings
option of the package one might derive an \annotate
command:
\newcommand{\annotate}[2][]{
\tikz[remember picture,overlay]\node[#1,use marker id] at (0,0){#2};
}
A complete example:
\documentclass[aspectratio=169]{beamer}
\usepackage{lmodern}
\usepackage{mathtools}
\usepackage[beamer,markings]{hf-tikz}% hf-tikz load itself tikz and the calc library
\newcommand{\annotate}[2][]{
\tikz[remember picture,overlay]\node[#1,use marker id] at (0,0){#2};
}
\tikzset{
invisible/.style={opacity=0},
visible on/.style={alt={#1{}{invisible}}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
},
}
\begin{document}
\begin{frame}
\frametitle{Text under equation blocks}
\begin{equation*}
\begin{aligned}
a = \phantom{aaaaa}\tikzmarkin<1->[mark at=0.825]{a}b\tikzmarkend{a}\annotate[visible on=<1->,below,red,font=\scriptsize]{Model Mismatch}
\phantom{aaaaa} +\phantom{Noi} \tikzmarkin<2->[mark at=0.825]{b}c\tikzmarkend{b}\annotate[visible on=<2->,below,brown,font=\scriptsize]{Noise}
\end{aligned}
\end{equation*}
\end{frame}
\end{document}
The key points are:
- mark the positions with the
mark at
key (to verify where the location is marked you might use in combination theshow markers
key); - insert some
phantom
space between and after the variable highlighted as the annotation text is too much larger with respect to the variables.
The result:
Improved version
According to egreg's comment, here is a more automatic solution exploiting \mathmakebox
from the mathtools
package. It provides a new \tikzmarkaligned
command which sets the space according to the annotation width:
\documentclass[aspectratio=169]{beamer}
\usepackage{lmodern}
\usepackage{mathtools,xparse}
\usepackage[beamer,markings]{hf-tikz}% hf-tikz load itself tikz and the calc library
\newcommand<>{\annotate}[2][]{
\onslide#3{
\tikz[remember picture,overlay]\node[#1,use marker id] at (0,0){#2};
}
}
\newlength{\notewidth}
\newcommand{\setnotewidth}[1]{%
\settowidth{\notewidth}{$#1$}%
}
\newcommand{\mth}[2]{
\setnotewidth{#2}
\mathmakebox[0.355\notewidth]{#1}
}
\NewDocumentCommand{\tikzmarkaligned}{r<> o m m}{
\phantom{\mth{#3}{#4}}
\tikzmarkin<#1>[#2]{#3}#3\tikzmarkend{#3}
\phantom{\mth{#3}{#4}}
}
\begin{document}
\begin{frame}
\frametitle{Text under equation blocks}
\begin{equation*}
\begin{aligned}
a =
\tikzmarkaligned<1->[mark at=0.825]{a}{Model Mismathc}
\annotate<1->[below,red,font=\scriptsize]{Model Mismatch}+
\tikzmarkaligned<2->[mark at=0.825]{b}{Noise}
%\tikzmarkin<2->[mark at=0.825]{b}c\tikzmarkend{b}
\annotate<2->[below,brown,font=\scriptsize]{Noise}
\end{aligned}
\end{equation*}
\end{frame}