%% %% This is file `unicode-math.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% unicode-math.dtx (with options: `preamble') %% unicode-math.dtx (with options: `msg') %% unicode-math.dtx (with options: `load') %% Copyright 2006-2011 Will Robertson %% Copyright 2010-2011 Philipp Stephani %% %% This package is free software and may be redistributed and/or modified under %% the conditions of the LaTeX Project Public License, version 1.3c or higher %% (your choice): . %% %% This work is "author-maintained" by Will Robertson. \ProvidesPackage{unicode-math} [2011/09/19 v0.6a Unicode maths in XeLaTeX and LuaLaTeX] \usepackage{ifxetex,ifluatex} \ifxetex\else\ifluatex\else \PackageError{unicode-math}{% Cannot be run with pdfLaTeX!\MessageBreak Use XeLaTeX or LuaLaTeX instead.% }\@ehd \fi\fi \RequirePackage{expl3}[2011/07/01] \RequirePackage{xparse}[2009/08/31] \RequirePackage{l3keys2e} \RequirePackage{fontspec}[2010/10/25] \RequirePackage{catchfile} \RequirePackage{fix-cm} % avoid some warnings \RequirePackage{filehook}[2011/01/03] \ExplSyntaxOn \cs_generate_variant:Nn \tl_put_right:Nn {cx} \cs_generate_variant:Nn \seq_if_in:NnTF {NV} \cs_generate_variant:Nn \prop_gput:Nnn {Nxn} \cs_generate_variant:Nn \prop_get:NnN {cxN} \cs_generate_variant:Nn \prop_if_in:NnTF {cx} \cs_new:Npn \exp_args:NNcc #1#2#3#4 { \exp_after:wN #1 \exp_after:wN #2 \cs:w #3 \exp_after:wN \cs_end: \cs:w #4 \cs_end: } \cs_set_eq:NN \tl_replace_in:Nnn \tl_replace_once:Nnn \cs_new_protected_nopar:Npn \bool_const:Nn #1 #2 { \bool_new:N #1 \bool_set:Nn #1 { #2 } } \bool_new:N \l_um_ot_math_bool \bool_new:N \l_um_init_bool \bool_new:N \l_um_implicit_alph_bool \bool_new:N \g_um_mainfont_already_set_bool \bool_new:N \g_um_literal_bool \bool_new:N \g_um_upLatin_bool \bool_new:N \g_um_uplatin_bool \bool_new:N \g_um_upGreek_bool \bool_new:N \g_um_upgreek_bool \bool_new:N \g_um_bfliteral_bool \bool_new:N \g_um_bfupLatin_bool \bool_new:N \g_um_bfuplatin_bool \bool_new:N \g_um_bfupGreek_bool \bool_new:N \g_um_bfupgreek_bool \bool_new:N \g_um_upsans_bool \bool_new:N \g_um_sfliteral_bool \bool_new:N \g_um_upNabla_bool \bool_new:N \g_um_uppartial_bool \bool_new:N \g_um_literal_Nabla_bool \bool_new:N \g_um_literal_partial_bool \bool_new:N \g_um_texgreek_bool \bool_set_true:N \g_um_texgreek_bool \bool_new:N \l_um_smallfrac_bool \bool_new:N \g_um_literal_colon_bool \int_new:N \g_um_fam_int \tl_const:Nn \c_um_math_alphabet_name_latin_tl {Latin,~lowercase} \tl_const:Nn \c_um_math_alphabet_name_Latin_tl {Latin,~uppercase} \tl_const:Nn \c_um_math_alphabet_name_greek_tl {Greek,~lowercase} \tl_const:Nn \c_um_math_alphabet_name_Greek_tl {Greek,~uppercase} \tl_const:Nn \c_um_math_alphabet_name_num_tl {Numerals} \tl_const:Nn \c_um_math_alphabet_name_misc_tl {Misc.} \prg_new_conditional:Nnn \um_glyph_if_exist:n {p,TF,T,F} { \iffontchar \l_um_font #1 \scan_stop: \prg_return_true: \else: \prg_return_false: \fi: } \cs_generate_variant:Nn \um_glyph_if_exist_p:n {c} \cs_generate_variant:Nn \um_glyph_if_exist:nTF {c} \cs_generate_variant:Nn \um_glyph_if_exist:nT {c} \cs_generate_variant:Nn \um_glyph_if_exist:nF {c} \cs_generate_variant:Nn \fontspec_set_family:Nnn {Nx} \cs_generate_variant:Nn \fontspec_set_fontface:NNnn {NNx} \DeclareDocumentCommand \unimathsetup {m} { \keys_set:nn {unicode-math} {#1} } \keys_define:nn {unicode-math} { normal-style .choice_code:n = { \bool_set_false:N \g_um_literal_bool \ifcase \l_keys_choice_int \bool_set_false:N \g_um_upGreek_bool \bool_set_false:N \g_um_upgreek_bool \bool_set_false:N \g_um_upLatin_bool \bool_set_false:N \g_um_uplatin_bool \or \bool_set_true:N \g_um_upGreek_bool \bool_set_false:N \g_um_upgreek_bool \bool_set_false:N \g_um_upLatin_bool \bool_set_false:N \g_um_uplatin_bool \or \bool_set_true:N \g_um_upGreek_bool \bool_set_true:N \g_um_upgreek_bool \bool_set_true:N \g_um_upLatin_bool \bool_set_false:N \g_um_uplatin_bool \or \bool_set_true:N \g_um_upGreek_bool \bool_set_true:N \g_um_upgreek_bool \bool_set_true:N \g_um_upLatin_bool \bool_set_true:N \g_um_uplatin_bool \or \bool_set_true:N \g_um_literal_bool \fi } , normal-style .generate_choices:n = {ISO,TeX,french,upright,literal} , } \keys_define:nn {unicode-math} { math-style .choice_code:n = { \ifcase \l_keys_choice_int \unimathsetup { normal-style=ISO, bold-style=ISO, sans-style=italic, nabla=upright, partial=italic, } \or \unimathsetup { normal-style=TeX, bold-style=TeX, sans-style=upright, nabla=upright, partial=italic, } \or \unimathsetup { normal-style=french, bold-style=upright, sans-style=upright, nabla=upright, partial=upright, } \or \unimathsetup { normal-style=upright, bold-style=upright, sans-style=upright, nabla=upright, partial=upright, } \or \unimathsetup { normal-style=literal, bold-style=literal, sans-style=literal, colon=literal, nabla=literal, partial=literal, } \fi } , math-style .generate_choices:n = {ISO,TeX,french,upright,literal} , } \keys_define:nn {unicode-math} { bold-style .choice_code:n = { \bool_set_false:N \g_um_bfliteral_bool \ifcase \l_keys_choice_int \bool_set_false:N \g_um_bfupGreek_bool \bool_set_false:N \g_um_bfupgreek_bool \bool_set_false:N \g_um_bfupLatin_bool \bool_set_false:N \g_um_bfuplatin_bool \or \bool_set_true:N \g_um_bfupGreek_bool \bool_set_false:N \g_um_bfupgreek_bool \bool_set_true:N \g_um_bfupLatin_bool \bool_set_true:N \g_um_bfuplatin_bool \or \bool_set_true:N \g_um_bfupGreek_bool \bool_set_true:N \g_um_bfupgreek_bool \bool_set_true:N \g_um_bfupLatin_bool \bool_set_true:N \g_um_bfuplatin_bool \or \bool_set_true:N \g_um_bfliteral_bool \fi } , bold-style .generate_choices:n = {ISO,TeX,upright,literal} , } \keys_define:nn {unicode-math} { sans-style .choice_code:n = { \ifcase \l_keys_choice_int \bool_set_false:N \g_um_upsans_bool \or \bool_set_true:N \g_um_upsans_bool \or \bool_set_true:N \g_um_sfliteral_bool \fi } , sans-style .generate_choices:n = {italic,upright,literal} , } \keys_define:nn {unicode-math} { nabla .choice_code:n = { \bool_set_false:N \g_um_literal_Nabla_bool \ifcase \l_keys_choice_int \bool_set_true:N \g_um_upNabla_bool \or \bool_set_false:N \g_um_upNabla_bool \or \bool_set_true:N \g_um_literal_Nabla_bool \fi } , nabla .generate_choices:n = {upright,italic,literal} , } \keys_define:nn {unicode-math} { partial .choice_code:n = { \bool_set_false:N \g_um_literal_partial_bool \ifcase \l_keys_choice_int \bool_set_true:N \g_um_uppartial_bool \or \bool_set_false:N \g_um_uppartial_bool \or \bool_set_true:N \g_um_literal_partial_bool \fi } , partial .generate_choices:n = {upright,italic,literal} , } \keys_define:nn {unicode-math} { vargreek-shape .choice: , vargreek-shape / unicode .code:n = { \bool_set_false:N \g_um_texgreek_bool } , vargreek-shape / TeX .code:n = { \bool_set_true:N \g_um_texgreek_bool } } \keys_define:nn {unicode-math} { colon .choice: , colon / literal .code:n = { \bool_set_true:N \g_um_literal_colon_bool } , colon / TeX .code:n = { \bool_set_false:N \g_um_literal_colon_bool } } \keys_define:nn {unicode-math} { slash-delimiter .choice: , slash-delimiter / ascii .code:n = { \tl_set:Nn \g_um_slash_delimiter_usv {"002F} } , slash-delimiter / frac .code:n = { \tl_set:Nn \g_um_slash_delimiter_usv {"2044} } , slash-delimiter / div .code:n = { \tl_set:Nn \g_um_slash_delimiter_usv {"2215} } } \keys_define:nn {unicode-math} { active-frac .choice: , active-frac / small .code:n = { \cs_if_exist:NTF \tfrac { \bool_set_true:N \l_um_smallfrac_bool }{ \um_warning:n {no-tfrac} \bool_set_false:N \l_um_smallfrac_bool } \use:c{um_setup_active_frac:} } , active-frac / normalsize .code:n = { \bool_set_false:N \l_um_smallfrac_bool \use:c{um_setup_active_frac:} } } \keys_define:nn {unicode-math} { warnings-off .code:n = { \clist_map_inline:nn {#1} { \msg_redirect_name:nnn { unicode-math } { ##1 } { none } } } } \keys_define:nn {unicode-math} { trace .choice: , trace / debug .code:n = { \msg_redirect_module:nnn { unicode-math } { log } { warning } } , trace / on .code:n = { % default } , trace / off .code:n = { \msg_redirect_module:nnn { unicode-math } { log } { none } } , } \unimathsetup {math-style=TeX} \unimathsetup {slash-delimiter=ascii} \unimathsetup {trace=off} \cs_if_exist:NT \tfrac { \unimathsetup {active-frac=small} } \ProcessKeysOptions {unicode-math} \cs_new:Npn \um_warning:n { \msg_warning:nn {unicode-math} } \cs_new:Npn \um_log:n { \msg_log:nn {unicode-math} } \cs_new:Npn \um_log:nx { \msg_log:nnx {unicode-math} } \msg_new:nnn {unicode-math} {no-tfrac} { Small~ fraction~ command~ \protect\tfrac\ not~ defined.\\ Load~ amsmath~ or~ define~ it~ manually~ before~ loading~ unicode-math. } \msg_new:nnn {unicode-math} {default-math-font} { Defining~ the~ default~ maths~ font~ as~ '\l_um_fontname_tl'. } \msg_new:nnn {unicode-math} {setup-implicit} { Setup~ alphabets:~ implicit~ mode. } \msg_new:nnn {unicode-math} {setup-explicit} { Setup~ alphabets:~ explicit~ mode. } \msg_new:nnn {unicode-math} {alph-initialise} { Initialising~ \@backslashchar math#1. } \msg_new:nnn {unicode-math} {setup-alph} { Setup~ alphabet:~ #1. } \msg_new:nnnn { unicode-math } { no-font-selected } { You've~ loaded~ the~ unicode-math~ package,~ but~ you~ forgot~ to~ select~ a~ Unicode~ math~ font.~ Please~ select~ one~ with~ the~ \token_to_str:N \setmathfont \\ command. } { Loading~ the~ unicode-math~ package~ without~ using~ a~ Unicode~ math~ font~ is~ not~ supported.~ Either~ select~ a~ Unicode~ math~ font,~ or~ don't~ load~ the~ unicode-math~ package. } \msg_new:nnn { unicode-math } { missing-alphabets } { Missing~math~alphabets~in~font~ "\fontname\l_um_font" \\ \\ \seq_map_function:NN \l_um_missing_alph_seq \um_print_indent:n } \cs_new:Nn \um_print_indent:n { \space\space\space\space #1 \\ } \msg_new:nnn {unicode-math} {macro-expected} { I've~ expected~ that~ #1~ is~ a~ macro,~ but~ it~ isn't. } \msg_new:nnn {unicode-math} {wrong-meaning} { I've~ expected~ #1~ to~ have~ the~ meaning~ #3,~ but~ it~ has~ the~ meaning~ #2. } \msg_new:nnn {unicode-math} {patch-macro} { I'm~ going~ to~ patch~ macro~ #1. } \msg_new:nnn { unicode-math } { mathtools-colon } { I'm~ going~ to~ overwrite~ the~ following~ commands~ from~ the~ `mathtools'~ package: \\ \\ \ \ \ \ \token_to_str:N \dblcolon,~ \token_to_str:N \coloneqq,~ \token_to_str:N \Coloneqq,~ \token_to_str:N \eqqcolon. \\ \\ Note~ that~ since~ I~ won't~ overwrite~ the~ other~ colon-like~ commands,~ using~ them~ will~ lead~ to~ inconsistencies. } \msg_new:nnn { unicode-math } { colonequals } { I'm~ going~ to~ overwrite~ the~ following~ commands~ from~ the~ `colonequals'~ package: \\ \\ \ \ \ \ \token_to_str:N \ratio,~ \token_to_str:N \coloncolon,~ \token_to_str:N \minuscolon, \\ \ \ \ \ \token_to_str:N \colonequals,~ \token_to_str:N \equalscolon,~ \token_to_str:N \coloncolonequals. \\ \\ Note~ that~ since~ I~ won't~ overwrite~ the~ other~ colon-like~ commands,~ using~ them~ will~ lead~ to~ inconsistencies.~ Furthermore,~ changing~ \token_to_str:N \colonsep \c_space_tl or~ \token_to_str:N \doublecolonsep \c_space_tl won't~ have~ any~ effect~ on~ the~ re-defined~ commands. } \luatex_if_engine:T { \usepackage{unicode-math-luatex} \endinput } \xetex_if_engine:T { \usepackage{unicode-math-xetex} \endinput }