alerque / libertinus

The Libertinus font family
Other
927 stars 57 forks source link

broken underbrace/overbrace when mathtools is used after libertinus #507

Closed tpapp closed 2 years ago

tpapp commented 2 years ago

(I reported this issue originally at latex3/mathtools#43, and was told that this isn't a bug with mathtools.)

MWE:

\documentclass[a4paper]{article}
\usepackage{libertinus}         % using mathtools BEFORE works fine
\usepackage{fontspec}
\setmathfont{Latin Modern Math}
\usepackage{mathtools}
\begin{document}
\begin{equation}
  \underbrace{g_u \lambda_u \Gamma_u}_{\text{example}} = 
    \underbrace{\int g_e(\varphi) \delta(\varphi) d\varphi}_{\text{example}}
\end{equation}
\end{document}

results in mathtools

using TeXLive 2021.20220204-1 in Ubuntu 22.04. Exchanging the order of libertinus and mathtools fixes the issue.

khaledhosny commented 2 years ago

It is not a font bug either. The issue you are linking to is saying it is a document bug so you have to fix your document. Furthermore, this repository maintains only the OpenType fonts, the LaTeX package you are using is maintained elsewhere.

hvoss49 commented 2 years ago

The problem is amsmath, which should be loaded always before unicode-math. In your case it is loaded by mathtools, so it overrides some math definitions of unicode-math, which is loaded by libertinus-otf. Use:

\documentclass[a4paper]{article}
\usepackage{mathtools}
\usepackage{libertinus}   
\setmathfont{Latin Modern Math}

\begin{document}
\begin{equation}
  \underbrace{g_u \lambda_u \Gamma_u}_{\text{example}} = 
    \underbrace{\int g_e(\varphi) \delta(\varphi) d\varphi}_{\text{example}}
\end{equation}
\end{document}