Strange behavior of underset

Adding baseline fixes it, I believe.

\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\newcommand{\bigswarrow}[1]{\tikz[baseline]{\draw[->](#1,3ex)--(0,0);}}
\begin{document}
\foreach \wid in {.1,.2,...,1}
{\bigswarrow{\wid em}}

\foreach \wid in {.1,.2,...,1}
{$\underset{\bigswarrow{\wid em}}{=}$}

\foreach \wid in {.1,.2,...,1}
{\bigswarrow{\wid}}

\foreach \wid in {.1,.2,...,1}
{$\underset{\bigswarrow{\wid}}{=}$}
\end{document}

enter image description here


Don't know why, but here is a fix. I put the underset arrows inside of an \hbox{...}

\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\newcommand{\bigswarrow}[1]{\tikz{\draw[->](#1,3ex)--(0,0);}}
\begin{document}
\foreach \wid in {.1,.2,...,1}
{\bigswarrow{\wid em}}

\foreach \wid in {.1,.2,...,1}
{$\underset{\hbox{\bigswarrow{\wid em}}}{=}$}

\foreach \wid in {.1,.2,...,1}
{\bigswarrow{\wid}}

\foreach \wid in {.1,.2,...,1}
{$\underset{\hbox{\bigswarrow{\wid}}}{=}$}
\end{document}

enter image description here

Alternately, giving a hat tip to marmot, I could force \bigswarrow onto the baseline by way of stackengine:

\usepackage{stackengine}
\newcommand{\bigswarrow}[1]{\abovebaseline[0pt]{\tikz{\draw[->](#1,3ex)--(0,0);}}}

Then, I wouldn't need the \hboxes.