[Tex/LaTex] \hbar not displayed with fontspec on XeLaTeX/LuaLaTeX

fontspecluatexxetex

With \usepackage{fontspec}, \hbar does not show up correctly. Tested on LaTeX2e <2018-04-01> patch level 5 and fontspec.sty 2018/07/30 vv2.6h.

\documentclass{article}
\usepackage{fontspec}
\begin{document}
[$\hbar$]
\end{document}

With LuaLaTeX:
hbar-lualatex

With XeLaTeX:

hbar-xelatex

I found that

  • Adding \usepackage{unicode-math}

or

  • \usepackage[no-math]{fontspec}

can resolve this problem, but I'm not sure which is better.

Best Answer

The definition of hbar is quite encoding dependant. As fontspec changes the operator font it breaks.

You could redefine it if you don't want to switch to unicode-math:

\documentclass{article}
\usepackage{fontspec}

\begin{document}\pagestyle{empty}

\def\hbar{{\mathchar175\mkern-9muh}}
[$\hbar$]

\def\hbar{\mathit{^^^^0127}}

[$\hbar$]

\end{document}

enter image description here

Related Question