答案1
也许你想要这样的东西:
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newsavebox{\jan@xtilde@base}
\newsavebox{\jan@xtilde@top}
\newcommand{\xtilde}[2][]{%
\if\relax\detokenize{#1}\relax
\tilde{#2}%
\else
{\jan@xtilde{#1}{#2}}%
\fi
}
\newcommand{\jan@xtilde}[2]{%
\sbox\jan@xtilde@top{$\m@th\scriptscriptstyle#1$}%
\sbox\jan@xtilde@base{$\m@th#2$}%
\kern-.25\wd\jan@xtilde@top
\tilde{%
\kern.25\wd\jan@xtilde@top
#2%
}%
\kern-.75\wd\jan@xtilde@top
\raisebox{\dimexpr\ht\jan@xtilde@base+\dp\jan@xtilde@top+1.5pt}{\copy\jan@xtilde@top}%
\kern-.25\wd\jan@xtilde@top
}
\makeatother
\begin{document}
$X\xtilde{X}\xtilde[i]{X}X\xtilde[f]{X}$
\end{document}
答案2
\documentclass{minimal}
\begin{document}
\let\origtilde\tilde
\def\tilde#1{\origtilde{#1}Hello!}
$\tilde{a}$
\end{document}
更新
在您编辑帖子后,我明白了您想要什么。
此解决方案使用accents
命令\setaccent
和(我希望波浪线位于字符的中心)。此外,我使用mathtools
而不是波浪线,因为添加字符后看起来更好\mathrlap
\sim
\documentclass{article}
\usepackage{mathtools,accents}
\thispagestyle{empty}
\begin{document}
$\accentset{\sim\mathrlap{i}}{a}$
\end{document}