2

Quick and simple question (actually surprised I couldn't find it on Stackexchange already): How can I typeset (in math mode) quantities with a tilde on top that is enclosed in parentheses?

Something akin to this would be nice:

enter image description here

I hope there's a solution without (a lot of) manual tinkering that clutters up my preamble

Janosh
  • 4,042

3 Answers3

4

How about this:

\documentclass{article}
\newcommand\ptwiddle[1]{\mathord{\mathop{#1}\limits^{\scriptscriptstyle(\sim)}}}
\begin{document}
$\ptwiddle{A} + \ptwiddle{B} = \ptwiddle{C}$
\end{document}

enter image description here

Since I've hard coded the \scriptscriptstyle size, this might not look so good in a subscript.

Thruston
  • 42,268
3

I came across this topic because I was looking for a solution to the same problem as the OP. Although the proposed solution worked, I was not really satisfied with the result, especially because the parentheses and the tilde were still quite chubby. Unlike originally wished by the OP, cluttering up my preamble was not a problem for me.

What I ended up doing instead is:

1) Use @Pieter van Oostrum 's answer to establish a nicer widetilde in the first place. The block below the first comment in my code is completely taken over from his solution.

2) I then combined this with ideas from @Alenanno 's post here to also write a command that furthermore puts said widetilde in parentheses.

The resulting commands \fixwidetilde{...} and \parwidetilde{...} gave the best results for my purposes. Note that parts (the first four lines) of the block below my first comment are necessary for the definition of the \parwidetilde{...} command. If \fixwidetilde{...} is not needed, one may without problems adjust the code by removing its definition from the code.

Below is a MWE:

\documentclass{article}

\usepackage{amsmath}
\usepackage{accents}
\usepackage{mathtools}


% A nicer \widetilde{...} with \fixwidetilde{...}
\DeclareMathSymbol{\widetildesym}{\mathord}{largesymbols}{"65}
    \newcommand\lowerwidetildesym{%
      \text{\smash{\raisebox{-1.3ex}{%
        $\widetildesym$}}}}
            \newcommand\fixwidetilde[1]{%
              \mathchoice
                {\accentset{\displaystyle\lowerwidetildesym}{#1}}
        {\accentset{\textstyle\lowerwidetildesym}{#1}}
        {\accentset{\scriptstyle\lowerwidetildesym}{#1}}
        {\accentset{\scriptscriptstyle\lowerwidetildesym}{#1}}
    }

% Overset the above tilde in brackets with \parwidetilde{...}
\newcommand\parwidetilde[1]{%
   \mathchoice
      {\accentset{\displaystyle\scalebox{.3}{(}\lowerwidetildesym\scalebox{.3}{)}}{#1}}
         {\accentset{\textstyle\scalebox{.3}{(}\lowerwidetildesym\scalebox{.3}{)}}{#1}}
         {\accentset{\scriptstyle\scalebox{.3}{(}\lowerwidetildesym\scalebox{.3}{)}}{#1}}
         {\accentset{\scriptscriptstyle\scalebox{.3}{(}\lowerwidetildesym\scalebox{.3}{)}}{#1}}
   }

\begin{document}
\begin{align}
    \fixwidetilde{A} + \parwidetilde{B} &= C \notag \\
    \fixwidetilde{ABC} + \parwidetilde{DEF} &= GHI
\end{align}
\end{document}

And here You can see the result: Widetilde in Parentheses

Marvin
  • 41
3

Even though the question is from four years ago, I add my answer keeping in mind that accents package vertically aligns the symbols more accurately. See the example.

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{accents}
\begin{document}
\[\accentset{\scriptscriptstyle{(\sim)}}{A}+\accentset{\scriptscriptstyle{(\sim)}}{B}=\accentset{\scriptscriptstyle{(\sim)}}{C}*\accentset{\scriptscriptstyle{(\sim)}}{D}\]
\end{document}

enter image description here

Sebastiano
  • 54,118