2

I want something like \sim^a but with the 'a' in the top center not like a power.

CampanIgnis
  • 4,624
dxander
  • 21

2 Answers2

5

See a comparison. Naturally, you might want to define the operator of your choice as a separate macro.

\documentclass{memoir}
\usepackage{amsmath}

\begin{document}

\begin{align} 1&\sim^a x\ 2&\stackrel a\sim x\%obsolete 3&\mathop\sim^a x\ 4&\overset a\sim x\ 5&\substack{a\\sim} x\ 6&\begin{subarray}{c}a\\sim\end{subarray} x\ 7&\buildrel a\over\sim x\ \end{align}

\end{document}

enter image description here

Related.

CampanIgnis
  • 4,624
  • 3
    Note that \stackrel{a}{\sim} is essentially equivalent to \overset{a}{\sim}, because \sim is a relation symbol. Both end up in doing \mathop{\sim}\limits^a, with the big difference that the latter is generally unwanted if not wrapped in \mathrel (and you get a above \sim just by chance, because align uses display math mode). Number 7 is the same as number 2, only using a foreign syntax. – egreg Jun 30 '20 at 22:39
  • 1
    Thanks for the details. Very thoughtful. – dxander Jul 02 '20 at 00:23
2

Just I'm adding the use of another package called accents. Here there are others output but with a lot of sincerity the correct solutions are those referred to the comments and response of the good user @CampanIgnis.

Edit after the comment of the very nice user @egreg using \mathrel.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{accents}

\begin{document} \textit{one option}, , $\square\mathrel{\accentset{a}{\sim}}\blacksquare$

\texttt{another options} [\triangle\mathrel{\accentset{\displaystyle a}{\sim}}\square] [\diamond\mathrel{\accentset{\scriptstyle a}{\sim}}\square] [\blacksquare\mathrel{\accentset{\scriptscriptstyle a}{\sim}}\triangle] \end{document}

enter image description here

Sebastiano
  • 54,118