2

I noticed that the \bar and \overbar as defined in unicode-math do not yield a centered bar over the letters.

For example for

\documentclass{article}

\usepackage{amsmath,unicode-math}
\unimathsetup{math-style=ISO,bold-style=ISO,sans-style=italic}
\setmathfont{texgyrepagella-math.otf}
%\setmathfont[range={scr,bfscr}]{texgyredejavu-math.otf}

\begin{document}
    \begin{align}
    \bar{\mscrw} \overbar{\mscrw}
    \end{align}
\end{document}

I get:

enter image description here

Is there anything I can do about it?

P.S.: I am using texlive 2018 with lualatex.

egreg
  • 1,121,712
bonanza
  • 2,141
  • 2
  • 26
  • 37

3 Answers3

4

with \overline{\mscrw} instead of \bar

enter image description here

  • Thanks! I also thought about this, but https://tex.stackexchange.com/questions/98028/bar-vs-overline-when-to-use-what-semantically seems to discourage \overline for some reasons. I would have naively expected that a font used via unicode-math with it's own accents should be fine. Is that a bug in unicode math and/or the font ? – bonanza Jan 30 '19 at 10:05
  • 4
    @bonanza I would say it is a bug in the font. Other accents are misplaced too, it fails also with xelatex, but other fonts work. With lualatex you could patch the top_accent value, but it would be better to report this to the font maintainers. – Ulrike Fischer Jan 30 '19 at 10:27
  • @UlrikeFischer, thanks, I could not find any reliable source of how to get in contact with the font maintainers. Do you know how to reach them? – bonanza Jan 30 '19 at 10:31
  • 1
    @bonanza There is a slightly hidden mail address in the contact info on http://www.gust.org.pl/projects/e-foundry/tex-gyre/ – Ulrike Fischer Jan 30 '19 at 10:36
1

Using \widebar from the macro (slightly amended) at this page Can I get a \widebar without using the mathabx package?

enter image description here

\documentclass{article}
\usepackage{amsmath,unicode-math}
\unimathsetup{math-style=ISO,bold-style=ISO,sans-style=italic}
\setmathfont{texgyrepagella-math.otf}
%\setmathfont[range={scr,bfscr}]{texgyredejavu-math.otf}

\makeatletter
\newcommand*\rel@kern[1]{\kern#1\dimexpr\macc@kerna}
\newcommand*\widebar[1]{%
  \begingroup
  \def\mathaccent##1##2{%
    \rel@kern{0.8}%
    \overline{\rel@kern{-0.8}\macc@nucleus\rel@kern{-0.1}}%
    \rel@kern{-0.3}%
  }%
  \macc@depth\@ne
  \let\math@bgroup\@empty \let\math@egroup\macc@set@skewchar
  \mathsurround\z@ \frozen@everymath{\mathgroup\macc@group\relax}%
  \macc@set@skewchar\relax
  \let\mathaccentV\macc@nested@a
  \macc@nested@a\relax111{#1}%
  \endgroup
}
\makeatother
\begin{document}
$\widebar{\mscrw}$
\end{document}
Sebastiano
  • 54,118
1

It seems like a font bug.

If you use \bar{{}\mscrw} the output is as expected.

\documentclass{article}

\usepackage{amsmath,unicode-math}

\unimathsetup{math-style=ISO,bold-style=ISO,sans-style=italic}

\setmathfont{texgyrepagella-math.otf}

\begin{document}

\begin{gather}
\bar{\mathscr{a}} \overbar{\mathscr{a}} \wideoverbar{\mathscr{a}} \\
\bar{\mathscr{b}} \overbar{\mathscr{b}} \wideoverbar{\mathscr{b}} \\
\bar{\mathscr{d}} \overbar{\mathscr{d}} \wideoverbar{\mathscr{d}} \\
\bar{\mathscr{g}} \overbar{\mathscr{g}} \wideoverbar{\mathscr{g}} \\
\bar{\mathscr{u}} \overbar{\mathscr{u}} \wideoverbar{\mathscr{u}} \\
\bar{\mathscr{w}} \overbar{\mathscr{w}} \wideoverbar{\mathscr{w}} \\
\bar{{}\mscrw} \overbar{{}\mscrw} \wideoverbar{{}\mscrw}
\end{gather}

\end{document}

enter image description here

It's possible to fix \bar (and other accents in the same way):

\documentclass{article}

\usepackage{amsmath,unicode-math}

\unimathsetup{math-style=ISO,bold-style=ISO,sans-style=italic}

\setmathfont{texgyrepagella-math.otf}

\ExplSyntaxOn
\cs_set_protected:Nn \bonanza_bar_new:n
 {
  \str_case:nnTF { #1 } 
   {
    {\mathscr{w}}{}
    {\mscrw}{}
   }
   { \bonanza_bar_original:n { {}#1 } }
   { \bonanza_bar_original:n { #1 } }
 }
\AtBeginDocument
 {
  \cs_set_eq:NN \bonanza_bar_original:n \bar
  \cs_set_eq:NN \bar \bonanza_bar_new:n
 }
\ExplSyntaxOff

\begin{document}

\[
\bar{\mathscr{a}}+
\bar{\mathscr{b}}+
\bar{\mathscr{d}}+
\bar{\mathscr{g}}+
\bar{\mathscr{u}}+
\bar{\mathscr{w}}+
\bar{\mscrw}
\]

\end{document}

enter image description here

egreg
  • 1,121,712