Browse Source

using \MTsetmathskips

master
Jonathan Spratte 1 year ago
parent
commit
c608f228d7
2 changed files with 132 additions and 53 deletions
  1. 127
    53
      MRTsfacc/MRTsfacc.sty
  2. 5
    0
      issues.md

+ 127
- 53
MRTsfacc/MRTsfacc.sty View File

@@ -10,7 +10,6 @@
10 10
   ]
11 11
 
12 12
 \RequirePackage{MRTif}
13
-\RequirePackage{amsmath}
14 13
 
15 14
 \providecommand\@firstofthree[3]{#1}
16 15
 \providecommand\@secondofthree[3]{#2}
@@ -32,64 +31,139 @@
32 31
           }%
33 32
       }%
34 33
   }
34
+\newif\if@MRTsfacc@patching@
35
+\DeclareOption{patching}{\@MRTsfacc@patching@true}
36
+\DeclareOption{mathastext}{\@MRTsfacc@patching@false}
35 37
 \DeclareOption*{\expandafter\MRTsfaccSet\expandafter{\CurrentOption}}
36 38
 \ProcessOptions\relax
37 39
 
38 40
 % stupid package for math font is stupid. Have to cure the sickness >>>
39
-\newcommand\MRTsfacc@kern%>>>
40
-  {%
41
-    \MRTsfacc@shift\ht\MRTsfacc@box
42
-  }%<<<
43
-\newbox\MRTsfacc@box
44
-\newcommand*\MRTsfacc@patch@mathaccentV%>>>
45
-  {%
46
-    \let\mathaccentV@orig\mathaccentV
47
-    \protected\long\def\mathaccentV##1##2##3##4% >>>
48
-      {%
49
-        \def\mathaccentV@args{{##1}{##2}{##3}{##4}}%
50
-        \futurelet\next\mathaccentV@a
51
-      }% <<<
52
-    \newcommand*\mathaccentV@a[1]% >>>
53
-      {%
54
-        \expandafter\ifx\next!%
55
-          \expandafter\@firstofthree
56
-        \else
57
-          \expandafter\ifx\next*%
58
-            \expandafter\expandafter\expandafter\@secondofthree
41
+\if@MRTsfacc@patching@
42
+% true >>>
43
+  \RequirePackage{amsmath}
44
+  \newcommand\MRTsfacc@kern%>>>
45
+    {%
46
+      \MRTsfacc@shift\ht\MRTsfacc@box
47
+    }%<<<
48
+  \newbox\MRTsfacc@box
49
+  \newcommand*\MRTsfacc@patch@mathaccentV%>>>
50
+    {%
51
+      \let\mathaccentV@orig\mathaccentV
52
+      \protected\long\def\mathaccentV##1##2##3##4% >>>
53
+        {%
54
+          \def\mathaccentV@args{{##1}{##2}{##3}{##4}}%
55
+          \futurelet\next\mathaccentV@a
56
+        }% <<<
57
+      \newcommand*\mathaccentV@a[1]% >>>
58
+        {%
59
+          \expandafter\ifx\next!%
60
+            \expandafter\@firstofthree
59 61
           \else
60
-            \expandafter\expandafter\expandafter\@thirdofthree
62
+            \expandafter\ifx\next*%
63
+              \expandafter\expandafter\expandafter\@secondofthree
64
+            \else
65
+              \expandafter\expandafter\expandafter\@thirdofthree
66
+            \fi
61 67
           \fi
62
-        \fi
63
-        {\expandafter\mathaccentV@orig\mathaccentV@args}
64
-        {\expandafter\mathaccentV@shifted\mathaccentV@args}
65
-        {\expandafter\mathaccentV@b\mathaccentV@args{##1}}%
66
-      }% <<<
67
-    \newcommand*\mathaccentV@b[5]% >>>
68
-      {%
69
-        \MRTifLetterGTF{##5}
70
-          {\mathaccentV@shifted{##1}{##2}{##3}{##4}{##5}}
71
-          {\mathaccentV@orig{##1}{##2}{##3}{##4}{##5}}%
72
-      }% <<<
73
-    \newcommand*\mathaccentV@shifted[5]% >>>
74
-      {%
75
-        \mathchoice%
76
-          {\mathaccentV@shifted@a{display}{##1}{##2}{##3}{##4}{##5}}
77
-          {\mathaccentV@shifted@a{text}{##1}{##2}{##3}{##4}{##5}}
78
-          {\mathaccentV@shifted@a{script}{##1}{##2}{##3}{##4}{##5}}
79
-          {\mathaccentV@shifted@a{scriptscript}{##1}{##2}{##3}{##4}{##5}}%
80
-      }% <<<
81
-    \newcommand*\mathaccentV@shifted@a[6]% >>>
82
-      {%
83
-        \setbox\MRTsfacc@box\hbox{$\csname ##1style\endcsname##6$}%
84
-        \kern\MRTsfacc@kern
85
-        \mathaccentV@orig{##2}{##3}{##4}{##5}%
86
-          {%
87
-            \kern-\MRTsfacc@kern
88
-            \copy\MRTsfacc@box % or ##6 both have drawbacks
89
-          }%
90
-      }% <<<
91
-  }%<<<
92
-\AtBeginDocument{\MRTsfacc@patch@mathaccentV}
68
+          {\expandafter\mathaccentV@orig\mathaccentV@args}
69
+          {\expandafter\mathaccentV@shifted\mathaccentV@args}
70
+          {\expandafter\mathaccentV@b\mathaccentV@args{##1}}%
71
+        }% <<<
72
+      \newcommand*\mathaccentV@b[5]% >>>
73
+        {%
74
+          \MRTifLetterGTF{##5}
75
+            {\mathaccentV@shifted{##1}{##2}{##3}{##4}{##5}}
76
+            {\mathaccentV@orig{##1}{##2}{##3}{##4}{##5}}%
77
+        }% <<<
78
+      \newcommand*\mathaccentV@shifted[5]% >>>
79
+        {%
80
+          \mathchoice%
81
+            {\mathaccentV@shifted@a{display}{##1}{##2}{##3}{##4}{##5}}
82
+            {\mathaccentV@shifted@a{text}{##1}{##2}{##3}{##4}{##5}}
83
+            {\mathaccentV@shifted@a{script}{##1}{##2}{##3}{##4}{##5}}
84
+            {\mathaccentV@shifted@a{scriptscript}{##1}{##2}{##3}{##4}{##5}}%
85
+        }% <<<
86
+      \newcommand*\mathaccentV@shifted@a[6]% >>>
87
+        {%
88
+          \setbox\MRTsfacc@box\hbox{$\csname ##1style\endcsname##6$}%
89
+          \kern\MRTsfacc@kern
90
+          \mathaccentV@orig{##2}{##3}{##4}{##5}%
91
+            {%
92
+              \kern-\MRTsfacc@kern
93
+              %\copy\MRTsfacc@box % or ##6 both have drawbacks
94
+              ##6%
95
+            }%
96
+        }% <<<
97
+    }%<<<
98
+  \AtBeginDocument{\MRTsfacc@patch@mathaccentV}
99
+\else% <<<
100
+% false >>>
101
+  \RequirePackage[italic,defaultmathsizes]{mathastext}
102
+  \RequirePackage{xparse}
103
+  \newlength\MRTsfacc@mu
104
+  \newcommand*\MRTsfacc@getmu%>>>
105
+    {%
106
+      \begingroup
107
+        \setbox0\hbox{$\mkern1mu$}%
108
+        \expandafter
109
+      \endgroup
110
+      \expandafter\MRTsfacc@mu\the\wd0
111
+    }%<<<
112
+  \ExplSyntaxOn
113
+  \NewDocumentCommand \MRTsfaccAll {}
114
+    {
115
+      \clist_set_eq:NN \l_MRTsfacc_chars_clist \c_MRTsfacc_chars_clist
116
+    }
117
+  \NewDocumentCommand \MRTsfaccSingle { m m }
118
+    {
119
+      \clist_remove_all:Nn \l_MRTsfacc_chars_clist { #1 }
120
+      \AtBeginDocument { \MRTsfacc@apply@single [ #2 ] { #1 } }
121
+    }
122
+  \NewDocumentCommand \MRTsfaccHelvet {}
123
+    {
124
+      %\MRTsfaccSet{.2}
125
+      %\MRTsfaccAll
126
+      %\MRTsfaccSingle
127
+    }
128
+  \clist_const:Nn \c_MRTsfacc_chars_clist%>>>
129
+    {
130
+      A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,
131
+      a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
132
+    }%<<<
133
+  \clist_new:N \l_MRTsfacc_chars_clist
134
+  \MRTsfaccAll
135
+  \newcommand*\MRTsfacc@pttomu[1]%>>>
136
+    {
137
+      \fp_eval:n { #1 / \MRTsfacc@mu } mu
138
+    }%<<<
139
+  \newcommand*\MRTsfacc@apply%>>>
140
+    {
141
+      \clist_map_function:NN \c_MRTsfacc_chars_clist \MRTsfacc@apply@single
142
+    }%<<<
143
+  \ExplSyntaxOff
144
+  \newcommand*\MRTsfacc@apply@single@a[2]%>>>
145
+    {%
146
+      \typeout{Moving accents for #2 with #1}
147
+      \MTsetmathskips{#2}{-#1}{#1}%
148
+    }%<<<
149
+  \newcommand*\MRTsfacc@apply@single[2][\MRTsfacc@shift]%>>>
150
+    {%
151
+      \begingroup
152
+        \setbox0\hbox{$#2$}%
153
+        \ht0=#1\ht0
154
+        \edef\MRTsfacc@tmp{\MRTsfacc@pttomu{\ht0}}%
155
+        \expandafter
156
+      \endgroup
157
+      \expandafter\MRTsfacc@apply@single@a\expandafter{\MRTsfacc@tmp}{#2}%
158
+    }%<<<
159
+  \AtBeginDocument%>>>
160
+    {%
161
+      \MRTsfacc@getmu
162
+      \MRTsfacc@apply
163
+    }%<<<
93 164
 % <<<
165
+\fi
166
+% <<<
167
+
94 168
 
95 169
 \endinput

+ 5
- 0
issues.md View File

@@ -0,0 +1,5 @@
1
+# XeTeX and LuaTeX
2
+- `mathastext` has to be preceeded by `\usepackage[no-math]{fontspec}`
3
+
4
+# MRTsfacc
5
+- nested use of `\mathaccentV` doesn't work properly

Loading…
Cancel
Save