summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/fixdif/fixdif.sty
blob: 3d2cc4f208ad303a8a5b7092151c5a9ebbdc5873 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
%%
%% This is file `fixdif.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% fixdif.dtx  (with options: `package')
%% 
%%   Copyright (C) 2022-2023 by Zhang Tingxuan <alphaztx@163.com>
%% 
%%   This work may be distributed and/or modified under the
%%   conditions of the LaTeX Project Public License, either
%%   version 1.3c of this license or (at your option) any later
%%   version. The latest version of this license is in:
%% 
%%     http://www.latex-project.org/lppl.txt
%% 
%%   and version 1.3 or later is part of all distributions of
%%   LaTeX version 2005/12/01 or later.
%% 
%%   This work has the LPPL maintenance status `maintained'.
%% 
%%   The Current Maintainer of this work is Zhang Tingxuan.
%% 
%%   This work consists of the files fixdif.dtx,
%%             and the derived files fixdif.ins,
%%                                   fixdif.sty,
%%                                   fixdif.pdf,
%%                               and README.md.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{fixdif}[2023/01/31 Interface for defining differential operators.]
\AtBeginDocument{%
\ifcsname symbf\endcsname%
  \csname bool_if:cF\endcsname{g__um_main_font_defined_bool}%
    {\csname __um_load_lm:\endcsname}%
  \Umathcode`\/="4 \symoperators "002F%
  \Umathcode"2044="4 \symoperators "2044%
  \Umathcode"2215="4 \symoperators "2215%
  \Umathcode"2F98="4 \symoperators "2F98%
  \Umathcode`\\="4 \symoperators "005C%
  \Umathcode"2216="4 \symoperators "2216%
  \Umathcode"29F5="4 \symoperators "29F5%
  \Umathcode"29F9="4 \symoperators "29F9%
\else\ifcsname fontspec\endcsname
  \csname bool_if:cT\endcsname{g__fontspec_math_bool}%
    {%
      \everymath{\mathcode`\/="413D\relax}%
      \PackageWarning{fixdif}{Requires `no-math' option of fontspec!\MessageBreak}%
    }% fontspec only influences "/"
\fi\fi}
\mathcode`\/="413D
\mathcode`\\="426E% \backslash
\protected\def\backslash{\delimiter"426E30F\relax}
\def\fd@mu@p{\mathchoice{\mskip-\thinmuskip}{\mskip-\thinmuskip}{}{}{}}
\def\s@fd@mu@p{\mathchoice{}{}{\hbox{}}{\hbox{}}}
\DeclareOption{rm}{%
  \AtBeginDocument{\ifcsname symbf\endcsname%
    \gdef\@fd@dif{\symrm{d}}\fi}%
  \gdef\@fd@dif{\mathrm{d}}}
\DeclareOption{normal}{\gdef\@fd@dif{d}}
\DeclareOption{partial}{\@tempswatrue}
\DeclareOption{nopartial}{\@tempswafalse}
\ExecuteOptions{rm,partial}
\ProcessOptions\relax
\if@tempswa
  \AtEndOfPackage{\letdif{\partial}{partial}}
\fi
\gdef\resetdfont#1{\AtBeginDocument{\let\@fd@dif\relax\gdef\@fd@dif{#1{d}}}}
\def\fd@dif{\mathinner{\@fd@dif}\fd@mu@p}
\AtBeginDocument{\let\fd@d@acc\d
  \DeclareRobustCommand\d{\ifmmode\fd@dif\else\expandafter\fd@d@acc\fi}}
\def\@letdif#1#2{\AtBeginDocument{%
  \ifcsname #2nondif\endcsname\else%
  \expandafter\let\csname #2nondif\expandafter\endcsname
    \csname #2\endcsname%
  \fi%
  \DeclareRobustCommand#1{\mathinner{\csname #2nondif\endcsname}\fd@mu@p}%
}}
\def\s@letdif#1#2{\AtBeginDocument{%
  \ifcsname #2nondif\endcsname\else%
  \expandafter\let\csname #2nondif\expandafter\endcsname
    \csname #2\endcsname%
  \fi%
  \DeclareRobustCommand#1{\mathinner{\s@fd@mu@p\csname #2nondif\endcsname\hbox{}}\fd@mu@p}%
}}
\DeclareRobustCommand\letdif{\@ifstar\s@letdif\@letdif}
\@onlypreamble\letdif
\long\def\@newdif#1#2{\AtBeginDocument{%
  \ifdefined#1
    \PackageError{fixdif}{\string#1 is already defined}
      {Try another command instead of \string#1.}%
  \else
    \DeclareRobustCommand#1{\mathinner{#2}\fd@mu@p}%
  \fi%
}}
\long\def\s@newdif#1#2{\AtBeginDocument{%
  \ifdefined#1
  \PackageError{fixdif}{\string#1 is already defined}
    {Try another command instead of \string#1.}%
  \else
    \DeclareRobustCommand#1{\s@fd@mu@p\mathinner{#2\hbox{}}\fd@mu@p}%
  \fi%
}}
\DeclareRobustCommand\newdif{\@ifstar\s@newdif\@newdif}
\@onlypreamble\newdif
\long\def\@renewdif#1#2{\AtBeginDocument{%
  \ifdefined#1
    \DeclareRobustCommand#1{\mathinner{#2}\fd@mu@p}%
  \else
    \PackageError{fixdif}{\string#1 has not been defined yet}
      {You should use \string\newdif instead of \string\renewdif.}%
  \fi%
}}
\long\def\s@renewdif#1#2{\AtBeginDocument{%
  \ifdefined#1
    \DeclareRobustCommand#1{\s@fd@mu@p\mathinner{#2\hbox{}}\fd@mu@p}%
  \else
    \PackageError{fixdif}{\string#1 has not been defined yet}
      {You should use \string\newdif instead of \string\renewdif.}%
  \fi%
}}
\DeclareRobustCommand\renewdif{\@ifstar\s@renewdif\@renewdif}
\@onlypreamble\renewdif
\def\@mathdif#1{\mathinner{#1}\fd@mu@p}
\def\s@mathdif#1{\s@fd@mu@p\mathinner{#1\mbox{}}\fd@mu@p}
\DeclareRobustCommand\mathdif{\@ifstar\s@mathdif\@mathdif}
\endinput
%%
%% End of file `fixdif.sty'.