Open adunning opened 6 years ago
The problem is that the newest gloss-latin.ldf
from polyglossia makes the apostroph active and this clashes with unicode-math which has given an active apostroph a definition. You would get the same error in texlive 2017 if you changed the catcode of '
:
\documentclass{article}
\usepackage{unicode-math}
\begin{document}
\catcode`\'=13
'
\end{document}
That's the apostroph has such a definition is normal (it has it also in latex and plain). But polyglossia seems not to handle it correctly when unicode-math is loaded. It also not quite clear why polyglossia activates the latin shorthands unconditionally for an "other" language (and makes the apostroph already active in the preamble). As a work-around you should deactivate the shorthand:
\documentclass{article}
\usepackage{unicode-math}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{latin}
\begin{document}
\shorthandoff{'}
'
\end{document}
Doesn’t apostrophe ALWAYS have an active definition for handling primes in math mode?
\documentclass{article} \begin{document} \catcode`\'=\active \show' \end{document}
(Sorry, I haven’t looked into this yet besides this quick reply…)
in fontmath.ltx:
\mathcode`\'="8000 % ^\prime
2018-05-10 2:21 GMT+02:00 Will Robertson notifications@github.com:
Doesn’t apostrophe ALWAYS have an active definition for handling primes in math mode?
\documentclass{article} \begin{document} \catcode`\'=\active \show' \end{document}
(Sorry, I haven’t looked into this yet besides this quick reply…)
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/wspr/unicode-math/issues/462#issuecomment-387913624, or mute the thread https://github.com/notifications/unsubscribe-auth/AMS0P_5kmwfqa-m00U2UCnr78VbyRBrQks5tw4gWgaJpZM4T1gLs .
@wspr @hvoss49 Yes thanks I realized this too and already adjusted the comment. Imho one part of the problem is that unicode-math makes the definition at begin document and so one has a chicken-egg problem:
If unicode-math is behind \setmainlanguage{latin}
:
\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{latin}
\usepackage{unicode-math}
\begin{document}
\show' %definition of unicode-math
' %error as not in math
\end{document}
If I move unicode-math
up the text prime works but now I get a loop using the ' in math:
\documentclass{article}
\usepackage{polyglossia}
\usepackage{unicode-math}
\setmainlanguage{latin}
\begin{document}
$\show' f'$
\end{document}
leads to
'->\active@prefix '\normal@char'
\active@prefix #1->\ifx \protect \@typeset@protect \else \ifx \protect \@unexpa
ndable@protect \noexpand #1\else \protect #1\fi \expandafter \@gobble \fi
#1<-'
\normal@char' ->'
'->\active@prefix '\normal@char'
\active@prefix #1->\ifx \protect \@typeset@protect \else \ifx \protect \@unexpa
ndable@protect \noexpand #1\else \protect #1\fi \expandafter \@gobble \fi
#1<-'
\normal@char' ->'
Both problems can be easily triggered also with babel by moving unicode-math before or after the shorthand definition:
\documentclass{article}
\usepackage[english]{babel}
\usepackage{unicode-math}
\AtBeginDocument{
\useshorthands*{'}
\defineshorthand{'}{\relax\ifmmode \def\next{'}\else \def\next{blub}\fi \next}
}
\begin{document}
\show' '
$\show' f'$
\end{document}
or even with pdflatex by simply defining '
:
\documentclass{article}
\usepackage[english]{babel}
\useshorthands*{'}
\def'{\int} %fake unicode-math
\defineshorthand{'}{\relax\ifmmode \def\next{'}\else \def\next{blub}\fi \next}
\begin{document}
%\show' '
%$\show' f'$
\end{document}
So I would say it boils down to the question if there is a safe replacement for the \defineshorthand{'}-code of polyglossia or if one can only say "don't use the apostroph as shorthand".
@u-fischer the \def\next{'}
in that shorthand is just an infinite loop as while the intention is presumably to access the original math ' definition, that isn't what happens. So I would say it's the responsibility of the code making the shorthand definition to save the original version of the math ' and then use that version in math mode, something like, so a babel issue not unicode-math or polyglossia
\documentclass{article} \usepackage[english]{babel}
\usepackage{unicode-math}
{\catcode`\'=13 \AtBeginDocument{\let\mathapos'}}% must be before the shorthand \AtBeginDocument{ \useshorthands*{'} \defineshorthand{'}{\relax\show x\ifmmode \let\next\mathapos\else \def\next{blub}\fi \next} }
\begin{document} \show' ' $\show' f'$ \end{document}
@davidcarlisle I know that \def\next{'}
is responsable for the loop, but this is what polyglossia is doing in gloss-latin. I only shortened it a bit:
\declare@shorthand{latin}{'}{\relax
\ifmmode
\def\xpgla@nextsq{'}%
\else
\def\xpgla@nextsq{\futurelet\xpgla@temp@A\xpgla@putacute}%
\fi
\xpgla@nextsq}%
And as unicode-math defines ' at begin document your code only work as long unicode-math is loaded before the \AtBeginDocument{\let\mathapos'}
.
I do find such order dependencies not really satisfactory ;-(.
And as unicode-math defines ' at begin document
if I ruled the world unicode-math would do almost all of its definitions straight away and only delay font-specific code, so that a user can specify which fonts they want in the preamble.
@davidcarlisle — from memory the only reason I used AtBeginDocument is to avoid loading the maths font twice if the user isn't using the default font. That could be a premature optimisation, really — I'll experiment (at some point) with taking it out.
I just wanted to add the following example to the discussion: https://topanswers.xyz/tex?q=691
There also hyperref
is involved and changing the load order such that babel
isn't loaded first (even if it is before unicode-math
) doesn't throw an error in that example.
Code-copy from that link above:
\documentclass{scrartcl}
\usepackage[spanish, activeacute]{babel}
\usepackage{unicode-math}
\usepackage{hyperref}
\begin{document}
\section{A section}
\end{document}
Note that the polyglossia conflict has been (re-)fixed but there are still problems with unicode-math
's prime handling with polyglossia Latin as well as with babel languages with active prime (such as Catalan). See https://github.com/reutenauer/polyglossia/issues/394 for details.
See my comment there: https://github.com/reutenauer/polyglossia/issues/394#issuecomment-596490933
Description
Unicode-Math v0.8l conflicts with Polyglossia when both the English and Latin languages are enabled.
Check/indicate
Minimal example demonstrating the issue
Further details
This did not occur before TeX Live 2018.