TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using XeLaTeX with the packages fontspec,xunicode,xlxtra (which I believe is pretty standard) to process my documents into a PDF file with the TeX Gyre Pagella font.

I have been doing so successfully for quite some time, but when using the standard LaTeX symbol \hbar, upon processing an error is thrown

LaTeX Warning: Command \hbar invalid in math mode on input line 86

and the symbol appears instead as a regular "h" which partially overlaps with the previous character.

Here is a minimal code example:

\setmainfont{TeX Gyre Pagella}
hbar by itself:  $\hbar$\\
hbar with a preceeding character:   $o\hbar$
share|improve this question
Can you give a minimal example of code? – egreg Jan 23 '12 at 15:17
Minimal code added; thanks for the reminder. – William Kennerly Jan 23 '12 at 15:23
up vote 2 down vote accepted

It seems to be a bug with xunicode.

Mixing Computer Modern Math with Pagella (Palatino) is not a good choice (but this is not related to the problem).

\usepackage{mathpazo} % get Palatino math  
\usepackage{fontspec} % xunicode is not needed, nor xltxtra
\defaultfontfeatures{Ligatures=TeX} % syntax compatible with LuaLaTeX
\setmainfont{TeX Gyre Pagella}

% Magic formula for make \hbar not throwing a spurious message
% However, \hbar won't work in text mode, which should not be a problem
\expandafter\let\expandafter\hbar\csname ?-\string\hbar\endcsname
% End of magic code

hbar by itself:  $\hbar$\\
hbar with a preceeding character:   $o\hbar$
share|improve this answer
Thanks! It turns out that you do need the Palatino math font in order to get the \hbar to work. (Commenting out \usepackage{mathpazo} breaks that \hbar) – William Kennerly Jan 23 '12 at 17:26
@WilliamKennerly You have to call fontspec with the option no-math, I believe, if mathpazo is not loaded. – egreg Jan 23 '12 at 17:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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