1

How can write text over stretched tilde in math mode? I want the tilde length to be automatically stretched to the size of the text on it. Like this figure! enter image description here MWE:

\documentclass{article}
\usepackage{amsmath, amssymb}
\begin{document}
\[ \sin x\stackrel{x\to 0}{\sim} x \]
\end{document}
Mohammadi
  • 357
  • 1
  • 11

1 Answers1

2

Not a very beautiful notation for my personal taste. Adapting a little bit the code from How to produce a longer \sim with a small letter on top

\documentclass{article}

\usepackage{amsmath,graphicx}

\makeatletter % helper macro I snitched somewhere on this site \newcommand{\smallerstyle}[1]{% \ifx#1\displaystyle\scriptstyle\else \ifx#1\textstyle\scriptstyle\else \scriptscriptstyle\fi\fi }

\newcommand{\xsim}[1]{\mathrel{\mathpalette\x@sim{#1}}} \newcommand{\x@sim}[2]{% \sbox0{\m@th$\smallerstyle#1,#2,$}% \sbox1{\m@th$#1\sim$}% #1\mathop{% \ifdim\wd0>\wd1 \resizebox{\wd0}{\height}{\box1}% \else \box1 \fi }\limits^{#2}% } \makeatother

\begin{document}

$A \xsim{a} B \xsim{a\to0} C$\par\medskip $\sin(x) \xsim{x\to0} x$ $\scriptstyle \sin(x) \xsim{x\to0} x$ $\scriptscriptstyle \sin(x) \xsim{x\to0} x$

\end{document}

enter image description here

campa
  • 31,130
  • Thank you. I do not know who closed the question, but here, unlike that question, the length of the tilde varies. – Mohammadi Mar 23 '21 at 19:01