Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

symbol \hbar from amsmath is not working #223

Open
AvalasJT opened this issue Jun 30, 2021 · 4 comments
Open

symbol \hbar from amsmath is not working #223

AvalasJT opened this issue Jun 30, 2021 · 4 comments

Comments

@AvalasJT
Copy link

Hi everyone,

I've got a strange error when I use "\hbar" in my equations. While compiling I get the error message
"Undefined control sequence. [..] \hbar"

amsmath, amsfonts and amssymb are all included as far as I can tell.

The same equations are working with "\hslash" instead of "\hbar" but it looks slightly different.

Although I get the "undefined control sequence"-error I can't define a new command \hbar:
"\newcommand{\hbar} {\mathchar'26\mkern-7.5mu h}"
results in an error:
"Command \hbar already defined. ...ommand{\hbar} {\mathchar'26\mkern-7.5mu h}"

Does anyone know how to solve that issu or had simmilar problems?
Thanks and cheers,
Jonas

@GR8DAN
Copy link

GR8DAN commented Jul 9, 2021

Seems the error does not occur with XeLaTeX, though the \hbar looks like \hslash.

Alternatively, if you comment out \pdfglyphtounicode{hbar}{0127} at line 2086 in the file glyphtounicode.tex the error does not appear, but \hbar again looks like \hslash.

Why \hbar looks like \hslash has been pointed out before, with both being assigned to U+210F instead of \hbar being set to something like U+0127, which is empty in some fonts, or the almost identical U+045B.

Looks like another package is be redefining \hbar. If you use \show\hbar the log file displays hbar=\protected macro: ->\hslash, even though amssymb has \hbar and \hslash as being different.

@AvalasJT
Copy link
Author

Dear GR8DAN,

thanks for your answer! Actually I already tried to comment out line 2086 in the glyphtounicode.tex file but that didn't change anything for me. I will check again, if I changed by accident the file in my template folder instead of my thesis folder or something like that.

But as that also doesn't change the appearance of \hbar here is a workaround I found in the meantime which seems to be working for me:
In the main tex file you can use \renewcommand{\hbar}{\mathchar'26\mkern-9mu h} to get the \hbar back again. The command has to be placed within the \begin{document} block.

Best wishes,
Jonas

@GR8DAN
Copy link

GR8DAN commented Jul 11, 2021

Thanks
Your suggestion (\renewcommand{\hbar}{\mathchar'26\mkern-9mu h}) did't work in my LaTeX environment (Overleaf), though \def\hbar{\mathit{^^^^0127}} did (from https://tex.stackexchange.com/questions/448490/hbar-not-displayed-with-fontspec-on-xelatex-lualatex).

@linas
Copy link

linas commented Jan 20, 2024

FWIW, I'm seeing a variant of this from within LyX. Haven't tracked down the details. Same document worked great 3-4 years ago; I just tried to reexport to PDF and boom, it fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants