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.

MRTif.sty 28KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  1. \newcommand*\MRTif@version{0.0.16}
  2. \newcommand*\MRTif@date{2020-10-28}
  3. \NeedsTeXFormat{LaTeX2e}
  4. \ProvidesPackage{MRTif}%
  5. [%
  6. \MRTif@date\space v\MRTif@version\space some if tests originally for MRTbeam
  7. and mrtarbeit%
  8. ]
  9. \RequirePackage{pdftexcmds,MRTutil}
  10. \long\def\@firstofthree#1#2#3{#1}
  11. \long\def\@secondofthree#1#2#3{#2}
  12. \long\def\@thirdofthree#1#2#3{#3}
  13. % MRTif@fi macros >>=
  14. \long\def\MRTif@fiAy#1\fi#2{\fi#2}
  15. \long\def\MRTif@fiAn#1\fi#2{\fi}
  16. \long\def\MRTif@fiAa#1\fi#2#3{\fi#2}
  17. \long\def\MRTif@fiAb#1\fi#2#3{\fi#3}
  18. \long\def\MRTif@fiBy\fi#1{\fi#1}
  19. \long\def\MRTif@fiBn\fi#1{\fi}
  20. \long\def\MRTif@fiBa\fi#1#2{\fi#1}
  21. \long\def\MRTif@fiBb\fi#1#2{\fi#2}
  22. \long\def\MRTif@fiBg\fi#1#2{\fi}
  23. \long\def\MRTif@fiBTa\fi#1#2#3{\fi#1}
  24. \long\def\MRTif@fiBTb\fi#1#2#3{\fi#2}
  25. \long\def\MRTif@fiBTc\fi#1#2#3{\fi#3}
  26. \long\def\MRTif@fiBTg\fi#1#2#3{\fi}
  27. \long\def\MRTif@fifiAa#1\fi\fi#2#3{\fi#2}
  28. \long\def\MRTif@fifiAb#1\fi\fi#2#3{\fi#3}
  29. \long\def\MRTif@fifiATa#1\fi\fi#2#3#4{\fi#2}
  30. \long\def\MRTif@fifiBAa#1\fi\fi#2#3{\fi\fi#2}
  31. \long\def\MRTif@fifiBAb#1\fi\fi#2#3{\fi\fi#3}
  32. \long\def\MRTif@fifiBATb#1\fi\fi#2#3#4{\fi\fi#3}
  33. \long\def\MRTif@fifiBBa\fi\fi#1#2{\fi\fi#1}
  34. \long\def\MRTif@fifiBBb\fi\fi#1#2{\fi\fi#2}
  35. \long\def\MRTif@fifiBBTc\fi\fi#1#2#3{\fi\fi#3}
  36. \long\def\MRTif@fi@gobble\fi\@firstofone#1{\fi}
  37. \long\def\MRTif@fi@firstofone\fi\@gobble#1{\fi#1}
  38. \long\def\MRTif@fi@firstoftwo\fi\@secondoftwo#1#2{\fi#1}
  39. \long\def\MRTif@fi@secondoftwo\fi\@firstoftwo#1#2{\fi#2}
  40. \long\def\MRTif@fifi@secondoftwo\fi\fi\@firstoftwo#1#2{\fi\fi#2}
  41. % =<<
  42. % Definition of \endMRTif@argument >>=
  43. \begingroup
  44. \catcode`\.=11
  45. \catcode`\ =11
  46. \@firstofone{\endgroup\def\endMRTif@argument{\MRTif Error. Please report.}}
  47. % =<<
  48. \MRTutil@def[\long]\MRTif@endMRTif@argument#1% >>=
  49. {%
  50. \ifx\endMRTif@argument#1%
  51. \MRTif@fi@firstoftwo
  52. \fi
  53. \@secondoftwo
  54. }% =<<
  55. % switch to catcode and lccode regime of ifEmpty >>=
  56. % Since the routine of MRTifEmpty is pretty performant, it is a good idea to
  57. % reuse parts of it in other macros which can be reduced to an ifEmpty test with
  58. % one or two expansions, hence we use this macro to unify the regimes of those
  59. % tests.
  60. \MRTutil@def[\protected]\MRTif@specialLowercase%>>=
  61. {%
  62. \begingroup
  63. \lccode`\Q=127
  64. \lccode`\*=127
  65. \MRTif@specialLowercase@
  66. }%=<<
  67. \MRTutil@def[\protected\long]\MRTif@specialLowercase@#1%>>=
  68. {%
  69. \lowercase{\endgroup#1}%
  70. }%=<<
  71. %=<<
  72. % CreateBranchingIfs >>=
  73. \MRTutil@def[\protected\long]\MRTifCreateBranchingIfs#1#2#3#4%>>=
  74. {%
  75. \def\MRTif@cbi@args##1#3##2\endMRTif@argument{##1#3}%
  76. \expandafter\MRTif@cbi@a\expandafter
  77. {\MRTif@cbi@args 0##1##2##3##4##5##6##7##8##9\endMRTif@argument}
  78. {#4}{#1}#2,\endMRTif@argument=\endMRTif@argument,%
  79. }%=<<
  80. \MRTutil@def[\protected]\MRTif@cbi@a#1%>>=
  81. {%
  82. \expandafter\MRTif@cbi@b\expandafter{\@gobble#1}%
  83. }%=<<
  84. \MRTutil@def[\long]\MRTif@cbi@b#1#2#3#4=#5,%>>=
  85. {%
  86. \ifx\endMRTif@argument#4%
  87. \MRTif@fi@gobble
  88. \fi
  89. \@firstofone
  90. {%
  91. \@ifundefined{MRTif@cbi@def@#5}
  92. {%
  93. \PackageError{MRTif}
  94. {%
  95. \string\MRTifCreateBranchingIfs\space Error:
  96. Unknown branching variant '#5', skipping definition of
  97. '\expandafter\@gobble\string\\#3#4'%
  98. }
  99. {}%
  100. }
  101. {%
  102. \csname MRTif@cbi@def@#5\expandafter\endcsname\csname #3#4\endcsname
  103. {#1}{#2}%
  104. }%
  105. \MRTif@cbi@b{#1}{#2}{#3}%
  106. }%
  107. }%=<<
  108. \MRTutil@def[\long]\MRTif@cbi@def@common#1#2#3#4#5%>>=
  109. {%
  110. \MRTutil@def[\long]#3#4{#5#1\fi#2}%
  111. }%=<<
  112. \MRTutil@def\MRTif@cbi@def@ab%>>=
  113. {\MRTif@cbi@def@common\MRTif@fi@firstoftwo\@secondoftwo}%=<<
  114. \MRTutil@def\MRTif@cbi@def@ba%>>=
  115. {\MRTif@cbi@def@common\MRTif@fi@secondoftwo\@firstoftwo}%=<<
  116. \MRTutil@def\MRTif@cbi@def@yn%>>=
  117. {\MRTif@cbi@def@common\MRTif@fi@firstofone\@gobble}%=<<
  118. \MRTutil@def\MRTif@cbi@def@ny%>>=
  119. {\MRTif@cbi@def@common\MRTif@fi@gobble\@firstofone}%=<<
  120. % =<<
  121. \MRTutil@def\MRTif@groupify@TF#1% >>=
  122. {%
  123. \long\expandafter\edef\csname MRTif#1GTF\endcsname##1%
  124. {%
  125. \unexpanded{\MRTifGroupTF}{##1}%
  126. {\unexpanded\expandafter{\csname MRTif#1GTF\endcsname}##1}%
  127. {\unexpanded\expandafter{\csname MRTif#1TF\endcsname}{##1}}%
  128. }%
  129. }% =<<
  130. \MRTutil@def\MRTif@create@TandF#1% >>=
  131. {%
  132. \long\expandafter\edef\csname MRTif#1T\endcsname##1%
  133. {%
  134. \unexpanded\expandafter{\csname MRTif#1TF\endcsname}{##1}%
  135. \unexpanded{\@firstofone\@gobble}%
  136. }%
  137. \long\expandafter\edef\csname MRTif#1F\endcsname##1%
  138. {%
  139. \unexpanded\expandafter{\csname MRTif#1TF\endcsname}{##1}%
  140. \unexpanded{\@gobble\@firstofone}%
  141. }%
  142. }% =<<
  143. \MRTutil@def\MRTif@create@TandF@twoargs#1% >>=
  144. {%
  145. \long\expandafter\edef\csname MRTif#1T\endcsname##1##2%
  146. {%
  147. \unexpanded\expandafter{\csname MRTif#1TF\endcsname}{##1}{##2}%
  148. \unexpanded{\@firstofone\@gobble}%
  149. }%
  150. \long\expandafter\edef\csname MRTif#1F\endcsname##1##2%
  151. {%
  152. \unexpanded\expandafter{\csname MRTif#1TF\endcsname}{##1}{##2}%
  153. \unexpanded{\@gobble\@firstofone}%
  154. }%
  155. }% =<<
  156. \MRTutil@def\MRTif@create@N@TandF#1% >>=
  157. {%
  158. \long\expandafter\edef\csname MRTif#1NTF\endcsname##1%
  159. {%
  160. \unexpanded{\expandafter}%
  161. \unexpanded\expandafter{\csname MRTif#1TF\endcsname\expandafter}%
  162. {##1}%
  163. }%
  164. \MRTif@create@TandF{#1N}%
  165. }% =<<
  166. \MRTutil@def[\long]\MRTif@NN@helper#1#2#3%>>=
  167. {%
  168. \expandafter#3\expandafter{#2}{#1}%
  169. }%=<<
  170. \MRTutil@def[\long]\MRTif@nN@helper#1#2#3%>>=
  171. {%
  172. #3{#2}{#1}%
  173. }%=<<
  174. \MRTutil@def\MRTif@create@N@TandF@twoargs#1% >>=
  175. {%
  176. \long\expandafter\edef\csname MRTif#1NNTF\endcsname##1##2%
  177. {%
  178. \unexpanded{\expandafter\MRTif@NN@helper\expandafter}%
  179. {##2}{##1}%
  180. \unexpanded\expandafter{\csname MRTif#1TF\endcsname}%
  181. }%
  182. \MRTif@create@TandF@twoargs{#1NN}%
  183. \long\expandafter\edef\csname MRTif#1NnTF\endcsname##1##2%
  184. {%
  185. \unexpanded{\expandafter}%
  186. \unexpanded\expandafter{\csname MRTif#1TF\endcsname\expandafter}%
  187. {##1}{##2}%
  188. }%
  189. \MRTif@create@TandF@twoargs{#1Nn}%
  190. \long\expandafter\edef\csname MRTif#1nNTF\endcsname##1##2%
  191. {%
  192. \unexpanded{\expandafter\MRTif@nN@helper\expandafter}%
  193. {##2}{##1}%
  194. \unexpanded\expandafter{\csname MRTif#1TF\endcsname}%
  195. }%
  196. \MRTif@create@TandF@twoargs{#1nN}%
  197. }% =<<
  198. \MRTutil@def\MRTif@create@TandF@N@TandF#1% >>=
  199. {%
  200. \MRTif@create@TandF{#1}%
  201. \MRTif@create@N@TandF{#1}%
  202. }% =<<
  203. \MRTutil@def\MRTif@create@TandF@N@TandF@twoargs#1% >>=
  204. {%
  205. \MRTif@create@TandF@twoargs{#1}%
  206. \MRTif@create@N@TandF@twoargs{#1}%
  207. }% =<<
  208. \MRTutil@def[\long]\MRTif@notEmpty@noGroup@noSpace#1#2% >>=
  209. {%
  210. \MRTifEmptyTF{#1}
  211. {\@secondoftwo}
  212. {%
  213. \MRTifContainsSpaceTF{#1}
  214. {\@secondoftwo}
  215. {%
  216. \MRTifContainsGroupTF{#1}
  217. {\@secondoftwo}
  218. {#2}%
  219. }%
  220. }%
  221. }% =<<
  222. % MRTifMathMode >>=
  223. \MRTutil@def\MRTifMathModeTF{\ifmmode\MRTif@fi@firstoftwo\fi\@secondoftwo}
  224. \MRTutil@def\MRTifMathModeT{\ifmmode\MRTif@fi@firstofone\fi\@gobble}
  225. \MRTutil@def\MRTifMathModeF{\ifmmode\MRTif@fi@gobble\fi\@firstofone}
  226. % =<<
  227. % MRTifEmpty >>=
  228. % obfuscated but *fast* ifempty, slightly less robust
  229. \MRTif@specialLowercase{%
  230. \MRTutil@def[\long]\MRTifEmpty@true@T*Q\@gobble#1{#1}
  231. \MRTutil@def[\long]\MRTifEmpty@true@F*Q\@firstofone#1{}
  232. \MRTutil@def[\long]\MRTifEmpty@true@TF*Q\@secondoftwo#1#2{#1}
  233. \MRTutil@def[\long]\MRTifEmpty@true@FT*Q\@firstoftwo#1#2{#2}
  234. \MRTutil@def[\long]\MRTifEmpty@#1*Q{}
  235. \MRTutil@def\MRTifEmpty@e{\MRTifEmpty@*}
  236. % standard version >>=
  237. \MRTutil@def[\long]\MRTifEmptyTF#1%
  238. {\MRTifEmpty@*#1Q\MRTifEmpty@true@TF*Q\@secondoftwo}
  239. \MRTutil@def[\long]\MRTifEmptyT#1%
  240. {\MRTifEmpty@*#1Q\MRTifEmpty@true@T*Q\@gobble}
  241. \MRTutil@def[\long]\MRTifEmptyF#1%
  242. {\MRTifEmpty@*#1Q\MRTifEmpty@true@F*Q\@firstofone}
  243. % =<<
  244. % N-version >>=
  245. \MRTutil@def[\long]\MRTifEmptyNTF#1%
  246. {\expandafter\MRTifEmpty@e#1Q\MRTifEmpty@true@TF*Q\@secondoftwo}
  247. \MRTutil@def[\long]\MRTifEmptyNT#1%
  248. {\expandafter\MRTifEmpty@e#1Q\MRTifEmpty@true@T*Q\@gobble}
  249. \MRTutil@def[\long]\MRTifEmptyNF#1%
  250. {\expandafter\MRTifEmpty@e#1Q\MRTifEmpty@true@F*Q\@firstofone}
  251. % =<<
  252. }
  253. \MRTif@groupify@TF{Empty}
  254. \MRTif@create@TandF@N@TandF{EmptyG}
  255. % =<<
  256. % MRTifBlank >>=
  257. % obfuscated but *fast* ifblank, reuses internals of ifEmpty
  258. \MRTif@specialLowercase{%
  259. \MRTutil@def[\long]\MRTifBlank@#1{\MRTifEmpty@*}
  260. % standard version >>=
  261. \MRTutil@def[\long]\MRTifBlankTF#1%
  262. {\MRTifBlank@#1.Q\MRTifEmpty@true@TF*Q\@secondoftwo}
  263. \MRTutil@def[\long]\MRTifBlankT#1%
  264. {\MRTifBlank@#1.Q\MRTifEmpty@true@T*Q\@gobble}
  265. \MRTutil@def[\long]\MRTifBlankF#1%
  266. {\MRTifBlank@#1.Q\MRTifEmpty@true@F*Q\@firstofone}
  267. % =<<
  268. % N-version >>=
  269. \MRTutil@def[\long]\MRTifBlankNTF#1%
  270. {\expandafter\MRTifBlank@#1.Q\MRTifEmpty@true@TF*Q\@secondoftwo}
  271. \MRTutil@def[\long]\MRTifBlankNT#1%
  272. {\expandafter\MRTifBlank@#1.Q\MRTifEmpty@true@T*Q\@gobble}
  273. \MRTutil@def[\long]\MRTifBlankNF#1%
  274. {\expandafter\MRTifBlank@#1.Q\MRTifEmpty@true@F*Q\@firstofone}
  275. % =<<
  276. }
  277. \MRTif@groupify@TF{Blank}
  278. \MRTif@create@TandF@N@TandF{BlankG}
  279. % =<<
  280. % MRTifGroup >>=
  281. \MRTutil@def[\long]\MRTifGroupTF#1% >>=
  282. {%
  283. \MRTifGroup@a#1.{}\MRTifGroup@endargument
  284. }% =<<
  285. \long\def\MRTifGroup@a#1#% >>=
  286. {%
  287. \MRTifBlankTF{#1}{\MRTifGroup@b}{\MRTifGroup@c}%
  288. }% =<<
  289. \long\def\MRTifGroup@b#1#2#3\MRTifGroup@endargument% >>=
  290. {%
  291. \MRTifEmptyTF{#3}%
  292. }% =<<
  293. \long\def\MRTifGroup@c#1\MRTifGroup@endargument#2#3% >>=
  294. {%
  295. #3%
  296. }% =<<
  297. \MRTutil@def[\long]\MRTifGroupNTF#1% >>=
  298. {%
  299. \expandafter\MRTifGroup@a#1.{}\MRTifGroup@endargument
  300. }% =<<
  301. \MRTif@create@TandF{Group}
  302. \MRTif@create@TandF{GroupN}
  303. % =<<
  304. % MRTifGroupNoSpaces >>=
  305. % reuses internals of ifGroup
  306. \MRTutil@def[\long]\MRTifGroupNoSpacesTF#1%>>=
  307. {%
  308. \MRTifGroupNoSpaces@a
  309. #1\MRTifGroupNoSpaces@endargument{}\MRTifGroup@endargument
  310. }%=<<
  311. \MRTutil@def[\long]\MRTifGroupNoSpaces@a#1#%>>=
  312. {%
  313. \MRTifEmptyTF{#1}\MRTifGroupNoSpaces@b\MRTifGroup@c
  314. }%=<<
  315. \MRTutil@def[\long]\MRTifGroupNoSpaces@b%>>=
  316. #1#2\MRTifGroupNoSpaces@endargument#3\MRTifGroup@endargument
  317. {%
  318. \MRTifEmptyTF{#2}%
  319. }%=<<
  320. \MRTutil@def[\long]\MRTifGroupNoSpacesNTF#1%>>=
  321. {%
  322. \expandafter\MRTifGroupNoSpaces@a
  323. #1\MRTifGroupNoSpaces@endargument{}\MRTifGroup@endargument
  324. }%=<<
  325. \MRTutil@def\MRTifGroupNoSpaces@endargument%>>=
  326. % have to define this because it might get expanded by \expandafter
  327. {\MRTifGroupNoSpaces@endargument}%=<<
  328. \MRTif@create@TandF{GroupNoSpaces}
  329. \MRTif@create@TandF{GroupNoSpacesN}
  330. % =<<
  331. % MRTifStringsMatch >>=
  332. \MRTifCreateBranchingIfs{MRTifStringsMatch}{TF=ab,T=yn,F=ny}{2}
  333. {\ifnum\pdf@strcmp{\detokenize{#1}}{\detokenize{#2}}=0 }
  334. \MRTutil@def[\long]\MRTifStringsMatchGTF#1#2% >>=
  335. {%
  336. \MRTifGroupTF{#1}
  337. {\MRTifStringsMatchGTF#1{#2}}
  338. {%
  339. \MRTifGroupTF{#2}
  340. {\MRTifStringsMatchGTF#2{#1}}
  341. {\MRTifStringsMatchTF{#1}{#2}}
  342. }%
  343. }% =<<
  344. \MRTif@create@N@TandF@twoargs{StringsMatch}
  345. \MRTif@create@TandF@N@TandF@twoargs{StringsMatchG}
  346. % =<<
  347. % MRTifStringsMatchXX >>=
  348. \MRTifCreateBranchingIfs{MRTifStringsMatchXX}{TF=ab,T=yn,F=ny}{2}
  349. {\ifnum\pdf@strcmp{#1}{#2}=0 }
  350. \MRTutil@def[\long]\MRTifStringsMatchXXGTF#1#2% >>=
  351. {%
  352. \MRTifGroupTF{#1}
  353. {\MRTifStringsMatchXXGTF#1{#2}}
  354. {%
  355. \MRTifGroupTF{#2}
  356. {\MRTifStringsMatchXXGTF#2{#1}}
  357. {\MRTifStringsMatchXXTF{#1}{#2}}%
  358. }%
  359. }% =<<
  360. \MRTif@create@TandF@twoargs{StringsMatchXXG}
  361. % =<<
  362. % MRTifOneToken >>=
  363. % obfuscated but *fast* ifonetoken, reuses internals of ifEmpty and ifBlank
  364. \MRTif@specialLowercase{%
  365. % this is actually a bit ingenious. If it's one token that token is gobbled by
  366. % \MRTifBlank@ and the remains will be empty, if it's no token then \MRTifBlank@
  367. % gobbles the 'Q' and the \MRTifEmpty internals will execute the false branch,
  368. % if there are more than one token the \MRTifEmpty internals will again use the
  369. % false branch.
  370. % standard version >>=
  371. \MRTutil@def[\long]\MRTifOneTokenTF#1%
  372. {\MRTifBlank@#1Q\MRTifEmpty@true@TF*Q\@secondoftwo}
  373. \MRTutil@def[\long]\MRTifOneTokenT#1%
  374. {\MRTifBlank@#1Q\MRTifEmpty@true@T*Q\@gobble}
  375. \MRTutil@def[\long]\MRTifOneTokenF#1%
  376. {\MRTifBlank@#1Q\MRTifEmpty@true@F*Q\@firstofone}
  377. % =<<
  378. % N-version >>=
  379. \MRTutil@def[\long]\MRTifOneTokenNTF#1%
  380. {\expandafter\MRTifBlank@#1Q\MRTifEmpty@true@TF*Q\@secondoftwo}
  381. \MRTutil@def[\long]\MRTifOneTokenNT#1%
  382. {\expandafter\MRTifBlank@#1Q\MRTifEmpty@true@T*Q\@gobble}
  383. \MRTutil@def[\long]\MRTifOneTokenNF#1%
  384. {\expandafter\MRTifBlank@#1Q\MRTifEmpty@true@F*Q\@firstofone}
  385. % =<<
  386. }
  387. \MRTif@groupify@TF{OneToken}
  388. \MRTif@create@TandF@N@TandF{OneTokenG}
  389. % =<<
  390. % MRTifOneTokenNoGroup>>=
  391. \MRTutil@def[\long]\MRTifOneTokenNoGroupTF#1% >>=
  392. {%
  393. \MRTifOneTokenTF{#1}
  394. {\MRTifContainsGroupT{#1}\@thirdofthree\@firstoftwo}%
  395. {\@secondoftwo}%
  396. }% =<<
  397. \MRTif@create@TandF@N@TandF{OneTokenNoGroup}
  398. % =<<
  399. % MRTifTwoToken >>=
  400. % obfuscated but *fast* iftwotoken, reuses internals of ifEmpty
  401. \MRTif@specialLowercase{%
  402. % same idea as for MRTifOneToken, but this time we gobble two tokens before
  403. % giving control to the ifEmpty internals, only notably different scenario: if
  404. % the argument is blank not only Q but also \MRTifEmpty@true@.. will be gobbled,
  405. % but that does no harm.
  406. \MRTutil@def[\long]\MRTifTwoToken@#1#2{\MRTifEmpty@*}
  407. % standard version >>=
  408. \MRTutil@def[\long]\MRTifTwoTokenTF#1%
  409. {\MRTifTwoToken@#1Q\MRTifEmpty@true@TF*Q\@secondoftwo}
  410. \MRTutil@def[\long]\MRTifTwoTokenT#1%
  411. {\MRTifTwoToken@#1Q\MRTifEmpty@true@T*Q\@gobble}
  412. \MRTutil@def[\long]\MRTifTwoTokenF#1%
  413. {\MRTifTwoToken@#1Q\MRTifEmpty@true@F*Q\@firstofone}
  414. % =<<
  415. % N-version >>=
  416. \MRTutil@def[\long]\MRTifTwoTokenNTF#1%
  417. {\expandafter\MRTifTwoToken@#1Q\MRTifEmpty@true@TF*Q\@secondoftwo}
  418. \MRTutil@def[\long]\MRTifTwoTokenNT#1%
  419. {\expandafter\MRTifTwoToken@#1Q\MRTifEmpty@true@T*Q\@gobble}
  420. \MRTutil@def[\long]\MRTifTwoTokenNF#1%
  421. {\expandafter\MRTifTwoToken@#1Q\MRTifEmpty@true@F*Q\@firstofone}
  422. % =<<
  423. }
  424. \MRTif@groupify@TF{TwoToken}
  425. \MRTif@create@TandF@N@TandF{TwoTokenG}
  426. % =<<
  427. % MRTifNumToken>>=
  428. \MRTifCreateBranchingIfs{MRTifNumToken}{TF=ab,T=yn,F=ny}{2}%>>=
  429. {\ifnum#1=\MRTtllength{#2} }%=<<
  430. \MRTifCreateBranchingIfs{MRTifNumTokenN}{TF=ab,T=yn,F=ny}{2}%>>=
  431. {\ifnum#1=\MRTtllengthN{#2} }%=<<
  432. \MRTifCreateBranchingIfs{MRTifNumTokenS}{TF=ab,T=yn,F=ny}{2}%>>=
  433. {\ifnum#1=\MRTtllengthS{#2} }%=<<
  434. \MRTifCreateBranchingIfs{MRTifNumTokenSN}{TF=ab,T=yn,F=ny}{2}%>>=
  435. {\ifnum#1=\MRTtllengthSN{#2} }%=<<
  436. \MRTutil@def[\long]\MRTifNumTokenG@common#1#2#3%>>=
  437. {%
  438. \MRTifGroupTF{#3}
  439. {\MRTifNumTokenG@common#1{#2}#3}
  440. {#1{#2}{#3}}%
  441. }%=<<
  442. \MRTutil@def\MRTifNumTokenGTF{\MRTifNumTokenG@common\MRTifNumTokenTF}
  443. \MRTutil@def\MRTifNumTokenSGTF{\MRTifNumTokenG@common\MRTifNumTokenSTF}
  444. \MRTutil@def[\long]\MRTifNumTokenGN@common#1#2#3%>>=
  445. {%
  446. \MRTifNumTokenG@common#3{#2}{#1}%
  447. }%=<<
  448. \MRTutil@def[\long]\MRTifNumTokenGNTF#1#2%>>=
  449. {%
  450. \expandafter\MRTifNumTokenGN@common\expandafter{#2}{#1}\MRTifNumTokenTF
  451. }%=<<
  452. \MRTutil@def[\long]\MRTifNumTokenSGNTF#1#2%>>=
  453. {%
  454. \expandafter\MRTifNumTokenGN@common\expandafter{#2}{#1}\MRTifNumTokenSTF
  455. }%=<<
  456. \MRTif@create@TandF@twoargs{NumTokenG}
  457. \MRTif@create@TandF@twoargs{NumTokenSG}
  458. \MRTif@create@TandF@twoargs{NumTokenGN}
  459. \MRTif@create@TandF@twoargs{NumTokenSGN}
  460. % =<<
  461. % MRTifLetter >>=
  462. \MRTutil@def[\long]\MRTifLetterTF#1% >>=
  463. {%
  464. \MRTifOneTokenNoGroupTF{#1}
  465. {\MRTifLetter@core #1}
  466. {\@secondoftwo}%
  467. }% =<<
  468. %\MRTif@groupify@TF{Letter}% possible but results in unnecessary group test
  469. \MRTutil@def[\long]\MRTifLetterGTF#1% >>=
  470. {%
  471. \MRTifGroupTF{#1}
  472. {\MRTifLetterGTF#1}
  473. {%
  474. \MRTifOneTokenTF{#1}
  475. {\MRTifLetter@core{#1}}
  476. {\@secondoftwo}%
  477. }%
  478. }% =<<
  479. %\MRTutil@def[\long]\MRTifLetter@core#1% >>=
  480. \begingroup
  481. \catcode`\z=11 % just to make sure z has catcode 11 in the following
  482. \@firstofone
  483. {%
  484. \endgroup
  485. \MRTifCreateBranchingIfs{MRTifLetter@core}{=ab}{1}{\ifcat\noexpand#1z}%
  486. }
  487. % =<<
  488. \MRTif@create@TandF@N@TandF{Letter}
  489. \MRTif@create@TandF@N@TandF{LetterG}
  490. % =<<
  491. % MRTifTokensMatch >>=
  492. \MRTutil@def[\long]\MRTifTokensMatchTF#1#2% >>=
  493. {%
  494. \MRTifContainsGroupTF{#1}
  495. {\@secondoftwo}
  496. {%
  497. \MRTifContainsGroupTF{#2}
  498. {\@secondoftwo}
  499. {\MRTifTokensMatch@a{#1}{#2}}%
  500. }%
  501. }% =<<
  502. \MRTutil@def[\long]\MRTifTokensMatchGTF#1#2% >>=
  503. {%
  504. \MRTifGroupTF{#1}
  505. {\MRTifTokensMatchGTF#1{#2}}
  506. {%
  507. \MRTifGroupTF{#2}
  508. {\MRTifTokensMatchGTF#2{#1}}
  509. {\MRTifTokensMatch@a{#1}{#2}}%
  510. }%
  511. }% =<<
  512. \MRTutil@def[\long]\MRTifTokensMatch@a#1#2% >>=
  513. {%
  514. \MRTifNumTokenSTF{1}{#1}
  515. {%
  516. \MRTifNumTokenSTF{1}{#2}
  517. {%
  518. \ifx#1#2%
  519. \MRTif@fi@firstoftwo
  520. \fi
  521. \@secondoftwo
  522. }
  523. {\@secondoftwo}%
  524. }
  525. {\@secondoftwo}%
  526. }% =<<
  527. \MRTif@create@TandF@N@TandF@twoargs{TokensMatch}
  528. \MRTif@create@TandF@N@TandF@twoargs{TokensMatchG}
  529. % =<<
  530. % MRTifDigit >>=
  531. \MRTutil@def[\long]\MRTifDigitTF#1% >>=
  532. {%
  533. \MRTifOneTokenTF{#1} % groups will fail \MRTifDigit@core
  534. {\MRTifDigit@core{#1}}
  535. {\@secondoftwo}%
  536. }% =<<
  537. \MRTutil@def[\long]\MRTifDigit@core#1% >>=
  538. {%
  539. \ifnum1<1\noexpand#1 \MRTif@fi@firstoftwo\fi\@secondoftwo
  540. }% =<<
  541. \MRTutil@def[\long]\MRTifDigitGTF#1% >>=
  542. {%
  543. \MRTifGroupTF{#1}
  544. {\MRTifDigitGTF#1}
  545. {%
  546. \MRTifOneTokenTF{#1}
  547. {\MRTifDigit@core{#1}}
  548. {\@secondoftwo}%
  549. }%
  550. }% =<<
  551. \MRTif@create@TandF@N@TandF{Digit}
  552. \MRTif@create@TandF@N@TandF{DigitG}
  553. % =<<
  554. % MRTifNumber >>=
  555. \MRTutil@def[\long]\MRTifNumberTF#1% >>=
  556. {%
  557. \MRTif@notEmpty@noGroup@noSpace{#1}
  558. {\MRTifNumber@ifSign#1\endMRTif@argument}%
  559. }% =<<
  560. \MRTutil@def[\long]\MRTifNumber@ifSign@#1%
  561. {%
  562. \ifx+#1%
  563. \else
  564. \ifx-#1%
  565. \else
  566. \MRTif@fifi@secondoftwo
  567. \fi
  568. \fi
  569. \@firstoftwo
  570. }
  571. \MRTutil@def[\long]\MRTifNumber@ifSign#1% >>=
  572. {%
  573. \MRTifNumber@ifSign@{#1}
  574. {\MRTifNumber@ifDigit@noend}
  575. {\MRTifNumber@ifDigit#1}%
  576. }% =<<
  577. \MRTutil@def[\long]\MRTifNumber@ifDigit#1% >>=
  578. {%
  579. \MRTif@endMRTif@argument{#1}
  580. {\@firstoftwo}
  581. {%
  582. \MRTifDigit@core{#1}
  583. {\MRTifNumber@ifDigit}
  584. {\MRTifNumber@false}%
  585. }%
  586. }% =<<
  587. \MRTutil@def[\long]\MRTifNumber@ifDigit@noend#1% >>=
  588. {%
  589. \MRTif@endMRTif@argument{#1}
  590. {\@secondoftwo}
  591. {%
  592. \MRTifDigit@core{#1}
  593. {\MRTifNumber@ifDigit}
  594. {\MRTifNumber@false}%
  595. }%
  596. }% =<<
  597. \long\def\MRTifNumber@false#1\endMRTif@argument% >>=
  598. {%
  599. \@secondoftwo
  600. }% =<<
  601. \MRTif@groupify@TF{Number}
  602. \MRTif@create@TandF@N@TandF{Number}
  603. \MRTif@create@TandF@N@TandF{NumberG}
  604. % =<<
  605. % MRTifNumberNoSign >>=
  606. \MRTutil@def[\long]\MRTifNumberNoSignTF#1% >>=
  607. {%
  608. \MRTif@notEmpty@noGroup@noSpace{#1}
  609. {\MRTifNumber@ifDigit#1\endMRTif@argument}%
  610. }% =<<
  611. \MRTif@groupify@TF{NumberNoSign}
  612. \MRTif@create@TandF@N@TandF{NumberNoSign}
  613. \MRTif@create@TandF@N@TandF{NumberNoSignG}
  614. % =<<
  615. % MRTifFloat >>=
  616. \MRTutil@def[\long]\MRTifFloatTF#1% >>=
  617. {%
  618. \MRTif@notEmpty@noGroup@noSpace{#1}{\MRTifFloat@a{#1}}%
  619. }% =<<
  620. \MRTutil@def[\long]\MRTifFloat@a#1% >>=
  621. {%
  622. \MRTifFloat@ifNoDot{#1}
  623. {\MRTifNumber@ifSign#1\endMRTif@argument}
  624. {\MRTifFloat@withDot#1\MRTifFloat@endargument}%
  625. }% =<<
  626. \MRTutil@def[\long]\MRTifFloat@ifNoDot#1% >>=
  627. {%
  628. \MRTifFloat@ifNoDot@a#1.\endMRTif@argument\MRTifFloat@endargument
  629. }% =<<
  630. \MRTutil@def[\long]\MRTifFloat@ifNoDot@a#1.#2\MRTifFloat@endargument% >>=
  631. {%
  632. \MRTif@endMRTif@argument{#2}%
  633. }% =<<
  634. \MRTutil@def[\long]\MRTifFloat@ifSign#1%>>=
  635. {%
  636. \MRTifNumber@ifSign@{#1}
  637. {\MRTifNumber@ifDigit}
  638. {\MRTifNumber@ifDigit#1}%
  639. }%=<<
  640. \MRTutil@def[\long]\MRTifFloat@withDot#1.#2\MRTifFloat@endargument% >>=
  641. {%
  642. \MRTifEmptyTF{#1}
  643. {\MRTifNumber@ifDigit@noend#2\endMRTif@argument}
  644. {%
  645. \MRTifEmptyTF{#2}
  646. {\MRTifNumber@ifSign#1\endMRTif@argument}
  647. {%
  648. \MRTifNumber@ifDigit#2\endMRTif@argument
  649. {\MRTifFloat@ifSign#1\endMRTif@argument}
  650. {\@secondoftwo}%
  651. }%
  652. }%
  653. }% =<<
  654. \MRTif@groupify@TF{Float}
  655. \MRTif@create@TandF@N@TandF{Float}
  656. \MRTif@create@TandF@N@TandF{FloatG}
  657. % =<<
  658. % MRTifFloatNoSign >>=
  659. \MRTutil@def[\long]\MRTifFloatNoSignTF#1% >>=
  660. {%
  661. \MRTif@notEmpty@noGroup@noSpace{#1}{\MRTifFloatNoSign@a{#1}}%
  662. }% =<<
  663. \MRTutil@def[\long]\MRTifFloatNoSign@a#1% >>=
  664. {%
  665. \MRTifFloat@ifNoDot{#1}
  666. {\MRTifNumber@ifDigit@noend#1\endMRTif@argument}
  667. {\MRTifFloatNoSign@withDot#1\MRTifFloatNoSign@endargument}%
  668. }% =<<
  669. \long\def\MRTifFloatNoSign@withDot#1.#2\MRTifFloatNoSign@endargument% >>=
  670. {%
  671. \MRTifEmptyTF{#1}
  672. {\MRTifNumber@ifDigit@noend#2\endMRTif@argument}
  673. {%
  674. \MRTifNumber@ifDigit@noend#1\endMRTif@argument
  675. {\MRTifNumber@ifDigit#2\endMRTif@argument}
  676. {\@secondoftwo}%
  677. }%
  678. }% =<<
  679. \MRTif@groupify@TF{FloatNoSign}
  680. \MRTif@create@TandF@N@TandF{FloatNoSign}
  681. \MRTif@create@TandF@N@TandF{FloatNoSignG}
  682. % =<<
  683. % MRTifContainsGroup >>=
  684. % obfuscated but *fast* ifContainsGroup, reuses internals of ifEmpty and ifBlank
  685. \MRTif@specialLowercase{%
  686. \MRTutil@def[\long]\MRTifContainsGroup@#1#{\MRTifBlank@}
  687. % normal version >>=
  688. \MRTutil@def[\long]\MRTifContainsGroupTF#1%
  689. {\MRTifContainsGroup@#1{}Q\MRTifEmpty@true@FT*Q\@firstoftwo}
  690. \MRTutil@def[\long]\MRTifContainsGroupT#1%
  691. {\MRTifContainsGroup@#1{}Q\MRTifEmpty@true@F*Q\@firstofone}
  692. \MRTutil@def[\long]\MRTifContainsGroupF#1%
  693. {\MRTifContainsGroup@#1{}Q\MRTifEmpty@true@T*Q\@gobble}
  694. % =<<
  695. % N-version >>=
  696. \MRTutil@def[\long]\MRTifContainsGroupNTF#1%
  697. {\expandafter\MRTifContainsGroup@#1{}Q\MRTifEmpty@true@FT*Q\@firstoftwo}
  698. \MRTutil@def[\long]\MRTifContainsGroupNT#1%
  699. {\expandafter\MRTifContainsGroup@#1{}Q\MRTifEmpty@true@F*Q\@firstofone}
  700. \MRTutil@def[\long]\MRTifContainsGroupNF#1%
  701. {\expandafter\MRTifContainsGroup@#1{}Q\MRTifEmpty@true@T*Q\@gobble}
  702. % =<<
  703. }
  704. \MRTif@groupify@TF{ContainsGroup}
  705. \MRTif@create@TandF@N@TandF{ContainsGroupG}
  706. % =<<
  707. % MRTifContainsSpace >>=
  708. % obfuscated but *fast* ifContainsSpace, reuses internals of ifEmpty
  709. \MRTif@specialLowercase{%
  710. \MRTutil@def[\long]\MRTifContainsSpace@#1 {\MRTifEmpty@*}
  711. % standard version >>=
  712. \MRTutil@def[\long]\MRTifContainsSpaceTF#1%
  713. {\MRTifContainsSpace@#1 Q\MRTifEmpty@true@FT*Q\@firstoftwo}
  714. \MRTutil@def[\long]\MRTifContainsSpaceT#1%
  715. {\MRTifContainsSpace@#1 Q\MRTifEmpty@true@F*Q\@firstofone}
  716. \MRTutil@def[\long]\MRTifContainsSpaceF#1%
  717. {\MRTifContainsSpace@#1 Q\MRTifEmpty@true@T*Q\@gobble}
  718. % =<<
  719. % N-version >>=
  720. \MRTutil@def[\long]\MRTifContainsSpaceNTF#1%
  721. {\expandafter\MRTifContainsSpace@#1 Q\MRTifEmpty@true@FT*Q\@firstoftwo}
  722. \MRTutil@def[\long]\MRTifContainsSpaceNT#1%
  723. {\expandafter\MRTifContainsSpace@#1 Q\MRTifEmpty@true@F*Q\@firstofone}
  724. \MRTutil@def[\long]\MRTifContainsSpaceNF#1%
  725. {\expandafter\MRTifContainsSpace@#1 Q\MRTifEmpty@true@T*Q\@gobble}
  726. % =<<
  727. }
  728. \MRTif@groupify@TF{ContainsSpace}
  729. \MRTif@create@TandF@N@TandF{ContainsSpaceG}
  730. % =<<
  731. % MRTifTokenIn >>=
  732. \MRTutil@def[\long]\MRTifTokenInTF#1%>>=
  733. {%
  734. \MRTifBlankTF{#1}
  735. {%
  736. \MRTifEmptyTF{#1}
  737. {\@secondofthree}
  738. {\MRTifContainsSpaceTF}%
  739. }
  740. {%
  741. \MRTifOneTokenNoGroupTF{#1}
  742. {\MRTifTokenIn@a#1}
  743. {\@thirdofthree}%
  744. }%
  745. }%=<<
  746. \MRTutil@def[\long]\MRTifTokenIn@a#1#2%>>=
  747. {%
  748. \MRTifTokenIn@b#1#2{\endMRTif@argument}\MRTifTokenIn@false
  749. }%=<<
  750. \MRTutil@def[\long]\MRTifTokenIn@b#1#2#%>>=
  751. {%
  752. \MRTifTokenIn@c#1#2\endMRTif@argument
  753. }%=<<
  754. \MRTutil@def[\long]\MRTifTokenIn@c#1#2%>>=
  755. {%
  756. \MRTif@endMRTif@argument#2%
  757. {\MRTifTokenIn@d}
  758. {%
  759. \ifx#1#2%
  760. \MRTifTokenIn@true
  761. \fi
  762. \MRTifTokenIn@c
  763. }%
  764. #1%
  765. }%=<<
  766. \MRTutil@def[\long]\MRTifTokenIn@d#1#2%>>=
  767. {%
  768. \MRTif@endMRTif@argument{#2}
  769. {}
  770. {\MRTifTokenIn@b#1}%
  771. }%=<<
  772. \MRTutil@def[\long]\MRTifTokenIn@true\fi%>>=
  773. \MRTifTokenIn@c#1\MRTifTokenIn@false#2#3%
  774. {%
  775. \fi#2%
  776. }%=<<
  777. \let\MRTifTokenIn@false\@secondoftwo
  778. \MRTutil@def[\long]\MRTifTokenInGTF#1#2%>>=
  779. {%
  780. \MRTifGroupTF{#2}
  781. {\MRTifTokenInGTF{#1}#2}
  782. {\MRTifTokenInTF{#1}{#2}}%
  783. }%=<<
  784. \MRTif@create@TandF@N@TandF@twoargs{TokenIn}
  785. \MRTif@create@TandF@N@TandF@twoargs{TokenInG}
  786. % =<<
  787. % MRTifTokenInDeep >>=
  788. \MRTutil@def[\long]\MRTifTokenInDeepTF#1%>>=
  789. {%
  790. \MRTifBlankTF{#1}
  791. {%
  792. \MRTifEmptyTF{#1}
  793. {\@secondofthree}
  794. {\MRTifTokenInDeep@space}%
  795. }
  796. {%
  797. \MRTifOneTokenNoGroupTF{#1}
  798. {\MRTifTokenInDeep@a#1}
  799. {\@thirdofthree}%
  800. }%
  801. }%=<<
  802. \MRTutil@def[\long]\MRTifTokenInDeep@a#1#2%>>=
  803. {%
  804. \MRTifTokenInDeep@b#1#2{\endMRTif@argument}\MRTifTokenIn@false
  805. }%=<<
  806. \MRTutil@def[\long]\MRTifTokenInDeep@b#1#2#%>>=
  807. {%
  808. \MRTifTokenInDeep@c#1#2\endMRTif@argument
  809. }%=<<
  810. \MRTutil@def[\long]\MRTifTokenInDeep@c#1#2%>>=
  811. {%
  812. \MRTif@endMRTif@argument#2%
  813. {\MRTifTokenInDeep@d}
  814. {%
  815. \ifx#1#2%
  816. \MRTifTokenInDeep@true
  817. \fi
  818. \MRTifTokenInDeep@c
  819. }%
  820. #1%
  821. }%=<<
  822. \MRTutil@def[\long]\MRTifTokenInDeep@d#1#2%>>=
  823. {%
  824. \MRTif@endMRTif@argument{#2}
  825. {}
  826. {\MRTifTokenInDeep@b#1#2}%
  827. }%=<<
  828. \MRTutil@def[\long]\MRTifTokenInDeep@true\fi%>>=
  829. \MRTifTokenInDeep@c#1\MRTifTokenIn@false#2#3%
  830. {%
  831. \fi#2%
  832. }%=<<
  833. \MRTutil@def[\long]\MRTifTokenInDeep@space#1%>>=
  834. {%
  835. \MRTifTokenInDeep@space@a#1{\endMRTif@argument}\MRTifTokenIn@false
  836. }%=<<
  837. \MRTutil@def[\long]\MRTifTokenInDeep@space@a#1#%>>=
  838. {%
  839. \MRTifContainsSpaceTF{#1}
  840. {\MRTifTokenInDeep@space@true}
  841. {\MRTifTokenInDeep@space@b}%
  842. }%=<<
  843. \MRTutil@def[\long]\MRTifTokenInDeep@space@b#1%>>=
  844. {%
  845. \MRTif@endMRTif@argument{#1}
  846. {}
  847. {\MRTifTokenInDeep@space@a#1}%
  848. }%=<<
  849. \MRTutil@def[\long]\MRTifTokenInDeep@space@true#1\MRTifTokenIn@false#2#3%>>=
  850. {%
  851. #2%
  852. }%=<<
  853. \MRTif@create@TandF@N@TandF@twoargs{TokenInDeep}
  854. % =<<
  855. %
  856. % MRTtllength >>=
  857. \MRTutil@def[\long]\MRTtllength@inner#1% >>=
  858. {%
  859. \MRTif@endMRTif@argument{#1}
  860. {\relax}
  861. {+1\MRTtllength@inner}%
  862. }% =<<
  863. \MRTutil@def[\long]\MRTtllength#1% >>=
  864. {%
  865. \the\numexpr0\MRTtllength@inner#1\endMRTif@argument
  866. }% =<<
  867. \MRTutil@def[\long]\MRTtllengthN#1% >>=
  868. {%
  869. \expandafter\MRTtllength\expandafter{#1}%
  870. }% =<<
  871. \MRTutil@edef[\long]\MRTtllengthS#1%>>=
  872. {%
  873. \unexpanded{\the\numexpr\m@ne\MRTtllengthS@spaces}#1
  874. \noexpand\endMRTif@argument\space
  875. \noexpand\MRTtllength@inner#1\noexpand\endMRTif@argument
  876. }%=<<
  877. \MRTutil@def[\long]\MRTtllengthS@spaces#1 %>>=
  878. {%
  879. \MRTif@endMRTif@argument{#1}{}{+1\MRTtllengthS@spaces}%
  880. }%=<<
  881. \MRTutil@def[\long]\MRTtllengthSN#1%>>=
  882. {%
  883. \expandafter\MRTtllengthS\expandafter{#1}%
  884. }%=<<
  885. % =<<
  886. % MRTifFexp >>=
  887. \@ifdefinable\MRTifFexp@endFexp{\let\MRTif@endFexp\z@}
  888. \MRTutil@def[\long]\MRTif@endFexp@gobble#1{\MRTif@endFexp}
  889. \MRTutil@def[\long]\MRTif@endFexp@firstofone#1{\MRTif@endFexp#1}
  890. \MRTutil@def[\long]\MRTif@endFexp@firstoftwo #1#2{\MRTif@endFexp#1}
  891. \MRTutil@def[\long]\MRTif@endFexp@secondoftwo#1#2{\MRTif@endFexp#2}
  892. \MRTutil@def[\long]\MRTif@FexpI@true\MRTif@endFexp@gobble#1%>>=
  893. {%
  894. \MRTif@endFexp#1%
  895. }%=<<
  896. % some parts of \MRTifFexp reuse internals of \MRTifEmpty
  897. \MRTif@specialLowercase{%
  898. % define macros which need spaces in places >>=
  899. \MRTutil@def\MRTifFexp#1%
  900. {%
  901. \long\def\MRTifFexp##1%>>=
  902. {%
  903. \romannumeral\expandafter\MRTifFexp@a
  904. \romannumeral`\^^@##1\MRTifFexp@b#1%
  905. \MRTifFexp@false@two\MRTifFexp@tokA#1%
  906. \MRTifFexp@tokB
  907. \MRTif@endFexp@gobble
  908. }%=<<
  909. \MRTutil@def\MRTifFexp@true@one%>>=
  910. *Q\MRTifFexp@true@two\MRTifFexp@false@two
  911. \MRTifFexp@tokA#1\MRTifFexp@tokB\MRTif@endFexp@gobble
  912. { % ending the inner \romannumeral
  913. \MRTifFexp@tokB\MRTif@endFexp@firstofone
  914. }%=<<
  915. \MRTutil@def\MRTifFexp@false@two%>>=
  916. \MRTifFexp@tokA#1\MRTifFexp@tokB\MRTif@endFexp@gobble
  917. { % ending the inner \romannumeral
  918. \MRTifFexp@tokB\MRTif@endFexp@secondoftwo
  919. }%=<<
  920. }%=<<
  921. \MRTifFexp{ }
  922. \MRTutil@def\MRTifFexp@b#1 % the space here is important >>=
  923. {%
  924. \MRTifEmpty@*#1Q\MRTifFexp@true@one*Q\MRTifFexp@true@two
  925. }%=<<
  926. }
  927. \MRTutil@def\MRTifFexp@a#1\MRTifFexp@tokB{}
  928. \MRTutil@def\MRTifFexp@true@two\MRTifFexp@tokB\MRTif@endFexp@gobble%>>=
  929. { % ending the inner \romannumeral
  930. \MRTifFexp@tokB\MRTif@endFexp@firstoftwo
  931. }%=<<
  932. \MRTutil@def[\long]\MRTifFexpII#1%>>=
  933. {%
  934. \romannumeral#1\MRTif@endFexp@firstoftwo\MRTif@endFexp@secondoftwo
  935. }%=<<
  936. \MRTutil@def[\long]\MRTifFexpI#1%>>=
  937. {%
  938. \romannumeral#1\MRTif@FexpI@true\MRTif@endFexp@gobble
  939. }%=<<
  940. % =<<
  941. \endinput
  942. % vim: ft=tex fdm=marker fmr=>>=,=<< sw=2 ts=2 tw=80