diff --git a/relalg.sty b/relalg.sty index 8941b1a..ec2c2f5 100644 --- a/relalg.sty +++ b/relalg.sty @@ -1,6 +1,6 @@ -\def\packagedate{13 December 2024} -\def\packageversion{2.0} -\def\packageshortdate{2024/12/13} +\def\packagedate{15 Jamuary 2025} +\def\packageversion{2.1} +\def\packageshortdate{2025/01/15} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Defines various relational algebra symbols. @@ -10,6 +10,8 @@ % Version History % v1.0 Initial version. % v2.0 Complete rewrite to support Unicode OpenType fonts and LaTeX3. +% v2.1 Plays nicely with other packages that \setmathfont, and only +% interpolates join symbols if they aren’t in the current font. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -24,32 +26,38 @@ \ExplSyntaxOn - \bool_new:N \__unicode_engine + \bool_new:N \g__ra_unicode_engine \ifLuaTeX \PackageInfo{relalg}{LuaTeX\space engine\space detected} - \bool_set_true:N \__unicode_engine + \bool_set_true:N \g__ra_unicode_engine \fi \ifXeTeX \PackageInfo{relalg}{XeTeX\space engine\space detected} - \bool_set_true:N \__unicode_engine + \bool_set_true:N \g__ra_unicode_engine \fi - \bool_if:NTF \__unicode_engine { + \bool_if:NTF \g__ra_unicode_engine { \RequirePackage[no-math]{fontspec} \RequirePackage{unicode-math} - \setmathfont{latinmodern-math.otf} + % Stolen from unicode-math.sty as the fallback in unicode-math doesn't + % seem to work? Weirdly it seems to work in a bare-bones MWE. + \bool_if:NF \g__um_main_font_defined_bool \__um_load_lm: % The various join symbols aren't covered very well by many maths fonts - % (including Latin Modern Math, annoyingly), so let's Frankenstein them - % in from fonts that do have them. We need to hack the scale to get roughly - % proportional looking sizes. + % (including Latin Modern Math, annoyingly), so if necessary let's + % Frankenstein them in from fonts that do have them. We need to hack + % the scale to get roughly proportional looking sizes. + % \iffontchar trick from % Outer joins (left, right, full): - \setmathfont{STIXTwoMath-Regular.otf}[range={"027D5-"027D7}, Scale=0.875] + \iffontchar\font "27D5\relax\else\setmathfont{STIXTwoMath-Regular.otf}[range="027D5, Scale=0.875] + \iffontchar\font "27D6\relax\else\setmathfont{STIXTwoMath-Regular.otf}[range="27D6, Scale=0.875] + \iffontchar\font "27D7\relax\else\setmathfont{STIXTwoMath-Regular.otf}[range="27D7, Scale=0.875] + % \setmathfont{STIXTwoMath-Regular.otf}[range={"027D5-"027D7}, Scale=0.875] % Inner join: (1.143 = 1 / 0.875) - \setmathfont{KpMath-Light.otf}[range={"02A1D}, Scale=1.143] + \iffontchar\font "2A1D\relax\else\setmathfont{KpMath-Light.otf}[range="2A1D, Scale=1.143] }{ \PackageInfo{relalg}{non-Unicode\space engine\space detected} \RequirePackage{latexsym} % for \Join @@ -177,7 +185,7 @@ % Outer join operators. \ExplSyntaxOn - \bool_if:NTF \__unicode_engine { + \bool_if:NTF \g__ra_unicode_engine { \NewDocumentCommand{\RelLeftOuterJoin}{}{\ensuremath{\ifXeTeX\mkern2.5mu\fi\mathbin{\leftouterjoin}}} \NewDocumentCommand{\RelRightOuterJoin}{}{\ensuremath{\ifXeTeX\mkern2.5mu\fi\mathbin{\rightouterjoin}}} \NewDocumentCommand{\RelFullOuterJoin}{}{\ensuremath{\ifXeTeX\mkern2.5mu\fi\mathbin{\fullouterjoin}}} @@ -187,10 +195,10 @@ % Weirdly the height of \Join is fractionally shorter than \bowtie, so % we can't use the more sensible solution of measuring off the line % height. Use only font-relative units to ensure proper scaling. - \def\__ojoin{\rule[0.11ex]{0.25em}{0.1ex}\llap{\rule[1.41ex]{0.25em}{0.1ex}}} - \NewDocumentCommand{\RelLeftOuterJoin}{}{\ensuremath{\mathbin{\__ojoin\mkern-6.4mu\Join}}} - \NewDocumentCommand{\RelRightOuterJoin}{}{\ensuremath{\mathbin{\Join\mkern-6.4mu\__ojoin}}} - \NewDocumentCommand{\RelFullOuterJoin}{}{\ensuremath{\mathbin{\__ojoin\mkern-6.4mu\Join\mkern-6.4mu\__ojoin}}} + \def\__ra_outer_join{\rule[0.11ex]{0.25em}{0.1ex}\llap{\rule[1.41ex]{0.25em}{0.1ex}}} + \NewDocumentCommand{\RelLeftOuterJoin}{}{\ensuremath{\mathbin{\__ra_outer_join\mkern-6.4mu\Join}}} + \NewDocumentCommand{\RelRightOuterJoin}{}{\ensuremath{\mathbin{\Join\mkern-6.4mu\__ra_outer_join}}} + \NewDocumentCommand{\RelFullOuterJoin}{}{\ensuremath{\mathbin{\__ra_outer_join\mkern-6.4mu\Join\mkern-6.4mu\__ra_outer_join}}} } \ExplSyntaxOff