You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MRTsfacc.sty 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. \newcommand*\MRTsfacc@version{0.0.4}
  2. \newcommand*\MRTsfacc@date{2018-11-07}
  3. \NeedsTeXFormat{LaTeX2e}
  4. \ProvidesPackage{MRTsfacc}
  5. [%
  6. \MRTsfacc@date\space v\MRTsfacc@version\space fixes accents for sf-math with
  7. helvet and other fonts%
  8. ]
  9. \RequirePackage{MRTif}
  10. \RequirePackage{amsmath}
  11. \providecommand\@firstofthree[3]{#1}
  12. \providecommand\@secondofthree[3]{#2}
  13. \providecommand\@thirdofthree[3]{#3}
  14. \def\MRTsfacc@shift{0.25}
  15. \newcommand\MRTsfaccSet[1]%>>>
  16. {%
  17. \MRTifFloatTF{#1}
  18. {\def\MRTsfacc@shift{#1}}
  19. {%
  20. \PackageError{MRTsfacc}{Provided option `#1` is no valid float}
  21. {%
  22. Parsing says you didn't provide a valid float. Please provide a
  23. valid float.\MessageBreak
  24. If you're sure that you entered a valid float, please report the bug
  25. to the\MessageBreak
  26. package maintainer.%
  27. }%
  28. }%
  29. }%<<<
  30. \newif\if@MRTsfacc@notest@
  31. \newif\if@MRTsfacc@height@
  32. \@MRTsfacc@height@true
  33. \DeclareOption{height}{\@MRTsfacc@height@true}
  34. \DeclareOption{list}{\@MRTsfacc@height@false}
  35. \DeclareOption{notest}{\@MRTsfacc@notest@true}
  36. \DeclareOption*{\expandafter\MRTsfaccSet\expandafter{\CurrentOption}}
  37. \ProcessOptions\relax
  38. % Test whether \mathaccentV has the correct meaning >>>
  39. \if@MRTsfacc@notest@
  40. \else
  41. % this is amsmath's definition of \mathaccentV (2018-06-11)
  42. \AtBeginDocument% >>>
  43. {%
  44. \begingroup
  45. \newcommand*\MRTsfacc@mathaccentV@test[5]% >>>
  46. {%
  47. \ifmmode
  48. \gdef\macc@tmp{\macc@depth\@ne}%
  49. \setbox\z@\hbox
  50. {%
  51. \let\mathaccentV\macc@test
  52. \let\use@mathgroup\@gobbletwo
  53. \let\select@group\@gobblethree
  54. \frozen@everymath{}%
  55. $#5$%
  56. }%
  57. \macc@tmp
  58. \ifnum\macc@depth=\@ne
  59. \global\let\macc@nucleus\@empty
  60. \mathaccent"\accentclass@
  61. \else
  62. \@xp\macc@nested
  63. \fi
  64. #2#3#4{#5}\macc@nucleus
  65. \else
  66. \@xp\nonmatherr@\csname #1\endcsname
  67. \fi
  68. }% <<<
  69. \ifx\MRTsfacc@mathaccentV@test\mathaccentV
  70. \else
  71. \PackageError{MRTsfacc}{Compatibility with amsmath might be broken}
  72. {%
  73. This version of MRTsfacc might be incompatible with your version of
  74. amsmath.%
  75. \MessageBreak
  76. This is tested by comparing the definition of
  77. \string\mathaccentV\space with a known\MessageBreak definition.%
  78. \MessageBreak
  79. Read the manual of this `MRTsfacc`. Afterwards you might contact the
  80. package\MessageBreak maintainer of this package.%
  81. }%
  82. \fi
  83. \endgroup
  84. }% <<<
  85. \fi
  86. % <<<
  87. \newcommand\MRTsfacc@mathaccentV[5]% >>>
  88. {%
  89. \global\let\macc@nucleus\@empty
  90. \mathaccent"\accentclass@#2#3#4{#5}\macc@nucleus
  91. }% <<<
  92. \newif\if@MRTsfacc@found@known@
  93. \edef\MRTsfacc@mathaccentV@detokenized{\detokenize{\mathaccentV}}
  94. \long\def\MRTsfacc@mathaccentV@using@inner#1 #2 #3\endMRTsfacc@arg% >>>
  95. {%
  96. \MRTifStringsMatchXXTF{\MRTsfacc@mathaccentV@detokenized}{#2 }
  97. }% <<<
  98. \newcommand\MRTsfacc@mathaccentV@using[1]% >>>
  99. {%
  100. \expandafter\MRTsfacc@mathaccentV@using@inner\meaning#1 . .\endMRTsfacc@arg
  101. }% <<<
  102. \newcommand\MRTsfacc@testnest[2]% >>>
  103. {%
  104. \MRTifTwoTokenTF{#2}
  105. {%
  106. \@MRTsfacc@found@known@false
  107. \setbox\z@\hbox
  108. {%
  109. \let\MRTsfacc@testknown#1\relax
  110. \let\mathaccentV\MRTsfacc@testnest@
  111. \let\use@mathgroup\@gobbletwo
  112. \let\select@group\@gobblethree
  113. \frozen@everymath{}%
  114. $#2$%
  115. }%
  116. \if@MRTsfacc@found@known@
  117. \expandafter\@firstoftwo
  118. \else
  119. \expandafter\@secondoftwo
  120. \fi
  121. }
  122. {\@secondoftwo}%
  123. }% <<<
  124. \newcommand\MRTsfacc@testnest@[5]% >>>
  125. {%
  126. \MRTsfacc@testknown{#5}
  127. {%
  128. \gdef\MRTsfacc@known{#5}%
  129. \global\@MRTsfacc@found@known@true
  130. }
  131. {%
  132. \MRTifTwoTokenTF{#5}
  133. {%
  134. \expandafter\MRTsfacc@mathaccentV@using\expandafter{\@firstoftwo#5}%
  135. {\@firstoftwo}
  136. {\@secondoftwo}%
  137. }
  138. {\@secondoftwo}%
  139. {%
  140. #5%
  141. }
  142. {%
  143. \global\@MRTsfacc@found@known@false
  144. }%
  145. }%
  146. }% <<<
  147. % stupid package for math font is stupid. Have to cure the sickness >>>
  148. \if@MRTsfacc@height@
  149. % true >>>
  150. \newcommand*\MRTsfacc@patch@mathaccentV% >>>
  151. {%
  152. \protected\long\def\mathaccentV##1##2##3##4% >>>
  153. {%
  154. \ifmmode
  155. \def\mathaccentV@args{{##1}{##2}{##3}{##4}}%
  156. \expandafter\@firstofone
  157. \else
  158. \@xp\nonmatherr@\csname ##1\endcsname
  159. \expandafter\@gobble
  160. \fi
  161. {\futurelet\next\mathaccentV@a}%
  162. }% <<<
  163. }% <<<
  164. \newcommand*\MRTsfacc@kern% >>>
  165. {%
  166. \MRTsfacc@shift\ht\MRTsfacc@box
  167. }% <<<
  168. \newbox\MRTsfacc@box
  169. \newcommand*\mathaccentV@a[1]% >>>
  170. {%
  171. \expandafter\ifx\next!%
  172. \expandafter\@firstofthree
  173. \else
  174. \expandafter\ifx\next*%
  175. \expandafter\expandafter\expandafter\@secondofthree
  176. \else
  177. \expandafter\expandafter\expandafter\@thirdofthree
  178. \fi
  179. \fi
  180. {\expandafter\MRTsfacc@mathaccentV\mathaccentV@args}
  181. {\expandafter\mathaccentV@shifted\mathaccentV@args}
  182. {\expandafter\mathaccentV@b\mathaccentV@args{#1}}%
  183. }% <<<
  184. \newcommand*\mathaccentV@b[5]% >>>
  185. {%
  186. \MRTifLetterGTF{#5}
  187. {\mathaccentV@shifted{#1}{#2}{#3}{#4}{#5}}
  188. {%
  189. \MRTsfacc@testnest\MRTifLetterGTF{#5}
  190. {\mathaccentV@shifted{#1}{#2}{#3}{#4}{#5}}
  191. {\MRTsfacc@mathaccentV{#1}{#2}{#3}{#4}{#5}}%
  192. }%
  193. }% <<<
  194. \newcommand*\mathaccentV@shifted[5]% >>>
  195. {%
  196. \mathchoice
  197. {\mathaccentV@shifted@a{display}{#1}{#2}{#3}{#4}{#5}}
  198. {\mathaccentV@shifted@a{text}{#1}{#2}{#3}{#4}{#5}}
  199. {\mathaccentV@shifted@a{script}{#1}{#2}{#3}{#4}{#5}}
  200. {\mathaccentV@shifted@a{scriptscript}{#1}{#2}{#3}{#4}{#5}}%
  201. }% <<<
  202. \newcommand*\mathaccentV@shifted@a[6]% >>>
  203. {%
  204. \setbox\MRTsfacc@box\hbox{$\csname #1style\endcsname#6$}%
  205. \MRTsfacc@mathaccentV{#2}{#3}{#4}{#5}%
  206. {%
  207. #6%
  208. \kern\MRTsfacc@kern
  209. }%
  210. \kern-\MRTsfacc@kern
  211. }% <<<
  212. \else% <<<
  213. % false >>>
  214. \newcommand*\MRTsfacc@patch@mathaccentV% >>>
  215. {%
  216. \protected\def\mathaccentV##1##2##3##4% >>>
  217. {%
  218. \ifmmode
  219. \expandafter\@firstofone
  220. \else
  221. \@xp\nonmatherr@\csname ##1\endcsname
  222. \expandafter\@gobble
  223. \fi
  224. {%
  225. \@ifnextchar[%]
  226. {\mathaccentV@b{##1}{##2}{##3}{##4}}
  227. {\mathaccentV@a{##1}{##2}{##3}{##4}}%
  228. }%
  229. }% <<<
  230. }% <<<
  231. \newcommand*\MRTsfacc@ifknown[1]% >>>
  232. {%
  233. \ifcsname\MRTsfacc@shift{#1}\endcsname
  234. \expandafter\@firstoftwo
  235. \else
  236. \expandafter\@secondoftwo
  237. \fi
  238. }% <<<
  239. \newcommand*\MRTsfacc@mathaccentV@shifted@expandhelper[6]% >>>
  240. {%
  241. \mathaccentV@shifted{#2}{#3}{#4}{#5}
  242. {\csname\MRTsfacc@shift{#1}\endcsname}{#6}%
  243. }% <<<
  244. \newcommand\mathaccentV@a[5]% >>>
  245. {%
  246. \MRTsfacc@ifknown{#5}
  247. {%
  248. \mathaccentV@shifted{#1}{#2}{#3}{#4}
  249. {\csname\MRTsfacc@shift{#5}\endcsname}{#5}%
  250. }%
  251. {%
  252. \MRTsfacc@testnest\MRTsfacc@ifknown{#5}
  253. {%
  254. \expandafter\MRTsfacc@mathaccentV@shifted@expandhelper\expandafter
  255. {\MRTsfacc@known}{#1}{#2}{#3}{#4}{#5}%
  256. }
  257. {\MRTsfacc@mathaccentV{#1}{#2}{#3}{#4}{#5}}%
  258. }%
  259. }% <<<
  260. \long\def\mathaccentV@b#1#2#3#4[#5]#6% >>>
  261. {%
  262. \MRTsfacc@ifknown{#5}
  263. {%
  264. \mathaccentV@shifted{#1}{#2}{#3}{#4}
  265. {\csname\MRTsfacc@shift{#5}\endcsname}{#6}%
  266. }
  267. {\mathaccentV@shifted{#1}{#2}{#3}{#4}{#5}{#6}}%
  268. }% <<<
  269. \newcommand\mathaccentV@shifted[6]% >>>
  270. {%
  271. \MRTsfacc@mathaccentV{#1}{#2}{#3}{#4}
  272. {%
  273. #6%
  274. \mkern#5\relax
  275. }
  276. \mkern-#5\relax
  277. }% <<<
  278. \renewcommand*\MRTsfacc@shift[1]% >>>
  279. {%
  280. MRTsfacc@shift@\detokenize{#1}%
  281. }% <<<
  282. \newcommand*\MRTsfaccShift[2]% >>>
  283. {%
  284. \expandafter\def\csname MRTsfacc@shift@\detokenize{#1}\endcsname{#2}%
  285. }% <<<
  286. \newcommand*\MRTsfaccShiftLet[2]% >>>
  287. {%
  288. \MRTsfacc@ifknown{#2}
  289. {%
  290. \expandafter\MRTsfaccShiftLet@a\csname\MRTsfacc@shift{#2}\endcsname
  291. {#1}%
  292. }
  293. {%
  294. \PackageError{MRTsfacc}{No shift defined for `\detokenize{#2}`.}
  295. {%
  296. You have to use an already defined shift as second argument for
  297. \string\MRTsfaccShiftLet.
  298. }%
  299. }%
  300. }% <<<
  301. \newcommand*\MRTsfaccShiftLet@a[2]% >>>
  302. {%
  303. \expandafter\let\csname\MRTsfacc@shift{#2}\endcsname#1%
  304. }% <<<
  305. \newcommand*\MRTsfaccLoadShiftList[1]% >>>
  306. {%
  307. \input{MRTsfacc.list.#1.tex}%
  308. }% <<<
  309. % <<<
  310. \fi
  311. % <<<
  312. \AtBeginDocument{\MRTsfacc@patch@mathaccentV}
  313. \endinput