summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/macros.tex201
-rw-r--r--config/preambule.tex22
2 files changed, 157 insertions, 66 deletions
diff --git a/config/macros.tex b/config/macros.tex
index a3a0837..8d0591a 100644
--- a/config/macros.tex
+++ b/config/macros.tex
@@ -1,89 +1,159 @@
%%% Emacs: -*- mode:latex; coding:utf-8; -*-
+%% Un peu de magie en Lua: ces fonctions servent à transformer une
+%% suite de caractères en les commandes \char ou \luatexUmathchar qui
+%% représentent ces caractères.
+
+\directlua{
+dmadore = {} % Nom du module où stocker ces fonctions
+function dmadore.process_chars(consumer)
+ local nesting = 0
+ local t
+ repeat
+ t = token.get_next()
+ if t[1]==1 then % Accolade ouvrante
+ if nesting>0 then consumer(t[2]) end
+ nesting = nesting+1
+ elseif t[1]==2 then % Accolade fermante
+ nesting = nesting-1
+ if nesting>0 then consumer(t[2]) end
+ elseif t[1]>=3 and t[1]<=15 then
+ consumer(t[2])
+ elseif token.is_activechar(t) then % Caractère actif
+ for v in string.utfvalues(token.csname_name(t)) do
+ consumer(v)
+ end
+ else
+ tex.error("I didn't expect a control sequence here")
+ end
+ until nesting==0
+end
+function dmadore.emit_text_char(v)
+ tex.sprint(luatexbase.catcodetables.CatcodeTableLaTeX, string.char(0x5c).."char ", v)
+end
+function dmadore.emit_math_char(v)
+ tex.sprint(luatexbase.catcodetables.CatcodeTableLaTeX, string.char(0x5c).."luatexUmathchar 7 0 ", v)
+end
+function dmadore.emit_text_chars()
+ dmadore.process_chars(dmadore.emit_text_char)
+ tex.sprint(string.char(0x5c).."relax ")
+end
+function dmadore.emit_math_chars()
+ dmadore.process_chars(dmadore.emit_math_char)
+ tex.sprint(string.char(0x5c).."relax ")
+end
+}
+
+\def\emittextchars{\directlua{dmadore.emit_text_chars()}}
+\def\emitmathchars{\directlua{dmadore.emit_math_chars()}}
+
%%
%% Macros pour les formules
%%
%% Opérateurs en caractères romains, etc.
+% Macros servant à obtenir des caractères romains/sans-sérif "ordinaires" en mode maths
+%
+% Le but est de résoudre le problème des accents qui n'apparaissaient
+% pas, par exemple, dans \mathrm{Dér} (parce qu'Unicode ne définit pas
+% les caractères accentués dans les alphabets mathématiques et,
+% concrètement, parce que le package unicode-math ne leur donne pas
+% des \mathcode appropriés, et ne fournit d'ailleurs pas de 'é'
+% sans-sérif ou autre truc du genre).
+%
+% Ces macros servent donc à écrire du texte dans des formules
+% mathématiques, de façon un peu « intermédiaire » entre \mathrm et
+% \textrm : elles créent du vrai mode maths (donc qui change de taille
+% en exposant et indice, contrairement à \textrm) mais en allant
+% chercher dans une police orientée texte et _sans_ aller prendre dans
+% les alphabets « mathématiques » d'Unicode. Attention : à cause de
+% l'usage de \emitmathchars, le paramètre passé à ces macros ne doit
+% pas contenir de commande quelle qu'elle soit, uniquement des
+% caractères.
+
+\newcommand\mathtextrm[1]{\mathtextrmfont{\emitmathchars{#1}}}
+\newcommand\mathtextsf[1]{\mathtextsffont{\emitmathchars{#1}}}
+\newcommand\mathtexttt[1]{\mathtextttfont{\emitmathchars{#1}}}
+
% Macro pour définir un opérateur dans une police quelconque
\newcommand\DeclareMathOperatorWithFont[3]{%
\newcommand{#1}{\mathop{\kern0pt\relax#2{#3}}\nolimits}}
-\DeclareMathOperatorWithFont{\Hom}{\mathsf}{Hom}
-\DeclareMathOperatorWithFont{\MHom}{\mathsf}{MHom}
-\DeclareMathOperatorWithFont{\End}{\mathsf}{End}
-\DeclareMathOperatorWithFont{\Isom}{\mathsf}{Isom}
-\DeclareMathOperatorWithFont{\Aut}{\mathsf}{Aut}
-\DeclareMathOperatorWithFont{\Int}{\mathsf}{Int}
-\DeclareMathOperatorWithFont{\Out}{\mathsf}{Out}
+\DeclareMathOperatorWithFont{\Hom}{\mathtextsf}{Hom}
+\DeclareMathOperatorWithFont{\MHom}{\mathtextsf}{MHom}
+\DeclareMathOperatorWithFont{\End}{\mathtextsf}{End}
+\DeclareMathOperatorWithFont{\Isom}{\mathtextsf}{Isom}
+\DeclareMathOperatorWithFont{\Aut}{\mathtextsf}{Aut}
+\DeclareMathOperatorWithFont{\Int}{\mathtextsf}{Int}
+\DeclareMathOperatorWithFont{\Out}{\mathtextsf}{Out}
-\DeclareMathOperatorWithFont{\Sym}{\mathsf}{Sym} % quelle police utiliser ?
+\DeclareMathOperatorWithFont{\Sym}{\mathtextsf}{Sym} % quelle police utiliser ?
-\DeclareMathOperatorWithFont{\Der}{\mathrm}{Dér} % quelle police utiliser ?
+\DeclareMathOperatorWithFont{\Der}{\mathtextrm}{Dér} % quelle police utiliser ?
-\DeclareMathOperatorWithFont{\Id}{\mathrm}{Id}
-\DeclareMathOperatorWithFont{\Ker}{\mathrm}{Ker}
-\DeclareMathOperatorWithFont{\Coker}{\mathrm}{Coker}
-\DeclareMathOperatorWithFont{\rmIm}{\mathrm}{Im}
+\DeclareMathOperatorWithFont{\Id}{\mathtextrm}{Id}
+\DeclareMathOperatorWithFont{\Ker}{\mathtextrm}{Ker}
+\DeclareMathOperatorWithFont{\Coker}{\mathtextrm}{Coker}
+\DeclareMathOperatorWithFont{\rmIm}{\mathtextrm}{Im}
\AtBeginDocument{\let\Im\rmIm} % Écrase la définition standard de \Im
-\DeclareMathOperatorWithFont{\Fix}{\mathrm}{Fix}
-\DeclareMathOperatorWithFont{\Stab}{\mathrm}{Stab}
+\DeclareMathOperatorWithFont{\Fix}{\mathtextrm}{Fix}
+\DeclareMathOperatorWithFont{\Stab}{\mathtextrm}{Stab}
-\DeclareMathOperatorWithFont{\pgcd}{\mathrm}{pgcd}
-\DeclareMathOperatorWithFont{\ppcm}{\mathrm}{ppcm}
+\DeclareMathOperatorWithFont{\pgcd}{\mathtextrm}{pgcd}
+\DeclareMathOperatorWithFont{\ppcm}{\mathtextrm}{ppcm}
-\DeclareMathOperatorWithFont{\prlim}{\mathrm}{lim}
-\DeclareMathOperatorWithFont{\colim}{\mathrm}{colim}
+\DeclareMathOperatorWithFont{\prlim}{\mathtextrm}{lim}
+\DeclareMathOperatorWithFont{\colim}{\mathtextrm}{colim}
-\DeclareMathOperatorWithFont{\car}{\mathrm}{car}
-\DeclareMathOperatorWithFont{\Frob}{\mathrm}{Frob}
+\DeclareMathOperatorWithFont{\car}{\mathtextrm}{car}
+\DeclareMathOperatorWithFont{\Frob}{\mathtextrm}{Frob}
-\DeclareMathOperatorWithFont{\Spec}{\mathrm}{Spec}
-\DeclareMathOperatorWithFont{\Specmax}{\mathrm}{Specmax}
-\DeclareMathOperatorWithFont{\Frac}{\mathrm}{Frac}
-\DeclareMathOperatorWithFont{\Nilp}{\mathrm}{Nilp}
-\DeclareMathOperatorWithFont{\red}{\mathrm}{red}
-\DeclareMathOperatorWithFont{\Idem}{\mathrm}{Idem}
-\DeclareMathOperatorWithFont{\Ann}{\mathrm}{Ann}
-\DeclareMathOperatorWithFont{\rad}{\mathrm}{rad}
+\DeclareMathOperatorWithFont{\Spec}{\mathtextrm}{Spec}
+\DeclareMathOperatorWithFont{\Specmax}{\mathtextrm}{Specmax}
+\DeclareMathOperatorWithFont{\Frac}{\mathtextrm}{Frac}
+\DeclareMathOperatorWithFont{\Nilp}{\mathtextrm}{Nilp}
+\DeclareMathOperatorWithFont{\red}{\mathtextrm}{red}
+\DeclareMathOperatorWithFont{\Idem}{\mathtextrm}{Idem}
+\DeclareMathOperatorWithFont{\Ann}{\mathtextrm}{Ann}
+\DeclareMathOperatorWithFont{\rad}{\mathtextrm}{rad}
-\DeclareMathOperatorWithFont{\dec}{\mathrm}{déc}
-\DeclareMathOperatorWithFont{\Gal}{\mathrm}{Gal}
-\DeclareMathOperatorWithFont{\Result}{\mathrm}{Résult}
-\DeclareMathOperatorWithFont{\Pic}{\mathrm}{Pic}
-\DeclareMathOperatorWithFont{\Br}{\mathrm}{Br}
-\DeclareMathOperatorWithFont{\Azu}{\mathrm}{Azu}
+\DeclareMathOperatorWithFont{\dec}{\mathtextrm}{déc}
+\DeclareMathOperatorWithFont{\Gal}{\mathtextrm}{Gal}
+\DeclareMathOperatorWithFont{\Result}{\mathtextrm}{Résult}
+\DeclareMathOperatorWithFont{\Pic}{\mathtextrm}{Pic}
+\DeclareMathOperatorWithFont{\Br}{\mathtextrm}{Br}
+\DeclareMathOperatorWithFont{\Azu}{\mathtextrm}{Azu}
-\DeclareMathOperatorWithFont{\Tr}{\mathrm}{Tr}
-\DeclareMathOperatorWithFont{\Trd}{\mathrm}{Trd}
-\DeclareMathOperatorWithFont{\N}{\mathrm}{N}
-\DeclareMathOperatorWithFont{\Nrd}{\mathrm}{Nrd}
-\DeclareMathOperatorWithFont{\NSpin}{\mathrm}{N\!S}
+\DeclareMathOperatorWithFont{\Tr}{\mathtextrm}{Tr}
+\DeclareMathOperatorWithFont{\Trd}{\mathtextrm}{Trd}
+\DeclareMathOperatorWithFont{\N}{\mathtextrm}{N}
+\DeclareMathOperatorWithFont{\Nrd}{\mathtextrm}{Nrd}
+\DeclareMathOperatorWithFont{\NSpin}{\mathtextrmfont}{\emitmathchars{N}\!\emitmathchars{S}}
-\DeclareMathOperatorWithFont{\ev}{\mathrm}{ev}
-\DeclareMathOperatorWithFont{\pr}{\mathrm}{pr}
+\DeclareMathOperatorWithFont{\ev}{\mathtextrm}{ev}
+\DeclareMathOperatorWithFont{\pr}{\mathtextrm}{pr}
-\DeclareMathOperatorWithFont{\ob}{\mathsf}{Ob}
+\DeclareMathOperatorWithFont{\ob}{\mathtextsf}{Ob}
-\DeclareMathOperatorWithFont{\GL}{\mathrm}{GL}
-\DeclareMathOperatorWithFont{\PGL}{\mathrm}{PGL}
-\DeclareMathOperatorWithFont{\AGL}{\mathrm}{AGL}
-\DeclareMathOperatorWithFont{\PSL}{\mathrm}{PSL}
-\DeclareMathOperatorWithFont{\Orth}{\mathrm}{O}
-\DeclareMathOperatorWithFont{\SOrth}{\mathrm}{SO}
+\DeclareMathOperatorWithFont{\GL}{\mathtextrm}{GL}
+\DeclareMathOperatorWithFont{\PGL}{\mathtextrm}{PGL}
+\DeclareMathOperatorWithFont{\AGL}{\mathtextrm}{AGL}
+\DeclareMathOperatorWithFont{\PSL}{\mathtextrm}{PSL}
+\DeclareMathOperatorWithFont{\Orth}{\mathtextrm}{O}
+\DeclareMathOperatorWithFont{\SOrth}{\mathtextrm}{SO}
-\DeclareMathOperatorWithFont{\rang}{\mathrm}{rang}
-\DeclareMathOperatorWithFont{\degtr}{\mathrm}{deg.tr}
+\DeclareMathOperatorWithFont{\rang}{\mathtextrm}{rang}
+\DeclareMathOperatorWithFont{\degtr}{\mathtextrm}{deg.tr}
-\DeclareMathOperatorWithFont{\diag}{\mathrm}{diag}
+\DeclareMathOperatorWithFont{\diag}{\mathtextrm}{diag}
-\DeclareMathOperatorWithFont{\Res}{\mathrm}{Rés}
+\DeclareMathOperatorWithFont{\Res}{\mathtextrm}{Rés}
% Exposants
-\newcommand{\op}{^{\mathsf{op}}}
-\newcommand{\sep}{^{\mathrm{sép}}}
-\newcommand{\alg}{^{\mathrm{alg}}}
+\newcommand{\op}{^{\mathtextsf{op}}}
+\newcommand{\sep}{^{\mathtextrm{sép}}}
+\newcommand{\alg}{^{\mathtextrm{alg}}}
%% Ensembles usuels
\newcommand{\ZZ}{\mathbf{Z}}
@@ -173,19 +243,18 @@
%% Caractères japonais
% On définit la police IPA Mincho. En mode texte :
\newfontfamily\IPAMincho[Script=CJK]{IPAMincho}
-% Et en mode maths (l'argument range semble ne pas fonctionner !) :
-\setmathfont[range={"4E00-"9FFF},Script=CJK]{IPAMincho}
-% On sauve le nom LaTeX de famille de cette police
+% Et en mode maths :
\ExplSyntaxOn
-\let\saveIPAMinchoFamily\um_symfont_tl
+\fontspec_set_family:Nnn{\IPAMinchoFamily}{Script=CJK}{IPAMincho}
\ExplSyntaxOff
+\DeclareSymbolFont{japanese}{EU2}{\IPAMinchoFamily}{\mddefault}{\updefault}
% Maintenant on peut définir les caractères eux-mêmes
-\Umathcode`米="0 \the\csname sym\saveIPAMinchoFamily\endcsname"7C73
-\DeclareUnicodeMathSymbol{\yone}{\mathord}{\saveIPAMinchoFamily}{"7C73}
-\Umathcode`田="0 \the\csname sym\saveIPAMinchoFamily\endcsname"7530
-\DeclareUnicodeMathSymbol{\yoneDA}{\mathord}{\saveIPAMinchoFamily}{"7530}
-\Umathcode`別="0 \the\csname sym\saveIPAMinchoFamily\endcsname"5225
-\DeclareUnicodeMathSymbol{\betsu}{\mathord}{\saveIPAMinchoFamily}{"5225}
+\Umathcode`米="0 \symjapanese"7C73
+\DeclareUnicodeMathSymbol{\yone}{\mathord}{japanese}{"7C73}
+\Umathcode`田="0 \symjapanese"7530
+\DeclareUnicodeMathSymbol{\yoneDA}{\mathord}{japanese}{"7530}
+\Umathcode`別="0 \symjapanese"5225
+\DeclareUnicodeMathSymbol{\betsu}{\mathord}{japanese}{"5225}
% Voir <URL: http://tex.stackexchange.com/questions/95304/spacing-changes-when-using-unicode-math-range-feature-why >
\setmathfont[range={}]{XITS Math}
diff --git a/config/preambule.tex b/config/preambule.tex
index 677f1f7..cfa4912 100644
--- a/config/preambule.tex
+++ b/config/preambule.tex
@@ -2,6 +2,9 @@
%%
%% Les packages à inclure.
%%
+\usepackage{luatexbase-regs}
+\usepackage{luatexbase-cctb}
+%
\usepackage[a4paper,hmargin=2.5cm,vmargin={2.5cm,3cm}]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
@@ -25,6 +28,8 @@
%%
\setmainfont{Linux Libertine O}
\setmathfont{XITS Math}
+% On sauve le nom LaTeX de famille de cette police
+\expandafter\let\expandafter\saveXITSMathSymfont\csname um_symfont_tl\endcsname
%% Pour utiliser une police maths adaptée du Computer Modern (mais en Unicode):
%\setmathfont[range=\mathup/{latin,Latin,greek,Greek}]{CMU Serif}
%\setmathfont[range=\mathit/{latin,Latin,greek,Greek}]{CMU Serif Italic}
@@ -32,3 +37,20 @@
%\setmathfont[range=\mathbfit/{latin,Latin,greek,Greek}]{CMU Serif Bold Italic}
%\setmathfont[range=\mathsfup/{latin,Latin}]{CMU Sans Serif}
%\setmathfont[range=\mathtt/{latin,Latin}]{CMU Typewriter Text}
+%
+%% On charge aussi une police de type Times et une de type Helvetica
+% Attention ! Comme ces polices ne contiennent pas les alphabets
+% mathématiques d'Unicode (et qu'à cause du package unicode-math taper
+% un bête x va émettre un U+1D465 MATHEMATICAL ITALIC SMALL X), les
+% commandes \mathtextrmfont et \mathtextsffont ne pourront fonctionner
+% que si on a redéfini les \mathcode - il faut donc plutôt utiliser
+% \mathtextrm et \mathtextsf (définis dans macros.tex) qui appellent
+% la magie de \emitmathchars pour obtenir des caractères "normaux".
+\ExplSyntaxOn
+\fontspec_set_family:Nnn{\TeXGyreTermesFamily}{}{TeXGyreTermes}
+\fontspec_set_family:Nnn{\TeXGyreHerosFamily}{}{TeXGyreHeros}
+\fontspec_set_family:Nnn{\CMUTypewriterFamily}{}{CMU Typewriter Text}
+\DeclareMathAlphabet{\mathtextrmfont}{EU2}{\TeXGyreTermesFamily}{\mddefault}{\updefault}
+\DeclareMathAlphabet{\mathtextsffont}{EU2}{\TeXGyreHerosFamily}{\mddefault}{\updefault}
+\DeclareMathAlphabet{\mathtextttfont}{EU2}{\CMUTypewriterFamily}{\mddefault}{\updefault}
+\ExplSyntaxOff