# LaTeX superscripts problem with widetilde

I tried to put a superscript (squared) with a \xi variable in the \widetilde :

$\widetilde{\xi}^2 = (\widetilde{\xi})^2 \neq \widetilde{\xi^2}$

gives

Which seems to be se same things, whereas it is absolutly not ! So, I'm looking for some way to put my squared in \widetilde{\xi}^2 slightly higher than my \widetilde.

This problem doesn't occur with a "small variable" like an x :

$\widetilde{x}^2 = (\widetilde{x})^2 \neq \widetilde{^2}$

gives

which places correctly and readably my squared without any doubt.

Any ideas ?

• \tilde{\xi}^{2} – egreg Oct 5 '16 at 17:36
• Perhaps you are looking for an output like the one provided by \widetilde{\xi\mkern 0mu}^{2}. The issue, here, is a very low-level feature of TeX that is documented in The TeXbook, Appendix G, Rule 12. – GuM Oct 5 '16 at 18:13

## 3 Answers

After all, this might indeed be the answer you are looking for. The reciprocal placement of a math accent and of a superscript (and/or subscript) is subject, when the “accentee” consists of a single character, to an exceptional treatment which is detailed in Rule 12 of Appendix G of The TeXbook (p. 443), and that can be informally described as the super-/sub-script being “fastened” directly to the character being accented. To inhibit application of this exception, it suffices to add, under the accent, “something” that takes up no space, for example \mkern 0mu.

Here is a MWE:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\newcommand*{\ShowLists}{%
%   \begingroup
%       \showboxbreadth = 1000
%       \showboxdepth = 10
%       \tracingonline = 1
%       \showlists
%   \endgroup
}

\begin{document}

Test:
$$\widetilde{\xi}^{2}+\widetilde{\xi\mkern 0mu}^{2}\ShowLists$$.
\ShowLists
Other test:
$$\tilde{\xi}^{2}+\tilde{\xi\mkern 0mu}^{2}\ShowLists$$.\ShowLists

\end{document}

And this is the output it produces:

If you uncomment the body of the definition of the \ShowLists command, some tracing information will be shown during compilation, that explains exactly what is going on.

# Addition

It turned out that the OP wasn’t quite satisfied with the above solution: the exponent gets raised too much. Then we propose a completely different method, which puts the superscript at the same vertical position that an exponent affixed to a parenthesis would be placed at. Note, however, that this causes the superscript to clash with the tilde, so a little amount of space needs to be added on its left. Note also that the braces around \mathstrut are not superfluous! (This is because \mathstrut does not produce an atom by itself, but “something else” that is not capable of carrying super-/sub-scripts.)

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\begin{document}

A completely different approach:
$$\widetilde{\xi}^{2} \neq \widetilde{\xi}{\mathstrut}^{\>2}$$.

\end{document}

The output in this second case is:

• Is it possible to slightly drop also the squared ? I was looking for the equivalent function \mkern but vertically. To put the upper point of '2' at the same level as the \tilde ? – Anthony T. Oct 5 '16 at 20:16
• @AnthonyT.: Please see edit. – GuM Oct 5 '16 at 21:37

Your problems stem from the fact you want to use \widetilde instead of \tilde, which is more appropriate both over \xi and x.

$\tilde{\xi}^{2}$\qquad
$\tilde{\xi}^{\,2}$\qquad
$\widetilde{\xi}^{2}$\qquad
$\widetilde{\xi}^{\,2}$\qquad
$\widetilde{\xi}{\mathstrut}^{\,2}$

$\tilde{x}^{2}$\qquad
$\tilde{x}^{\,2}$\qquad
$\widetilde{x}^{2}$\qquad
$\widetilde{x}^{\,2}$\qquad
$\widetilde{x}{\mathstrut}^{2}$

(I added no preamble and no end because this runs the same in plain TeX as in LaTeX.)

There is no way to mistake \tilde{\xi}^{2} for “xi squared with tilde applied to it” rather than “xi tilde squared”. Perhaps this is the case where a thin space \, can be used (not for x).

As you will notice, the wide tilde extends a bit outside of its bounding box, but in any case the smaller variant for it is too wide for a single lowercase letter; perhaps it can be used for uppercase letters.

Keep it small.

Here I offer a substitute macro \reallywidetilde, based on, but different from my answer at Big tilde in math mode.

\documentclass{article}
\usepackage{scalerel}
\usepackage{stackengine,wasysym}

\newcommand\reallywidetilde[1]{\ThisStyle{%
\setbox0=\hbox{$\SavedStyle#1\mathstrut$}%
\stackengine{.40\LMpt}{$\SavedStyle#1$}{%
\stretchto{\scaleto{\SavedStyle\mkern.2mu\ACC}{.5150\wd0}}{.3\ht0}%
}{O}{c}{F}{T}{S}%
}}
\def\ACC{\ooalign{\AC\cr\kern.25\LMpt\AC}}
\parskip 1ex
\begin{document}
widetilde

$\widetilde{\xi}^2 = (\widetilde{\xi})^2 \neq \widetilde{\xi^2}$

$\widetilde{x}^2 = (\widetilde{x})^2 \neq \widetilde{x^2}$

reallywidetilde

$\reallywidetilde{\xi}^2 = (\reallywidetilde{\xi})^2 \neq \reallywidetilde{\xi^2}$

$\reallywidetilde{x}^2 = (\reallywidetilde{x})^2 \neq \reallywidetilde{x^2}$
\end{document}

• Thank you, but when I tried, I had a problem with scalerel.sty ! Undefined control sequence. \\Isnextbyte ...elax \relax \relax \ifdefstrequal {\SR@Letter@A }{\SR@Letter...` – Anthony T. Oct 5 '16 at 18:57
• @AnthonyT. Without knowing more, I am going to guess that your etoolbox.sty is quite out of date. My version is 2015/08/02 v2.2a. The macro \ifdefstrequal was introduced to that package with version 2.1 on 2011-01-03. – Steven B. Segletes Oct 5 '16 at 19:10
• Yes ! It was exactly that's what was missing. Thanks. – Anthony T. Oct 5 '16 at 19:32