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

xelatex + unicode-math breaks over/underbrackets #29

Open
andrewheiss opened this issue Sep 16, 2021 · 5 comments
Open

xelatex + unicode-math breaks over/underbrackets #29

andrewheiss opened this issue Sep 16, 2021 · 5 comments

Comments

@andrewheiss
Copy link

andrewheiss commented Sep 16, 2021

When using mathools v1.25 (2021/03/18) with xelatex (TeX Live 2021) and unicode-math, underbrackets and overbrackets fail to render correctly if thickness/height arguments are provided:

\documentclass{article}
\usepackage{mathtools}
\usepackage{unicode-math}
\begin{document}

Default options:

$$
\underbracket{A}_{\text{Some text}} = \overbracket{\pi r^2}^{\text{More text}}
$$

Custom options:

$$
\underbracket[0.25pt][1pt]{A}_{\text{Some text}} = \overbracket[1pt][3pt]{\pi r^2}^{\text{More text}}
$$

\end{document}

image

Everything works fine if unicode-math is omitted:

\documentclass{article}
\usepackage{mathtools}
\begin{document}

Default options:

$$
\underbracket{A}_{\text{Some text}} = \overbracket{\pi r^2}^{\text{More text}}
$$

Custom options:

$$
\underbracket[0.25pt][1pt]{A}_{\text{Some text}} = \overbracket[1pt][3pt]{\pi r^2}^{\text{More text}}
$$

\end{document}

image

It seems like unicode-math might be providing its own underbracket and overbracket that are overriding mathtools' brackets?

@zauguin
Copy link
Member

zauguin commented Sep 16, 2021

It seems like unicode-math might be providing its own underbracket and overbracket that are overriding mathtools' brackets?

It's not unicode-math itself, but the font. Unicode math fonts contain instructions for drawing e.g. underbrackets/overbrackets and many similar things, so they don't have to be emulated with TeX code. unicode-math uses these. I would assume that this is by design.

@andrewheiss
Copy link
Author

andrewheiss commented Sep 16, 2021

According to this, there might be a way to redefine over/underbracket macros so there's compatibility (since unicode-math does have its own argument-free over/underbracket) latex3/unicode-math#544 - and once upon a time it seems to have worked by preserving and redefining mathtools' brackets: latex3/unicode-math@872775e

@andrewheiss
Copy link
Author

In the meantime, here's a solution that works (via this)! Store mathtools' brackets as separate commands, then restore them after \begin{document}. They have to be restored after the document begins because unicode-math apparently executes its Unicode table after the document starts—including \let\underbracket=\normalunderbracket in the preamble thus doesn't work

\documentclass{article}
\usepackage{mathtools}
% Save mathtools' brackets
\let\normalunderbracket=\underbracket
\let\normaloverbracket=\overbracket

\usepackage{unicode-math}

\begin{document}

% Restore mathtools' brackets *after* \begin{document}
\let\underbracket=\normalunderbracket
\let\overbracket=\normaloverbracket

Default options:

$$
\underbracket[0.25pt][1pt]{A}_{\text{Some text}} = \overbracket[1pt][3pt]{\pi r^2}^{\text{More text}}
$$

Custom options:

$$
\underbracket[0.25pt][10pt]{A}_{\text{Some text}} = \overbracket[1pt][8pt]{\pi r^2}^{\text{More text}}
$$

\end{document}

image

@zepinglee
Copy link

mathtools also breaks over/underbrace of unicode-math (see https://tex.stackexchange.com/q/521394/82731). I suggest checking if unicode-math is loaded.

\@ifpackageloaded{unicode-math}{
  \let\underbrace\LaTeXunderbrace
  \let\overbrace\LaTeXoverbrace
}{}

@daleif
Copy link
Collaborator

daleif commented Feb 21, 2022

@zepinglee doesn't unicode-math fix that by it self? The problem with the linked example is that mathtools is loaded after unicode-math which is not recommended.

andrewheiss added a commit to andrewheiss/corrupt-caterpillar that referenced this issue Dec 16, 2023
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

4 participants