So I want to denote the Dirac operator with a hat, and I tried both \hat{\slashed{D}} and \slashed{\hat{D}}: the first one has the $^$ rather distant to the $\slashed{D}$, while the second one has the slash much too to the left of the $D$, almost coincide the semi-vertical stroke of the letter $D$.

Is there any way to adjust the position of the hat or slash?


Just overlap the symbol with the hat with the slashed version of itself.


enter image description here

You can use \phantom in the following way to prevent double striking the glyph, but AFAIK \phantom doesn't detect cramped style and shifts the hat to the right.

  • Was working a stack, but I like your answer better (+1). I note that you double-strike the D. Interestingly, in an effort to avoid that, I found that using \phantom{#1} on either the \hat or the \slashed elements also caused distortion. Thus, the overstrike proved the only reliable method. Mar 18 '14 at 19:48
  • @StevenB.Segletes Thank you for your appreciation! I will ask in chat about that strange interference. I'm still interested in your stackengine solution, please post it. My upvote is yours :-) Mar 18 '14 at 19:51
  • Better recheck that phantom... Mar 18 '14 at 20:11
  • @StevenB.Segletes Hm. Why does \phantom shift the slash? Does \phantom change back to horizontal mode, instead of staying in math mode? Mar 18 '14 at 20:18
  • This \newcommand\hatslashedB[1]{{\,\hat{\phantom{\!#1}}\mathllap{\slashed{#1}}}} is closer to the overstriked solution, note the \! and \,. By the way, the phantom is shifting the \hat, I think, not the slash. Mar 18 '14 at 20:20

Without character overlapping:


  \expandafter\ifx\csname psla@\string#1\endcsname\relax
    \csname psla@\string#1\endcsname
  \expandafter\def\csname psla@\string#5\endcsname{%




I define a command \pslashed that mimicks \slashed, but over a phantom.

Why doesn't \hat{\phantom{D}} give a good result? Because \hat cannot get the font metric information about the character D, because it's over a box containing nothing. So we set the accented character (in \mathrlap) and then set the slash as if it were across a D.

enter image description here

  • Thanks for clarifying the mystery. I may have more questions... Mar 19 '14 at 1:54
  • Your solution was very much tailored to the particular problem at hand. Maybe a question is a better forum than a comment, but is it possible to generalize \phantom to somehow contain vestigial font metric information of what was phantomed? In a related question, is there such a thing as what I will call \leavetrace{D}, which prints nothing, but makes whatever follows next in the input stream think a D had just preceded it? Mar 19 '14 at 2:15
  • 1
    @StevenB.Segletes That's a very tough question: several operation in math mode are performed differently when the nucleus of a atom is a character or something else (a box, a skip, …). When you have a box rather than a character, the metric information has been lost: there is no “mathbox”, only \hbox and \vbox (\vtop, \vcenter).
    – egreg
    Mar 19 '14 at 9:51

This turned out a lot more interesting as an exercise, than I anticipated. In the first row of my answer, I give the basic elements we are working with, the D, the hatted D, and the slashed D.

Then, on the second line, I confirm the OP's observations that creating composite glyphs \hat{\slashed{D}} and \slashed{\hat D} cause distortions in the result. That's not too surprising, I guess.

So I figured this was tailor-made for a stack, wherein I could superimpose two of the basic elements atop each other to achieve the result. I first confirmed that the basic elements were all the same width, not augmented laterally in some way by the decoration. Of course, I wanted to avoid, if possible, double-striking the letter D, so I used a \phantom of D in one of the two elements of the stack. And I found, very surprisingly to myself, that the phantom distorted the results, as well.

About this time, Henri posted his solution, far superior to my own approach, since it naturally scales with mathstyle (whereas I would have to add the apparatus of scalerel on top of my solution to achieve that). I abandoned my solution, voted for Henri, and left him a comment of my \phantom observation. But then he asked for the stackengine result, so I continue.

The third line of my result shows those phantom results, with the hat being shifted left in the first, and the stroke being shifted left in the second. I figured it might have something to do with letter-specific kerns, lost with the phantom.

So, on the fourth line, I just lived with the double-striked D, same as Henri. But, this approach does not, in its current form, scale with the mathstyle.

Basic Elements: $D \hat D \slashed D $

Derived Elements:$\hat{\slashed{D}} \slashed{\hat D}$ (ugh!)

Stacked Phantoms: $\stackslashA{\hat}{D} \stackslashB{\hat}{D}$ (slight shifts)

Stacked Element: $\stackslash{\hat}{D}$ (double-stroked D)

enter image description here

  • You can use \phantom inside the accent, here \hat, but not inside \slashed. Maybe you want to include this to prevent double striking. Mar 18 '14 at 20:03
  • @HenriMenke I'm sorry, but \documentclass{article} \usepackage{slashed, mathtools} \begin{document} \newcommand\hatslashedA[1]{{\hat{\phantom{#1}}\mathllap{\slashed{#1}}}} \newcommand\hatslashed[1]{{\hat{#1}\mathllap{\slashed{#1}}}} $\hatslashedA{D} \hatslashed{D}$ \end{document} does not produce identical results. Mar 18 '14 at 20:09
  • @HenriMenke As a follow up, the phantom version is horizontally off by (approximately) a \! Mar 18 '14 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.