10

After a recent update of MikTeX (and TeX Live!) on my computers (right after my vacation :)) I am not able to compile my book. The book is big and complex, uses many \if \else \fi constructions in the preamble, uses my own custom macros and environments some of which ceased to work properly. Here is one of the troubles identified so far.

The following minimal text is not compiled by XeTeX both in MkTeX and TeX Live.

\documentclass{article}

% Load fontspec and define a document font:
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}

% Load unicode-math and define a math font:
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}

\begin{document}

  \providecommand{\tensor}[1]{\overleftrightarrow{{\mathbf{#1}}}}%

  \begin{equation}
  \tensor{\pi}
  \end{equation}

\end{document}

Compilation aborts with 0 pages of output after issuing the message:

! Internal error: fad native font flag in `map_char_to_glyph'

I am absolutely sure that 3 months ago the above example would be succesfully compiled.

What's wrong now? Should I change the above definition of the \tensor macro?

Here is complete defintion of the \tensor macro in my own package.

%\makeatletter
\@ifpackageloraded{unicode-math}{%
  \providecommand{\tensor}[1]{\overleftrightarrow{{\mathbf{#1}}}}%
  \PackageInfo{handy}{\string\tensor\space has been declared using ^^J\space\space \string\overleftrightarrow\space from unicode-math package}%
}{%
  \@ifpackageloaded{accents}{%
    \providecommand{\tensor}[1]{\accentset{\leftrightarrow}{{\mathbf{#1}}}}%
    \PackageInfo{handy}{\string\tensor\space has been declared using ^^J\space\space \string\accentset\space from in accents package}%
  }{%
    \@ifpackageloaded{revsymb4-1}{%
      \PackageWarningNoLine{handy2}{\string\tensor\space has been taken from revsymb4-1 package.^^J You are recommended to load `accents' package before me}%
    }{
    \@ifpackageloaded{revsymb}{%
        \PackageWarningNoLine{handy2}{\string\tensor\space has been taken from revsymb package.^^J You are recommended to load `accents' package before me}%
      }{%
        \ifx\undefined\overset
        \else
          \providecommand{\tensor}[1]{\overset{\leftrightarrow}{\vec{#1}}}
          \PackageWarningNoLine{handy2}{\string\tensor\space has been declared using ^^J\space\space \string\overset\space from amsmath package.^^J You are recommended to load `accents' package before me}%
        \fi
      }%
    }%
  }%
}%
%\makeatother

It uses 4 alternatives depending on what package is loaded. The most preferable alternative goes first and it assumes that unicode-math package is available.

11

There have been some changes in unicode-math, for fixing some issues in multiletter identifiers using \mathXY commands.

Now, a single bold math symbol should be built with \symbf rather than \mathbf, which is reserved for multiletter things.

\documentclass{article}

% Load fontspec and define a document font:
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}

% Load unicode-math and define a math font:
\usepackage{unicode-math}
\setmathfont{TeX Gyre Pagella Math}

\newcommand{\tensor}[1]{\overleftrightarrow{\symbf{#1}}}

\begin{document}

\begin{equation}
\tensor{\pi}
\end{equation}

\end{document}

enter image description here

For older document, you can reinstate the old meaning with a package option:

\documentclass{article}

% Load fontspec and define a document font:
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}

% Load unicode-math and define a math font:
\usepackage[mathbf=sym]{unicode-math}
\setmathfont{TeX Gyre Pagella Math}

\newcommand{\tensor}[1]{\overleftrightarrow{\mathbf{#1}}}

\begin{document}

\begin{equation}
\tensor{\pi}
\end{equation}

\end{document}

but it's better to switch to the new commands as soon as possible.

  • 1
    So, if someone wants to redefine \vec macro should he or she write \renewcommand{\vec}[1]{\symbf{#1} in XeTeX but \renewcommand{\vec}[1]{\mathbf{#1}} in LaTeX? – Igor Kotelnikov Aug 28 '15 at 14:46
  • @IgorKotelnikov I'm afraid so; maybe an alias for \symbf=\mathbf could be introduced. The fact is that \mathbf{fi} wouldn't have a ligature, with the old setup in unicode-math. – egreg Aug 28 '15 at 17:15
  • This is as crazy as the recent atan2 argument switch in pgf.... Sigh. Back comparability should be (more) sacred. Well... – Rmano Sep 3 '15 at 21:46
  • @Rmano That was exactly the problem: \mathbf was not backward compatible. And \mathit behaved in a very silly way. – egreg Sep 3 '15 at 21:49
  • @Rmano A choice had to be made, because \mathbf (and similar) was not backward compatible and rendered incorrectly multiletter identifiers. A good rule is never using \mathbf directly in a document, but hide it in a macro: \newcommand{\vector}[1]{\mathbf{#1}. If you had this, upgrading to the new unicode-math setup would just need changing one \mathbf into \symbf. But I'm often using \mathbf in the document myself ;-)( in shorter ones). – egreg Sep 3 '15 at 21:54

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.