# How to use Feynman Slash notation?

How can I use Feynman slash notation, e.g., $\require{cancel} \cancel{A}$, in Mathematica? I've seen some answer from 2008 which doesn't seem to work well in Mathematica 10. I'd like this to be part of the text and not a graphic such that I can use it as part of the text in a legend.

Here is a palette that does the slashing when you select a character and press the button:

CreatePalette[{Button["Slash it!",
NotebookWrite[InputNotebook[],
Replace[FromCharacterCode[
Join[ToCharacterCode[
FromCharacterCode[{8706, 824}] :>
OverlayBox[{"\<\[PartialD]\>", "\</\>"}]]]]}];


It uses the unicode character for a combining solidus (824). This adds the slash to whatever character is printed in front of it.

Edit

Because operators such as $\partial$ don't allow combining marks in Mathematica, I had to add special treatment for $\partial$ in the form of an OverlayBox. All I do is look for the result of the unicode combination to contain the sequence of characters corresponding to $\partial$ and the combining solidus, then replace that particular combination by an overlay. Using an Overlay in all cases may also be workable, but I thought it's better to rely on the alignment provided by the built-in Unicode functionality.

Edit 2

While the above palette yields (I think) a cleverer representation of most slashed characters based on the Unicode standard, it doesn't seem to work on all platforms (it does work on Mac). Therefore, here is a simpler version that uses only OverlayBoxes:

CreatePalette[{Button["Slash it!",
NotebookWrite[InputNotebook[],

• I tried this on \[PartialD] — e.g. as in the Dirac equation — and the slash is placed after the derivative operator rather than through it. – Stephen Luttrell Aug 5 '15 at 20:21
• @MarcoB You did it exactly the way I intended. That's got to be a system-specific issue. It works for on Mac OS X, with Mathematica 10.1. You're saying it doesn't work with the $\partial$ character, either? – Jens Aug 5 '15 at 22:26