2

I'm using LuaLaTeX 1.13.2 from TeX Live 2021, unicode-math 2020-01-31 v0.8q, and hyperref 2021-06-07 v7.00m.

Let's start with

\documentclass{article}
\usepackage[paperwidth=2in, paperheight=1.5in, textwidth=1.5in, textheight=1in]{geometry}
\usepackage{unicode-math}
\pagestyle{empty}
\begin{document}
\begin{equation}
-1
\end{equation}
\begin{equation}
{}-1
\end{equation}
\end{document}

This typesets to the document below; the difference in spacing between the two equations is intended:

Changing the include line to \usepackage{unicode-math,hyperref} messes up the spacing of the unary minus. This affects only the first unary symbol in display math, not if the unary appears in parentheses or inline math:

But changing it to \usepackage{hyperref,unicode-math} inserts additional vertical space between the equations. This is usually not an issue because there should be text between the two equations, but it is still strange:

It seems to be a unicode-math problem because neither issue appears when the package list is a permutation of fontspec and hyperref. The conclusions are unchanged if XeLaTeX is used instead. Are there fixes, and is there a canonical order to include these packages?

1
  • 1
    the problem is not unicode-math but amsmath (loaded by unicode-math). And there is not much one can do, load hyperref after unicode math and hide the number with {-1}. Aug 16 at 16:38
2

You can redefine \incr@eqnum as below. Ulrike and I are considering in chat if this would be safe fix for amsmath to do generally

\documentclass{article}
\usepackage{amsmath,hyperref}

\makeatletter
\def\incr@eqnum{\ifmmode\mathopen\fi{\refstepcounter{equation}}\let\incr@eqnum\@empty}
\makeatother

\pagestyle{empty}
\begin{document}


\begin{equation}
-1
\end{equation}
\begin{equation}
{}-1
\end{equation}
\end{document}
3
  • that breaks labels as \@currentlabel is now set inside the mathopen group ;-( Aug 22 at 11:50
  • @UlrikeFischer \refstepcounter{equation}\ifmmode\mathopen{}\fi ? Aug 22 at 12:51
  • that could work. I will run the tests again (I tried to change it in amsmath ;-)) Aug 22 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.