3

enter image description here

This \hbar is ugly with the bar too high and too left

enter image description here

This is what I want

My settings are:

\documentclass{beamer}
\usetheme{default}
\usecolortheme{seahorse}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{items}[ball]
\setbeamertemplate{footline}[frame number]
\setbeamertemplate{section in toc}[ball]
\setbeamerfont{section in toc}{series=\bfseries}
\renewcommand{\arraystretch}{1.25}

\usepackage[fontset=none]{ctex}
\setCJKsansfont{SimSun}[BoldFont=Noto Sans CJK SC Medium]
\usepackage{amsmath,amssymb,mathrsfs,bm}
\usepackage{tikz}
\usepackage{anyfontsize}
\usepackage{fontspec}
\usefonttheme[onlymath]{serif}
\usepackage{color}
\usepackage{graphicx,caption,subcaption}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=green,
    urlcolor=cyan,
    citecolor=cyan,
}

\AtBeginDocument{
  \let\uglyepsilon\epsilon
  \renewcommand\epsilon{\varepsilon}
}
\AtBeginDocument{
  \let\uglymathsf\mathsf
  \renewcommand\mathsf{\symsf}
}

\let\sectiononly\section
\renewcommand{\section}[1]{
    \sectiononly{#1}
    \let\sectiontitle\relax
    \newcommand{\sectiontitle}{#1}
}

\newenvironment{slide}{
    \begin{frame}{\bfseries{\sectiontitle}}
}{
    \end{frame}
}

what is next is: if I add:

\usepackage{unicode-math}
\unimathsetup{bold-style=ISO, mathrm=sym}
\setmathfont{Latin Modern Math}
\renewcommand{\bm}{\symbf}

to my settings, it will look like this:

enter image description here

1 Answer 1

3

unicode-math by default uses Latin Modern Math as the math mode font which is why the \hbar looks different. To access the original Computer Modern \hbar you can do something like this.

enter image description here

\documentclass{article}
\usepackage{mathtools, amssymb}
\let\oldhbar\hbar % Computer Modern hbar
\usepackage[warnings-off={mathtools-colon,mathtools-overbracket}]{unicode-math} % Math fonts
\setmathfont{Latin Modern Math}
\let\newhbar\hbar % Latin Modern hbar

\begin{document}
\def\hbar{\oldhbar\mkern1mu} % hbar kerning redefinition
\[\hbar\]
\end{document}

Hope this helps.

2
  • Thanks! So LMM and CM have different \hbar, but your code produces an h Commented Apr 5, 2022 at 1:41
  • Oh, sorry! I fixed the code now :) Commented Apr 5, 2022 at 1:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .