Tx · LaTeX & TikZ

How to Get a Correct \hbar with Antykwa Toruńska in LuaLaTeX

Published By the 9to5Science editorial team

At a glance

  1. 1. Separate text and math

    Load Antykwa Toruńska for text and use an OpenType math font for mathematical symbols.

  2. 2. Override the glyph

    Assign Unicode character U+210F to a math font with the h-bar shape you want.

  3. 3. Check the output

    Compile with LuaLaTeX and inspect h-bar alongside other math symbols.

Antykwa Toruńska can be used for document text while a separate OpenType math font supplies a well-shaped ℏ\hbar symbol. With LuaLaTeX, unicode-math lets you assign that one symbol to a different math font without changing the text font.

The exact appearance depends on the math font: fonts draw ℏ differently, and a font may not include the glyph you expect. The example below uses STIX Two Math for ℏ and Latin Modern Math for the remaining mathematical symbols.

Use a separate math-font glyph

The Unicode character for the reduced Planck constant is U+210F, ℏ. The unicode-math package maps \hbar to this character. Its range option lets you take that character from a different math font from the one used for the rest of the equation.

\documentclass{article}
\usepackage{fontspec}
\usepackage{unicode-math}

\setmainfont{Antykwa Toruńska}
\setmathfont{Latin Modern Math}
\setmathfont[range={"210F}]{STIX Two Math}

\begin{document}
The reduced Planck constant is $\hbar$.

For example, $E = \hbar\omega$.
\end{document}

Compile this with LuaLaTeX. The text uses Antykwa Toruńska, the general math font is Latin Modern Math, and only U+210F is taken from STIX Two Math. As a result, \hbar uses the STIX Two glyph, while symbols such as $\omega$ use Latin Modern Math.

If you prefer a different h-bar shape, replace STIX Two Math with another installed OpenType math font that has a suitable glyph. Keep range={"210F} to replace only ℏ. To use that font for all math instead, set it as the main math font and remove the range-specific line.

If the font name is not found

Font family names can differ between operating systems and installations. LuaLaTeX must be able to find the font under the name given to \setmainfont or \setmathfont. Install the font, update the system font cache if needed, and check the family name recognized by your font manager. If necessary, substitute the exact installed family name in the example.

Legacy Antykwa math versus OpenType math

The anttor package provides Antykwa Toruńska through traditional LaTeX font support. That is a different setup from selecting Unicode OpenType fonts with fontspec and unicode-math. The example uses Antykwa Toruńska for text, not its legacy math setup. It therefore gives you a Unicode math font for symbols and Greek letters, rather than preserving Antykwa’s original math design.

If you need Antykwa’s own math fonts throughout, first check whether your chosen Antykwa setup supports the math system you use. A Unicode glyph override with unicode-math applies to Unicode math fonts; it is not a drop-in fix for every traditional math-font configuration. Avoid loading unicode-math alongside packages that configure traditional math fonts unless their documentation explicitly says the combination is supported.

Common mistakes

  • Changing the text font and expecting math to follow. \setmainfont selects the text font; it does not choose the math font.
  • Changing the entire math font to fix one symbol. A range-specific override can replace just U+210F and leave the rest of the math layout alone.
  • Using \hslash as a substitute. It is a different slashed-h symbol, not necessarily the conventional h-bar glyph used for ℏ.
  • Compiling with pdfLaTeX. This example uses fontspec and unicode-math, so it requires LuaLaTeX or XeLaTeX; it will not compile with pdfLaTeX.
  • Assuming every font draws ℏ the same way. Try the glyph in the actual equation and select a math font whose design fits your document.

References

  1. The unicode-math package documentation
  2. The Antykwa Toruńska font package

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.