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.

MRTutil.sty 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. \newcommand*\MRTutil@version{0.0.5}
  2. \newcommand*\MRTutil@date{2019-04-07}
  3. \NeedsTeXFormat{LaTeX2e}
  4. \ProvidesPackage{MRTutil}
  5. [%
  6. \MRTutil@date\space v\MRTutil@version\space provides some utility macros for
  7. the MRTbundle%
  8. ]
  9. %% def macros >>=
  10. \@ifdefinable\MRTutil@def@%>>=
  11. {%
  12. \protected\def\MRTutil@def@#1%
  13. {\@ifnextchar[{\MRTutil@def@a#1}{\MRTutil@def@a#1[]}}%
  14. }%=<<
  15. \@ifdefinable\MRTutil@def@a%>>=
  16. {%
  17. \long\def\MRTutil@def@a#1[#2]#3#4#{\MRTutil@def@b#1{#2}#3{#4}}%
  18. }%=<<
  19. \@ifdefinable\MRTutil@def@b%>>=
  20. {%
  21. \protected\long\def\MRTutil@def@b#1#2#3#4#5{\@ifdefinable#3{#2#1#3#4{#5}}}%
  22. }%=<<
  23. \@ifdefinable\MRTutil@def%>>=
  24. {%
  25. \protected\def\MRTutil@def{\MRTutil@def@\def}
  26. }%=<<
  27. \MRTutil@def[\protected]\MRTutil@edef%>>=
  28. {%
  29. \MRTutil@def@\edef
  30. }%=<<
  31. % =<<
  32. %% opt arg parsing >>=
  33. % Definition of MRTutil@@mark >>=
  34. \begingroup
  35. \lccode`\M=`\M \lccode`\R=`\R \lccode`\T=`\T
  36. \lccode`\:=`\M \lccode`\;=`\_ \lccode`\A=`\-
  37. \lccode`\*=`\F
  38. \lowercase
  39. {%
  40. \endgroup
  41. \MRTutil@def\MRTutil@@mark{AMRTutil;:ark-}%
  42. \MRTutil@def\MRTutil@@false{AMRTutil;*alse-}%
  43. }
  44. % =<<
  45. \MRTutil@def[\long]\MRTutil@@fiBTb\fi#1#2#3{\fi#2}
  46. \MRTutil@def[\long]\MRTutil@ifmark#1%>>=
  47. {%
  48. \ifx\MRTutil@@mark#1%
  49. \MRTutil@@fiBTb
  50. \fi
  51. \@secondoftwo
  52. }%=<<
  53. \MRTutil@def[\protected\long]\MRTutil@defOarg#1#2#3%>>=
  54. {%
  55. \MRTutil@edef[\protected\long]#1##1##2%
  56. {%
  57. \noexpand\@ifnextchar#2%
  58. {\expandafter\noexpand\csname\string#1\endcsname{##2}}
  59. {##2{##1}}%
  60. }%
  61. \expandafter\MRTutil@def\expandafter[\expandafter\long\expandafter]%
  62. \csname\string#1\endcsname##1#2##2#3{##1{##2}}%
  63. }%=<<
  64. \MRTutil@def[\protected\long]\MRTutil@defoarg#1#2#3%>>=
  65. {%
  66. \MRTutil@edef[\protected\long]#1##1%
  67. {%
  68. \noexpand\@ifnextchar#2%
  69. {\expandafter\noexpand\csname\string#1\endcsname{##1}}
  70. {##1{\noexpand\MRTutil@@mark}}%
  71. }%
  72. \expandafter\MRTutil@def\expandafter[\expandafter\long\expandafter]%
  73. \csname\string#1\endcsname##1#2##2#3{##1{##2}}%
  74. }%=<<
  75. \MRTutil@def[\protected\long]\MRTutil@defOargpair#1#2#3#4%>>=
  76. {%
  77. \MRTutil@defOarg#1#3#4%
  78. \MRTutil@edef[\protected\long]#2##1%
  79. {%
  80. \noexpand\@ifnextchar#3%
  81. {\expandafter\noexpand\csname\string#1\endcsname{##1}}
  82. {##1{\noexpand\MRTutil@@mark}}%
  83. }%
  84. }%=<<
  85. \MRTutil@defOargpair\MRTutil@Oarg\MRTutil@oarg[]
  86. \MRTutil@def[\protected\long]\MRTutil@Darg#1#2#3#4%>>=
  87. {%
  88. \long\def\MRTutil@Darg@##1#1##2#2{##1{##2}}%
  89. \@ifnextchar#1{\MRTutil@Darg@{#4}}{#4{#3}}%
  90. }%=<<
  91. \MRTutil@def[\protected\long]\MRTutil@darg#1#2%>>=
  92. {%
  93. \MRTutil@Darg#1#2\MRTutil@@mark
  94. }%=<<
  95. \MRTutil@def[\protected\long]\MRTutil@Earg#1#2#3%>>=
  96. {%
  97. \@ifnextchar#1{\MRTutil@Earg@{#3}}{#3{#2}}%
  98. }%=<<
  99. \MRTutil@def[\protected\long]\MRTutil@Earg@#1%>>=
  100. {%
  101. \def\MRTutil@Earg@@{#1}%
  102. \afterassignment\MRTutil@Earg@@
  103. \let\MRTutil@gobbled=%
  104. }%=<<
  105. \MRTutil@def[\protected\long]\MRTutil@earg#1%>>=
  106. {%
  107. \MRTutil@Earg#1\MRTutil@@mark
  108. }%=<<
  109. \MRTutil@def[\protected\long]\MRTutil@targ#1#2%>>=
  110. {%
  111. \@ifnextchar#1{\MRTutil@targ@{#2}}{#2{\MRTutil@@false}}%
  112. }%=<<
  113. \MRTutil@def[\protected\long]\MRTutil@targ@#1%>>=
  114. {%
  115. \def\MRTutil@targ@@{#1{\MRTutil@@mark}}%
  116. \afterassignment\MRTutil@targ@@
  117. \let\MRTutil@gobbled=%
  118. }%=<<
  119. % =<<
  120. \endinput
  121. % vim: ft=tex fdm=marker fmr=>>=,=<< sw=2 ts=2 tw=80