# d with a little line through the top of it

In math mode one can do $\hbar$, which produces an h with a little line through the top of it. I want to do the same thing, except with the letter d instead. Is there a generalization of $\hbar$ that works for other letters besides just h?

• \dj{} with \usepackage[T1]{fontenc} Sep 28, 2014 at 0:16
• the 'fontenc' package doesn't seem to work with the 'amsart' document class Sep 28, 2014 at 0:29
• No! No problem. They work very well. Sep 28, 2014 at 0:32
• I was using it in math mode, hum Sep 28, 2014 at 0:41
• @Sigur and Rohan. \dj{} is a text-mode symbol. In math it would be $\text{\dj}$. You should load the package lmodern as well in order to get that symbol unpixeld. Oct 1, 2014 at 6:24

You can create a specific command \dbar for this purpose.

\newcommand{\dbar}{d\hspace*{-0.08em}\bar{}\hspace*{0.1em}}


## Full Code

\documentclass{article}
\newcommand{\dbar}{d\hspace*{-0.08em}\bar{}\hspace*{0.1em}}
\begin{document}
$\hbar$, $\dbar$.
\end{document}


produces

• A more convenient command could be \mathchar '26 \mkern-11mu d. This is the same idea used in \hbar. Sep 28, 2014 at 0:44
• @Sigur I think better with -12mu. Sep 28, 2014 at 0:52
• @skpblack, I was talking about the char and kern. OK. Sep 28, 2014 at 0:54
• Also, in general, kerns are better than \hspaces for things like this, because \hspace has stretchable glue in it, whereas a \kern or \mkern does not. Sep 28, 2014 at 1:17
• @StevenB.Segletes I'm afraid that both you and skpblack are wrong: \hspace{...} becomes stretchable only if the argument contains stretch components, so \hspace{2pt} will never stretch. The \hspace* variant has nothing to do with stretching or shrinking per se, because it obeys the same rules as the normal command. The main difference between a skip (\hspace) and a kern is that the latter isn't considered a line break point. Oct 1, 2014 at 6:34

There is code in the Comprehensive List of Symbols, but it's wrong: what's suggested is

\newcommand{\dbar}{{\mathchar'26\mkern-12mu d}}


but one needs to compensate the amount of backup, which is larger than the width of the bar by 3mu:

\documentclass{article}

\newcommand{\dbar}{{\mkern3mu\mathchar'26\mkern-12mu d}}

\begin{document}

$32\lambda^2 \dbar_w$

$32\lambda^2 d_w$

$32\lambda^2 \hat{d}_w$

\end{document}


The fact that the width is 9mu is confirmed by the definition of \hbar in Plain TeX:

\hbar:
macro:->{\mathchar '26\mkern -9muh}


Of course, different math fonts may need different amounts of spacing.

A possibly better definition is

\newcommand{\dbar}{{d\mkern-7mu\mathchar'26\mkern-2mu}}


so that the bar doesn't protrude as much on the right:

\documentclass{article}

\newcommand{\dbar}{{d\mkern-7mu\mathchar'26\mkern-2mu}}

\begin{document}

$d\dbar d$

$h\hbar h$

\end{document}


For PDFLaTeX:

As recommended by Sigur. You should load the package lmodern as well as the output will be pixeled with out it.

% arara: pdflatex

\documentclass{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\begin{document}
in text \dj{} and math $\textit{\dj}$
\end{document}


For Lua- or XeLaTeX:

The output is the same as above. You can use the unicode U+0111 or copy paste that symbol directly into your code.

% arara: lualatex

\documentclass{article}
\usepackage{fontspec}

\begin{document}
in text \symbol{"0111}  and math $\textit{\symbol{"0111}}$
\end{document}


The package unicode-math does not contain this symbol yet. It just contains the unicode U+00F0 with the command $\matheth$ which could be an alternative.

You can find fonts that support that symbol on your system by clicking here. Here are some font examples. Choose one and write your macro like \newcommand*{\dbar}{{\fontspec{font_of_your_choice}\symbol{"0111}}}.

% arara: lualatex

\documentclass{article}
\usepackage{fontspec}
\usepackage{booktabs}

\begin{document}
\begin{tabular}{ll}\toprule
Font & Example\\\midrule
Latin Modern & \symbol{"0111}\\
Code2000 & \setmainfont{Code2000.ttf}\symbol{"0111}\\
Comic Sans MS & \setmainfont{comic.ttf}\symbol{"0111}\\
Consolas & \setmainfont{consola.ttf}\symbol{"0111}\\
DejaVu Sans & \setmainfont{DejaVuSans.ttf}\symbol{"0111}\\
EB Garamond & \setmainfont{EB Garamond}\symbol{"0111}\\
Linux Libertine &\setmainfont{Linux Libertine O}\symbol{"0111}\\
Quivira &\setmainfont{quivira.otf}\symbol{"0111}\\
XITS &\setmainfont{xits-regular.otf}\symbol{"0111}\\
\bottomrule
\end{tabular}
\end{document}


• using \textit in math mode feels rather wrong to me. And if it is left out the first example gives LaTeX Warning: Command \dj invalid in math mode on input line 8. Jul 1, 2015 at 8:01
• @clemens Yes of course this was a tweak. The command \dj is a textcommand. and therefore I used \textit here. Jul 1, 2015 at 8:05