# What's the most elegant way to obtain Dirac operators? (slash notation)

What's the best way to achieve the Dirac slash notation for Dirac operators (contraction with Gamma matrices)? I would have thought the AMSmath packages would have this built in somewhere.

(The cancel package springs to mind, but surely there is an easier method?)

• Good question! And one I've struggled with over many years. I'm currently using the slashed package as mas suggests. Commented Aug 25, 2011 at 16:56
• I found this way to write the Feynman's d-slash ${\partial\!\!\!\big /}$ on MSE from Wikipedia page for the Dirac Equation: Commented Jun 8, 2022 at 22:24

Does

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{slashed}
\begin{document}
$\slashed{p}$
\end{document}


give what you want?

• Yes, it does - thanks. I was wondering if I had overlooked a built-in way of doing it, in AMSmath or otherwise, without the need for an additional package.
– Dan
Commented Aug 25, 2011 at 16:10
• @Dan -- thanks for the comment. Welcome to TeX.SX: hope you'll enjoy coming here!
– mas
Commented Aug 25, 2011 at 17:15
• While this is convenient, Werner's solution actually looks much nicer. The slashed package seems to use a different vertical position depending on the letter height, so if you have \slashed{a}\slashed{b} it looks a bit off. Commented Apr 1, 2015 at 13:59

In addition to mas's answer, you could define your own using an overlap (in mathmode) of the \not operator:

\documentclass[12pt]{article}
\usepackage{mathtools}% http://ctan.org/pkg/mathtools
\newcommand{\fsl}[1]{\ensuremath{\mathrlap{\!\not{\phantom{#1}}}#1}}% \fsl{<symbol>}
\begin{document}
\noindent $\not{a}\not{b}=4(a\cdot b)$

\noindent $\fsl{a}\fsl{b}=4(a\cdot b)$
\end{document}


​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

Of course this works best for single-symbol/letter slashing. I think this is more commonly referred to as Feynman slash notation.

• I never knew it was down to Feynman - thanks!
– Dan
Commented Aug 25, 2011 at 16:08
• I tried something like this myself and the problem with it is that how it ends up looking, depends on the width of the character it's applied to. Try this with P or A and you'll see. Commented Apr 1, 2017 at 4:03
• @GeoffPointer: You could consider using centernot or cancel.
– Werner
Commented Apr 1, 2017 at 4:08
• Then, all you need is \newcommand{\fsl}[1]{{\centernot{#1}}}. Commented Apr 1, 2017 at 5:28

Small tip to enter the Dirac slash:

k\!\!\!/ = \gamma^\mu k_\mu

• This solution is not very well thought out. The use of \! is very arbitrary. This might look good on the letter k, but it won't on other letters and it cannot be generalised. Commented Apr 1, 2017 at 7:20
• I have no idea why this is downvoted, it works quite well when you are unable to use a package that does it for you. Commented Dec 3, 2017 at 0:45
• I agree that this solution is very inelegant and works kind of accidentally, but it's a great way to get the slash notation in markdown-like web-inputs (e.g. issues, comments, commit messages) that do not allow to load latex packages. Commented Jul 5, 2022 at 13:14

Quite often using Latex there is not a simple solution, so one gets used to having one's own macro file, to accumulate personal solutions, which I recommend if you keep finding yourself wanting to change things.

For this problem, \newcommand{\fsl}[1]{{\centernot{#1}}} is serving me very well. You must include \usepackage{centernot} after your \documentclass for it to work. Or put it at the top of your macro file, once and for all, (or \RequirePackage{centernot} if you've converted your macro file to a package). Even the slashed package requires a \usepackage{slashed} every time you use it.

I've included some output below. The top row is with my simple solution and the bottom row uses the slashed package. It shows that my simple solution is not perfect, just compare my theta slash with the one below it, but then have a look at the phi slash below mine. It just looks like a messy phi and the i slash below is not so flash either. So there is no perfect solution and at least in mine, all the slashes are uniform, which I prefer.

Notice the difference in spacing as well. I prefer it compact for products, but that's a question of taste I guess.

Please note that I've used double brackets around my definition, so the inner brackets become part of what is produced. I do this with most things that are essentially a single symbol, or unit, so they can be sub- or super-scripted without brackets in my source file.

A solution using \ooalign that yields slightly better spacing than Werner's (especially with the very narrow and the very wide characters) is

\renewcommand{\fsl}[1]{{\ooalign{$$#1$$\cr\hidewidth$$/$$\hidewidth\cr}}}


This still looks rather ugly on some capital letters and the slash on the f is almost invisible, but that is maybe just a weakness of the notation. (One could of course add checks to adjust the spacing depending on the character that is to be slashed.)

For an introduction to \ooalign, see this answer.