blob: af6f93165a3b0ad6c3a4c272c100eff36c59cfac (
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
|
% -*- coding: utf-8 -*-
% ----------------------------------------------------------------------------
% Author: Jianrui Lyu <tolvjr@163.com>
% License: The LaTeX Project Public License 1.3c
% ----------------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{medmath}[2024-01-11 v2024B Fix mediummath option in nccmath package]
\RequirePackage{array}
\RequirePackage{etoolbox}
\newif\ifmdm@enabled \mdm@enabledtrue % enable medmath fixes
\newif\ifmdm@amsfonts \mdm@amsfontsfalse % use ams symbol fonts
\DeclareKeys{
mdm@enabled .if = mdm@enabled,
mdm@amsfonts .if = mdm@amsfonts
}
\ProcessKeyOptions
\RequirePackage[mediummath]{nccmath}
\newcommand{\my@do@medmath}{%
%% Adjust \oiint operator
\ifdef{\oiint}{%
\let\NCC@op@oiint=\oiint
\DeclareRobustCommand{\oiintop}{\mathop{\medmath{\NCC@op@oiint}}}%
\def\oiint{\DOTSI\NCC@op@prepare{\oiintop}}%
}{}%
%% Setting \medintcorr parameter
%% We have used relative dimensions later, so no need to set it anymore
%\ifmdm@amsfonts
% \medintcorr{0.5em}
%\else
% \medintcorr{0.3em}
%\fi
%% The definite integrals in cases environment may cause infinite loops
%% Our redefinition moves \quad to the beginning of the second columns
%% Therefore removing extra spaces when there is only one column in it
\renewenvironment{cases}{%
\left\{\linespread{1.0}\selectfont\def\arraystretch{1.2}%
\begin{array}{@{}l@{}>{\quad}l@{}}%
}{%
\end{array}\right.%
}%
%% Right skip is missing when minipage or \parbox has only a displayed formula
%% Other problems could be found here: http://tex.stackexchange.com/q/22170
\let\start@gather=\NCC@startgather
\let\start@align=\NCC@startalign
\let\start@multline=\NCC@startmultline
\let\mathdisplay=\NCC@startdisplay
}
\newcommand{\my@do@medmath@fix}{%
%% Fix sizes of non integral operators in superscripts/subscripts
%% We use the method in scalerel package for saving math styles
% big operator in normal text is 80% of the size of \displaystyle
% big operator in script is 80% of the size of \textstyle
% big operator in script script is 80% of the size of \scriptstyle
\def\@my@style@D{\displaystyle}%
\def\@my@style@T{\displaystyle}%
\def\@my@style@S{\textstyle}%
\def\@my@style@s{\scriptstyle}%
\def\my@style@saved{\csname @my@style@\@my@style@switch\endcsname}%
\newcommand{\my@style@this}[1]{%
\mathchoice{\def\@my@style@switch{D}##1}{\def\@my@style@switch{T}##1}
{\def\@my@style@switch{S}##1}{\def\@my@style@switch{s}##1}%
}%
\DeclareRobustCommand*\medmath[1]{\NCC@select@msize
\mathord{\my@style@this{\raise\@tempdima\hbox{\NCC@prepare@msize$\my@style@saved ##1$}}}%
}
%% Fix sizes of integral operators in superscripts/subscripts
\newlength{\@my@em}%
\setlength{\@my@em}{1em}%
\ifmdm@amsfonts
\medintcorr{0.5\@my@em}%
\else
\medintcorr{0.3\@my@em}%
\fi
\newcommand{\my@style@unit}[1]{%
\mathchoice{\setlength{\@my@em}{1em}##1}{\setlength{\@my@em}{1em}##1}
{\setlength{\@my@em}{0.5em}##1}{\setlength{\@my@em}{0.3em}##1}%
}%
\let\my@saved@op@printm=\NCC@op@printm
\def\NCC@op@printm{\my@style@unit{\my@saved@op@printm}}%
%% Fix fractions and subfractions in superscripts/subscripts
%% Always use current style size to typeset the fractions
\newcommand{\my@larger@frac}[2]{%
\mathchoice{\genfrac{}{}{}{0}{##1}{##2}}{\genfrac{}{}{}{0}{##1}{##2}}%
{\genfrac{}{}{}{1}{##1}{##2}}{\genfrac{}{}{}{2}{##1}{##2}}%
}%
\DeclareRobustCommand{\frac}[2]{%
\mathchoice{\mfrac{##1}{##2}}{\mfrac{##1}{##2}}%
{\my@larger@frac{##1}{##2}}{\my@larger@frac{##1}{##2}}%
}%
\patchcmd{\NCC@prepare@msize}{%
\def\frac{\protect\NCC@innerfrac{}}%
}{%
\let\frac=\my@larger@frac
}{}{}%
}
\AtBeginDocument{%
\ifmdm@enabled
\my@do@medmath \my@do@medmath@fix
\fi
}
|