4
\documentclass{article}

\usepackage{amsmath}

\begin{document}
\begin{equation}
    \mathbf{v}_{\textnormal{h}}=\mathbf{v}_{\textnormal{h},0}\left(X_{\textnormal{m}}, X_{\textnormal{s}}, z\right)+\epsilon\mathbf{v}_{\textnormal{h},1}\left(X_{\textnormal{m}},X_{\textnormal{s}}, z\right)+\epsilon^2\mathbf{v}_{\textnormal{h},2}\left(X_{\textnormal{m}},X_{\textnormal{s}}, z\right)+\cdots\,.
\end{equation}
\end{document}

Question: How can I label epsilon? I'd like to have an arrow (\downarrow) pointing to the equation with text below the arrow.

Sylvia
  • 485
  • 7
  • see e.g. https://tex.stackexchange.com/q/449324/36296 , https://tex.stackexchange.com/questions/522517/annotate-math-equation-with-text-on-arrows-around-the-equation , https://tex.stackexchange.com/questions/539238/add-simple-pointed-annotations-to-equations-in-latex-as-a-ctan-package-improve , https://ctan.org/pkg/hf-tikz – samcarter_is_at_topanswers.xyz Jan 19 '24 at 12:58
  • 2
    Off-topic: Don't use \textnormal here; instead, use \mathrm. – Mico Jan 19 '24 at 13:21

2 Answers2

5

The following solution provides two user macros: \explainabove and \explainbelow. They employ \overset and \underset, respectively, which are macros provided by the amsmath package, as well as \mathclap, a macro provide by the mathtools package. (The mathtools package is a superset of the amsmath package.) That way, you can simply write \explainabove{some text}{\epsilon} and \explainbelow{more text}{\epsilon^2} to provide the desired annotations.

enter image description here

\documentclass{article}
\usepackage{mathtools} % for '\mathclap' macro; load 'amsmath' automatically

%% two new user macros \newcommand\explainabove[2]{% \overset{\overset{\mathclap{\textnormal{#1}}}{\downarrow}}{#2\mathstrut}} \newcommand\explainbelow[2]{% \underset{\underset{\mathclap{\textnormal{#1}}}{\uparrow}}{#2\mathstrut}}

\begin{document}

\begin{equation} \mathbf{v}{\mathrm{h}} =\mathbf{v}{\mathrm{h},0}(X_{\mathrm{m}},X_{\mathrm{s}},z) +\explainabove{some text}{\epsilon} \mathbf{v}{\mathrm{h},1}(X{\mathrm{m}},X_{\mathrm{s}},z) +\explainbelow{more text}{\epsilon^2} \mathbf{v}{\mathrm{h},2}(X{\mathrm{m}},X_{\mathrm{s}}, z) +\dotsb \end{equation}

\end{document}

Mico
  • 506,678
5

You can do it with \overset, where the upper part is a zero width tabular in the appropriate size, namely, \scriptsize.

In case you have various annotations, you may need to help TeX in order to get them at the same vertical position.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\annot}[2]{% #1 symbol to annotate, #2 = text \overset{% \makebox[0pt]{% \normalfont\scriptsize \begin{tabular}{@{}c@{}} #2 \ $\downarrow$ \end{tabular}% }% }{\mathstrut #1}% }

\begin{document}

\begin{equation} \mathbf{v}{\mathrm{h}}= \mathbf{v}{\mathrm{h},0}(X_{\mathrm{m}},X_{\mathrm{s}}, z) +\annot{\epsilon}{interesting}\mathbf{v}{\mathrm{h},1}(X{\mathrm{m}},X_{\mathrm{s}}, z) +\epsilon^2\mathbf{v}{\mathrm{h},2}(X{\mathrm{m}},X_{\mathrm{s}}, z) +\dotsb. \end{equation}

\begin{equation} \mathbf{v}{\mathrm{h}}= \mathbf{v}{\mathrm{h},0}(X_{\mathrm{m}},X_{\mathrm{s}}, z) +\annot{\epsilon\vphantom{\epsilon^2}}{interesting} \mathbf{v}{\mathrm{h},1}(X{\mathrm{m}},X_{\mathrm{s}}, z) +\annot{\epsilon^2}{more interesting} \mathbf{v}{\mathrm{h},2}(X{\mathrm{m}},X_{\mathrm{s}}, z) +\dotsb. \end{equation}

\end{document}

Note the omission of the useless \left and \right tokens, but also \dotsb instead of \cdots.

enter image description here

You can modify the code to allow for both above and below annotation: below positioning is obtained with \annot*.

\documentclass{article}
\usepackage{amsmath}

\NewDocumentCommand{\annot}{smm}{% % if *, below, otherwise above % #2 = symbol to annotate % #3 = text \IfBooleanTF{#1}{% \innerannot{\underset}{#2}{#3}{\textuparrow}% }{% \innerannot{\overset}{#2}{\textdownarrow}{#3}% }% } \NewDocumentCommand{\innerannot}{mmmm}{% #1{% \overset or underset \makebox[0pt]{% \normalfont\scriptsize \begin{tabular}{@{}c@{}} #4 \ #3 \end{tabular}% }% }{\mathstrut #2}% }

\begin{document}

\begin{equation} \mathbf{v}{\mathrm{h}}= \mathbf{v}{\mathrm{h},0}(X_{\mathrm{m}},X_{\mathrm{s}}, z) +\annot{\epsilon}{interesting}\mathbf{v}{\mathrm{h},1}(X{\mathrm{m}},X_{\mathrm{s}}, z) +\epsilon^2\mathbf{v}{\mathrm{h},2}(X{\mathrm{m}},X_{\mathrm{s}}, z) +\dotsb. \end{equation}

\begin{equation} \mathbf{v}{\mathrm{h}}= \mathbf{v}{\mathrm{h},0}(X_{\mathrm{m}},X_{\mathrm{s}}, z) +\annot{\epsilon\vphantom{\epsilon^2}}{interesting} \mathbf{v}{\mathrm{h},1}(X{\mathrm{m}},X_{\mathrm{s}}, z) +\annot{\epsilon^2}{more interesting} \mathbf{v}{\mathrm{h},2}(X{\mathrm{m}},X_{\mathrm{s}}, z) +\dotsb. \end{equation}

\begin{equation} \mathbf{v}{\mathrm{h}}= \mathbf{v}{\mathrm{h},0}(X_{\mathrm{m}},X_{\mathrm{s}}, z) +\annot{\epsilon}{interesting} \mathbf{v}{\mathrm{h},1}(X{\mathrm{m}},X_{\mathrm{s}}, z) +\annot*{\epsilon^2}{more interesting} \mathbf{v}{\mathrm{h},2}(X{\mathrm{m}},X_{\mathrm{s}}, z) +\dotsb. \end{equation}

\end{document}

enter image description here

egreg
  • 1,121,712