答案1
基本上和沃纳的答案相同,但有一些概括:
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand*{\underarrow}{\def\@underarrow{\relax}\@ifstar{\@@underarrow}{\def\@underarrow{\hidewidth}\@@underarrow}}
\newcommand*{\@@underarrow}[2][]{\underset{\@underarrow\substack{\uparrow\if\relax\detokenize{#1}\relax\else\\#1\fi}\@underarrow}{#2}}
\newcommand*{\overarrow}{\def\@overarrow{\relax}\@ifstar{\@@overarrow}{\def\@overarrow{\hidewidth}\@@overarrow}}
\newcommand*{\@@overarrow}[2][]{\overset{\@overarrow\substack{\if\relax\detokenize{#1}\relax\else#1\\\fi\downarrow}\@overarrow}{#2}}
\makeatother
\begin{document}
\[
(1, 2, 3)
= (\underarrow{1}, 2, \overarrow{3})
= (1, \underarrow{2}, 3)
= (\overarrow[n=1]{1}, 2, \underarrow{3})
= (1, \underarrow[n = 2]{2}, 3)
= (\underarrow*[n=1]{1}, \underarrow*[n = 2 \\ n=2]{2}, 3)
\]
\end{document}
可以将额外文本作为可选参数提供。无星号版本会忽略可选参数的宽度,而带星号版本则不会。
答案2
一个简单的\uparrow
可以使用 来放置\underset{\uparrow}{<stuff>}
。如果你要添加宽内容,你可能需要考虑堆叠它们(使用\substack
- 一个小array
结构)和使用\mathclap
(从mathtools
)。
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[
x_1(n) = (1, 2, 3)
= (\underset{\uparrow}{1}, 2, 3)
= (1, \underset{\uparrow}{2}, 3)
= (1, 2, \underset{\uparrow}{3})
= (1, \underset{\mathclap{\substack{\uparrow \\ n = 2}}}{2}, 3)
\]
\end{document}
答案3
一种较低级别的方法,改编自 @wipet 的答案文字下方的箭头,使用\mathbin
提供的格式\limits...
,加上框和字距调整:
平均能量损失
\documentclass{article}
%%From:
%https://tex.stackexchange.com/questions/554923/arrow-under-text
%\def\type#1#2{\mathbin{\mathop{#1\kern0pt}%
% \limits_{\raise2.5ex\hbox to0pt{\hss\strut$\uparrow$\hss}\hbox to0pt{\hss#2\hss}}}}
\newcommand\typel[2]{%
\mathbin{\mathop{#1\kern0pt}%
\limits_{\raisebox{2.5ex}{\hbox to0pt{\hss\strut$\uparrow$\hss}}\hbox to0pt{\hss#2\hss}}}
}
\newcommand\typem[2]{%
\mathbin{\mathop{#1\kern0pt}%
\limits^{\raisebox{2.5ex}{\hbox to0pt{\hss#2\hss}}\hbox to0pt{\hss\strut$\downarrow$\hss}}}
}
\begin{document}
\[
x_1(n) = (1, 2, 3)
= (\typel{1}{$n=1$}, 2, 3)
= (1, \typel{2}{even}, 3)
= (1, 2, \typel{3}{})
= (1, \typel{2}{$n = 2$}, \typem{3}{odd})
\]
\end{document}