2

This answer provides the following code for lowering the \widetilde accent:

\makeatletter
\newcommand*\wt[1]{\mathpalette\wthelper{#1}}
\newcommand*\wthelper[2]{%
        \hbox{\dimen@\accentfontxheight#1%
                \accentfontxheight#11.3\dimen@
                $\m@th#1\widetilde{#2}$%
                \accentfontxheight#1\dimen@
        }%
}

\newcommand*\accentfontxheight[1]{% \fontdimen5\ifx#1\displaystyle \textfont \else\ifx#1\textstyle \textfont \else\ifx#1\scriptstyle \scriptfont \else \scriptscriptfont \fi\fi\fi3 } \makeatother

Can someone explain how this code works? In particular, I would like to know:

  1. The answer says that the code scales the "x-height" of the accent by 1.3. What exactly is the x-height of an accent? I am familiar with the notion of the x-height of a font, but I can't see why scaling the x-height would lower the accent.
  2. What do the various commands (e.g., \mathpalette, \dimen@, \fontdimen, \m@th) in the above code do? What is the command \accentfontxheight supposed to do?
  3. Why doesn't the code have any effect on lowercase letters? The answer provides an explanation, but I don't understand why it works for uppercase letters but not lowercase letters.
  4. Is there a way to modify the code so that it lowers the accent on lowercase letters?
Vincent
  • 20,157
Frank
  • 121
  • 3

1 Answers1

2
  1. The "x-height" of a font is how large 1ex is in that font. TeX utilizes this to set the space between a box and an accent in math. There is a little more to it than this, but an accent is placed on top of the box and the space between them is decreased by min(1ex, h) where 1ex is relative to the accent font and h is the height of the box (decreased because the accent character is right above the height of an uppercase letter about).
    So if you do \widetilde{W} for example, since the height of W is more than 1ex you get something like
    \vbox{
        \hbox{<horizontally skewed widetilde accent>}
        \kern-1ex
        \hbox{W}
    }
    

So if you increase 1ex, you will decrease the space between the accent and the character.

    • \fontdimen is a TeX primitive which loads certain dimension registers of a font. Its usage is \fontdimen<number><font>, and in this case \fontdimen5<font> gives the size of 1ex in <font>. In this case the font we want is \textfont3 or \scriptfont3 etc depending on the context, since these are defined to be the accent fonts. This is the purpose of the \accentfontxheight macro, if you give it the context (\displaystyle, \textstyle, etc --- the current math style) it gives you the \fontdimen3 in that context.
    • \dimen@ is a shorthand for \dimen0, the 0th dimen register in TeX. It's used here as a temporary register to store the original value of \fontdimen so it can be reset after \wt. Doing \dimen@<dimen> sets \dimen0 to <dimen>, and <dimen register>\dimen@ sets <dimen register> to the value stored in \dimen0.
    • \mathpalette\<macro>{<param>} calls
      \<macro>\displaystyle{<param>}, or
      \<macro>\textstyle{<param>}, etc depending on the context, this allows you to create a macro \<macro> which does different things depending on the current math style.
    • \m@th is a shorthand for \mathsurround=0pt. TeX adds kerns of length \mathsurround around math-on and math-off items.
  1. The reason then this has no effect on lowercase letters is because h<=1ex in this case, so min(h, 1ex)=h, and so increasing 1ex doesn't affect this minimum.

  2. One way you could do this is by checking if the box being accented has height <1ex and if so, put what's being accented into a higher box (raise the material being accented), accent it, then lower it back down so that it's at its original height. This is just one idea, it's probably not the best.

All information regarding this can be found in the TeXbook. Appendix G contains the information on how TeX generates boxes from formulas, step 12 on page 443 has the relevant information on math accents.

Slurp
  • 876