I sometimes find that the \widetilde accents sits too high above the math letter it is applied to. An example:

To me it looks as if the first tilde is sitting just in between the two lines; it is not visually attached to the "B". As the second "B tilde" shows, I did manage to produce a version where the \widetilde is lowered, but this is an ugly hack using \textcolor:


What I'm doing here: I lower the whole \widetilde{B}, then I erase the "B" by some (manually adjusted) white box, and finally I typeset the "B" that is seen in the output. Of course I have this wrapped in some macro, but this macro does not work for small letters such as "m", which is due to the white box.

The more straightforward attempt


does not work as the output shows: the tilde in is too far to the left. The reason for this is that TeX handles accents over single characters differently, using the \skewchar of the font, and \phantom{B} is not a single character. Moreover, in the version \tilde B I find the tilde too small: .

One of the problems of my solution is that it doesn't render properly when I view the dvi file in Yap. Does anyone know a better solution to lower the \widetilde?


TH's first solution works rather well. It has the only drawback that it does not lower the \widetilde over small letters such as "m". However, this is not a big deal since in this case the tilde does not look as if it is sitting in between two lines. I came up with an answer that does lower the \widetilde over "m", but that has other major problems. TH's (rather involved) second solution fixes most of these problems. Great work!

  • You may wish to read eutypon.gr/eutypon/pdf/e2000-05/e05-a04.pdf (however I couldn't find the package on CTAN). It has very useful information on accents and the parameters to manipulate them.
    – yannisl
    Commented Oct 9, 2010 at 14:35
  • @Yiannis: I think this won't help since it is about accents in text mode, which are quite different from accents in math mode. Commented Oct 9, 2010 at 15:02
  • fyi, I tracked the accentbx files down and put them up on github here: github.com/zellyn/accentbx
    – zellyn
    Commented Dec 21, 2011 at 20:31
  • @zellyn Thanks for tracking it down and posting it on github.
    – yannisl
    Commented Jan 8, 2012 at 16:53

2 Answers 2


Implementation 1
This code changes the x-height of the accent font for its argument. It should be fairly robust. Rather than scaling the height by 1.3, one could simply add a fixed value to it. Because of the way TeX computes accent heights, there is some minimum height of an accent and so this tends to have no discernible effect on lowercase letters.



Implementation 2
This attempts to duplicate Rule 12 and the relevant portions of Rules 16–18 in Appendix G of The TeXbook for typesetting math accents.

Some notes on the implementation: I don't know how to compute successors, so instead I replace box y which should just be the accent and the italic correction with $\widetilde{\hphantom{...}}$. As a result, the tilde should already be shifted by half(w+width(y)). From tex.web, the shift amount of box y is given by
thus it suffices to compute the kerning s and shift right by that amount.

The code below contains 3 main parts.

  1. The first thing it does is tries to parse the argument to \wt which will appear as the nucleus of the Acc atom. This is extremely brittle. If the argument expands to any primitives other than \relax, \bgroup, \egroup, \begingroup, \endgroup, \fam, (control space), \char (not tested), \mathchar (not tested), \mathcode (not tested), a letter, or a symbol, it will treat the nucleus as not a single character even if it really is. If there is an unknown control sequence, for example \let\unknown\foo, it will fail with a mysterious error because it cannot expand \unknown. Some effort is put into checking for changes of fonts.

    If the \wt@checknucleus macro decides that the nucleus of the Acc atom we're about to fake is just a single character, it stores the \mathcode and notes the fact by setting \ifwt@nucleussingle to \iftrue. (I suppose the third part of the code could just check the saved math code instead.)

    • After \wt@checknucleus is complete, it scans ahead looking for _ and ^. If these are hidden in macros, it won't find them! Any subscripts and superscripts are saved for later processing in either Rule 12 or Rule 18.

    • Finally, \wt@choice uses \mathchoice to typeset the formula in each of the 4 styles which is done by \wt@applyrules and then pick the appropriate one. \wt@applyrules contains the relevant rules from The TeXbook as comments followed by some code that attempts to apply the rules.

The code is not perfect. See the output from my test at the bottom of this answer. Also, it loses crampedness because pdfTeX provides no way to test for it. It does perform the appropriate cramping where Rule 12 calls for it.





        \else\ifx#1            \else\ifx#1\wt@sentinel
                \wt@nucleussingletrue % Not really true...
        % In principle, this could handle every primitive.








        % The following block comments are quotes from Knuth's The
        % TeXbook. My notes appear [in brackets].
        % Rule 12:
        % If the current item is an Acc atom (from \mathaccent) [this
        % is what we're constructing], just go to Rule 16 if the
        % accent character doesn't exist in the current size [ignoring
        % this]. Otherwise set box x to the nucleus in style C', and
        % set u to the width of this box.
        % [We don't need u.]
        % If the nucleus is not a single character, let s = 0;
        % otherwise set s to the kern amount for the nucleus followed
        % by the \skewchar of its font
                        \wt@s\z@ % s
                        \advance\wt@s-\wd\tw@ % s
        % If the accent character has a successor in its font whose
        % width is <= u, change it to the successor and repeat this
        % sentence.
        % [I don't know how to do this, so I'm ignoring it.]
        % Now set delta <- min(h(x), chi), where chi is \fontdimen5
        % (the x-height in the accent font).
        \wt@delta\fontdimen5\accentfont % x-height in accent font
        \ifdim\wt@delta>\ht\z@ \wt@delta\ht\z@ \fi % delta
        \advance\wt@delta\p@ % Increase delta by 1pt
        % If the nucleus is a single character, replace box x by a box
        % containing the nucleus together with the superscript and
        % subscript of the Acc atom, in style C, and make the
        % sub/superscript of the Acc atom empty; also increase delta
        % by the difference between the new and old values of h(x).
        % [Note that we lose crampedness here since one cannot check
        % for it with pdfTeX.]
                        \ifwt@sup^{\the\wt@sup}\fi $}%
        % Put the accent into a new box y, including the italic
        % correction.
        % [\setbox\tw@\hbox{\accentfont\char"65\/} would work except
        % that I didn't find the larger accents above. Instead, use
        % \widetilde and \hphantom.]
        \setbox\tw@\hbox{$\m@th#1\widetilde{\hphantom{\the\wt@nucleus}}$}% box y
        % Let z be a vbox consisting of: boy y moved right s +
        % (1/2)(u-w(y)), kern -delta, and box x.
                % [Since we aren't setting the accent ourself, we only
                % need to move right by s since the \widetilde will
                % take care of the rest.
                % \moveright\dimexpr\dimen@+.5\wd\[email protected]\wd\tw@\relax\box\tw@]
        }% box z
        % If h(z) < h(x), add a kern of h(x) - h(z) above box y and
        % set h(z) <- h(x).
        % Finally set w(z) <- w(x),
        % replace the nucleus of the Acc atom by box z, and continue
        % with Rule 16.
        % Rule 16:
        % Change the current item to an Ord atom, and continue with
        % Rule 17.
        % Rule 17:
        % If the nucleus of the current item is a math list [it
        % isn't]...
        % Then if the nucleus is not simply a symbol [it isn't], go on
        % to Rule 18. ...
        % Rule 18:
        % (The remaining task for the current atom is to attach a
        % possible subscript and superscript.) If both the subscript
        % and superscript fields are empty, move to the next item.
        % Otherwise continue with the following subrules.
        % [Let's let TeX deal with subscripts and superscripts here.]

This requires the mathtools package for \cramped and etoolbox for \ifdefmacro.

This is my current test. Note that \mathrm doesn't work properly for some reason.




$\tw A\tw B\tw I\tw W\tw m\tw w$

$\twt A\twt B\twt I\twt W\twt m\twt w$
  • @TH: Both your solutions look very interesting, so +1 for now. Before I accept the answer, I'll have to understand (even) better what you're doing. What I understood so far: Both your solutions have a similar (very good) effect. However, they do not lower the tilde over small letters such as "m", and I think this is due to the minimum of h(x) and \chi in rule 12. Nevertheless, it's already very helpful for my needs. Thanks for your help! Commented Oct 3, 2010 at 20:24
  • @Hendrik Vogt: Yes, I think you're right regarding h(x) and χ.
    – TH.
    Commented Oct 3, 2010 at 20:28
  • @TH: Looking closer I see that your second solution is no good: Just try it with "W" instead of "B"; there the tilde is much too far to the right. Using the italic correction here is not the right idea (and it is not in the spririt of rule 12). Still the method with the \currentfont is very interesting. Commented Oct 3, 2010 at 20:46
  • @Hendrik Vogt: I'm not sure I agree with your assessment of not being in the spirit of rule 12. It does say, "Put the accent into a new box y, including the italic correction." Unless Knuth means the italic correction of the accent itself, it's doing something with the italic correction of the nucleus.
    – TH.
    Commented Oct 3, 2010 at 20:54
  • @Hendrik Vogt: I just reread the paragraphs that proceed the list of rules and I think that the italic correction might actually be for the accent.
    – TH.
    Commented Oct 3, 2010 at 21:11

With the help of TH's various suggestions I came up with the following alternative answer that fixes my first attempt with \phantom. It contains the definition of a macro \wt that takes one optional argument (the lowering amount, defaults to 0.1ex) and one mandatory argument.





\Huge $\triple A\triple B\triple I\triple W\triple m\triple w$

(The amsmath package is only needed to make \widetilde work properly with \Huge and subscripts. What I find interesting about this solution is that it illustrates the role of the \skewchar in rule 12 of Appendix G in the TeXbook.)

The macro \wt should only be used for setting a tilde over a single "usual math letter". To be more precise, \wt{m} works, \wt{WA} works but doesn't position the tilde correctly, and the versions \wt{\gamma}, \wt{B_1} and \wt{\mathcal{M}} don't work at all. (Of course it would be possible to construct a macro that decides to use my solution in the case of a single "usual math letter", and TH's solution otherwise.)

  • How do you get the same for \gamma, for instance. What I have to modify in the code? Commented Nov 19, 2023 at 17:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .