-
Notifications
You must be signed in to change notification settings - Fork 7
/
mhsetup.dtx
666 lines (649 loc) · 21.3 KB
/
mhsetup.dtx
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
% \iffalse meta-comment
%
% Copyright (C) 2002-2007,2010 by Morten Hoegholm
% Copyright (C) 2017-2019 by Lars Madsen
% Copyright (C) 2020- by Lars Madsen, The LaTeX3 team
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any later
% version. The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of
% LaTeX version 2008/05/04 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% This Current Maintainer of this work is Lars Madsen
% <[email protected]>, the LaTeX3 team,
% https://github.com/latex3/mathtools
%
% This work consists of the main source file mhsetup.dtx
% and the derived files
% mhsetup.sty, mhsetup.pdf, mhsetup.ins, mhsetup.drv.
%
% Distribution:
% CTAN:macros/latex/contrib/mh/mhsetup.dtx
% CTAN:macros/latex/contrib/mh/mhsetup.pdf
%
% Unpacking:
% (a) If mhsetup.ins is present:
% tex mhsetup.ins
% (b) Without mhsetup.ins:
% tex mhsetup.dtx
% (c) If you insist on using LaTeX
% latex \let\install=y\input{mhsetup.dtx}
% (quote the arguments according to the demands of your shell)
%
% Documentation:
% (a) If mhsetup.drv is present:
% latex mhsetup.drv
% (b) Without mhsetup.drv:
% latex mhsetup.dtx; ...
% The class ltxdoc loads the configuration file ltxdoc.cfg
% if available. Here you can specify further options, e.g.
% use A4 as paper format:
% \PassOptionsToClass{a4paper}{article}
%
% Programm calls to get the documentation (example):
% pdflatex mhsetup.dtx
% makeindex -s gind.ist mhsetup.idx
% pdflatex mhsetup.dtx
% makeindex -s gind.ist mhsetup.idx
% pdflatex mhsetup.dtx
%
% Installation:
% TDS:tex/latex/mh/mhsetup.sty
% TDS:doc/latex/mh/mhsetup.pdf
% TDS:source/latex/mh/mhsetup.dtx
%
%<*ignore>
\begingroup
\def\x{LaTeX2e}
\expandafter\endgroup
\ifcase 0\ifx\install y1\fi\expandafter
\ifx\csname processbatchFile\endcsname\relax\else1\fi
\ifx\fmtname\x\else 1\fi\relax
\else\csname fi\endcsname
%</ignore>
%<*install>
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
\Msg{* Package: mhsetup 2021/03/18 v1.4 mhsetup}
\Msg{************************************************************************}
\keepsilent
\askforoverwritefalse
\preamble
This is a generated file.
Copyright (C) 2002-2007,2010 by Morten Hoegholm
Copyright (C) 2017-2019 by Lars Madsen
Copyright (C) 2020- by Lars Madsen, The LaTeX3 team
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
version 1.3c of this license or (at your option) any later
version. The latest version of this license is in
http://www.latex-project.org/lppl.txt
and version 1.3c or later is part of all distributions of
LaTeX version 2008/05/04 or later.
This work has the LPPL maintenance status "maintained".
This Current Maintainer of this work is Lars Madsen
<[email protected]>, The LaTeX3 team https://github.com/latex3/mathtools
This work consists of the main source file mhsetup.dtx
and the derived files
mhsetup.sty, mhsetup.pdf, mhsetup.ins, mhsetup.drv.
\endpreamble
\generate{%
\file{mhsetup.ins}{\from{mhsetup.dtx}{install}}%
\file{mhsetup.drv}{\from{mhsetup.dtx}{driver}}%
\usedir{tex/latex/mh}%
\file{mhsetup.sty}{\from{mhsetup.dtx}{package}}%
}
\obeyspaces
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* file into a directory searched by TeX:}
\Msg{*}
\Msg{* mhsetup.sty}
\Msg{*}
\Msg{* To produce the documentation run the file `mhsetup.drv'}
\Msg{* through LaTeX.}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}
\endbatchfile
%</install>
%<*ignore>
\fi
%</ignore>
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{mhsetup.drv}%
[2021/03/18 v1.4 programming setup (MH)]
\documentclass{ltxdoc}
\usepackage{mhsetup}
\addtolength\oddsidemargin{30pt}
\providecommand*\pkg[1]{\textsf{#1}}
\providecommand*\env[1]{\texttt{#1}}
\providecommand*\opt[1]{\texttt{#1}}
\def\MakePrivateLetters{%
\makeatletter\catcode`\_=11\relax \catcode`\:=11\relax
}
\def\MHmarg#1{{\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}\endgroup}
\DeclareRobustCommand\marg{\begingroup\MakePrivateLetters\MHmarg}%
\def\MHarg#1{{\ttfamily\char`\{#1\ttfamily\char`\}}\endgroup}
\DeclareRobustCommand\arg{\begingroup\MakePrivateLetters\MHarg}%
\def\MHcs#1{\texttt{\char`\\#1}\endgroup}
\DeclareRobustCommand\cs{\begingroup\MakePrivateLetters\MHcs}
\makeatletter
\providecommand*\eTeX{$\m@th\varepsilon$-\TeX}
\makeatother
\begin{document}
\DocInput{mhsetup.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{301}
%
% \GetFileInfo{mhsetup.drv}
%
% \title{The \pkg{mhsetup} package\thanks{This package has version
% number \fileversion, last revised on \filedate.}}
% \author{Morten H\o gholm (maintained by Lars Madsen and The LaTeX3 team)}
% \date{\filedate}
% \maketitle
%
% \begin{abstract}
% \noindent The \pkg{mhsetup} package provides tools for a \LaTeX{}
% programming environment similar to the one described in
% \texttt{expl3} on \textsc{ctan} although not as extensive. It is
% a required part of both the \pkg{mathtools} and \pkg{empheq}
% packages.
% \end{abstract}
% \noindent
% The description below was made before the extensive changes made to
% the expl3 code available from the LaTeX Project website.
%
% \section{The new internal syntax}
%
%
% The \LaTeX3 package \pkg{ldcsetup} defines the command
% \cs{InternalSyntaxOn} which makes |_| and |:| letters and then
% automatically restores the category codes at the end of the
% package. This usually works fine but when you try to load
% \pkg{\mbox{amstext}} you will experience that \TeX{} goes into an
% infinite loop. Packages containing code like
% |\@for\@tempa:=\@tempb\do{...}| will not work correctly either,
% thus we provide an alternative version here with the pair of
% commands
% \DescribeMacro{\MHInternalSyntaxOn}\cs{MHInternalSyntaxOn} and
% \DescribeMacro{\MHInternalSyntaxOff}\cs{MHInternalSyntaxOff}. They
% are to be used only as a pair, because \cs{MHInternalSyntaxOn}
% defines \cs{MHInternalSyntaxOff} so that it restores the category
% codes correctly.
%
%
% \section{Handling optional arguments}
%
% The standard behavior of scanning for optional arguments in
% \LaTeX{} allows any number of spaces preceding the optional
% argument and that is not always good in math. For that reason
% \pkg{amsmath} makes sure that commands like |\\| disallow spaces
% before the optional argument but at the same time it fails to
% provide ``safe'' environments. What would you expect from the
% following input?
% \begin{verbatim}
% \[
% \begin{gathered}
% [v] = 100 \\
% [t] = 200
% \end{gathered}
% \]
% \end{verbatim}
% \LaTeX{} will see the \texttt{[v]} as an optional argument of
% \env{gathered} and use it. In this case the test inside
% \env{gathered} checks if it's a \texttt{t} or \texttt{b} and if
% it's neither it'll choose \cs{vcenter} internally. So you get no
% warning, only missing output. Another example, this time from the
% \pkg{empheq} package used with its \opt{overload} option: If
% preceding spaces are allowed, the input
% \begin{verbatim}
% \begin{gather}
% [a] = [b]
% \end{gather}
% \end{verbatim}
% results in the rather strange error message
% \begin{verbatim}
% ! Package keyval Error: a undefined.
% \end{verbatim}
%
% When using \cs{newcommand} etc.\ for defining commands and
% environments with optional arguments, the peek ahead is done by
% \cs{kernel@ifnextchar} (since \LaTeX{} release 2003/12/01, else
% \cs{@ifnextchar}) and it is \emph{hardwired at definition time} by
% \cs{@xargdef}. With the commands
% \DescribeMacro{\MHPrecedingSpacesOff}\cs{MHPrecedingSpacesOff} and
% \DescribeMacro{\MHPrecedingSpacesOn}\cs{MHPrecedingSpacesOn}
% \pkg{mhsetup} provides an interface to define commands and
% environments where the optional argument cannot have preceding
% spaces. You simply wrap them around the definitions:
% \begin{verbatim}
% \MHPrecedingSpacesOff
% \newenvironment*{test}[1][default]{Start, arg: (#1)}{Ending.}
% \MHPrecedingSpacesOn
% \begin{test}
% [text]
% \end{test}
% \begin{test}[text]
% \end{test}
% \end{verbatim}
% \MHPrecedingSpacesOff
% \newenvironment*{test}[1][default]{Start, arg: (#1)}{Ending.}
% \MHPrecedingSpacesOn
% \begin{quote}
% \begin{test}
% [text]
% \end{test}
% \begin{test}[text]
% \end{test}
% \end{quote}
% It is of somewhat limited use in commands (control words in \TeX{}
% terminology), because \TeX{} discards the spaces. The exception is
% \emph{control symbols} where \TeX{} obeys following spaces but
% there are rather few of them available. All is not lost however.
% In the \env{aligned} environment from \pkg{amsmath} (shown below)
% a command is used as argument grabber.
% \begin{verbatim}
% \newenvironment{aligned}{%
% \let\@testopt\alignsafe@testopt
% \aligned@a
% }{%
% \crcr\egroup
% \restorecolumn@
% \egroup
% }
% \newcommand{\aligned@a}[1][c]{\start@aligned{#1}\m@ne}
% \end{verbatim}
% By applying our trick on the grabber function, we get a space
% obeying version:
% \begin{verbatim}
% \MHPrecedingSpacesOff
% \renewcommand*\aligned@a[1][c]{\start@aligned{#1}\m@ne}
% \MHPrecedingSpacesOn
% \end{verbatim}
% This way a nested \env{aligned} environment is still safe from
% empty first cells.
%
% \StopEventually{}
%
%
% \section{First bits of a new programming environment}
%
%
% \begin{macrocode}
%<*package>
\ProvidesPackage{mhsetup}%
[2021/03/18 v1.4 programming setup (MH)]
% \end{macrocode}
% \subsection{The new internal syntax}
% \begin{macro}{\MHInternalSyntaxOn}
% \begin{macro}{\MHInternalSyntaxOff}
% Almost copy of \cs{InternalSyntaxOn}.
% \begin{macrocode}
\def\MHInternalSyntaxOn{
\edef\MHInternalSyntaxOff{%
\catcode`\noexpand\~=\the\catcode`\~\relax
\catcode`\noexpand\ =\the\catcode`\ \relax
\catcode`\noexpand\^^I=\the\catcode`\^^I\relax
\catcode`\noexpand\@=\the\catcode`\@\relax
\catcode`\noexpand\:=\the\catcode`\:\relax
\catcode`\noexpand\_=\the\catcode`\_\relax
\endlinechar=\the\endlinechar\relax
}%
\catcode`\~=10\relax
\catcode`\ =9\relax
\catcode`\^^I=9\relax
\makeatletter
\catcode`\_=11\relax
\catcode`\:=11\relax
\endlinechar=` %
\relax
}
\MHInternalSyntaxOn
\AtEndOfPackage{\MHInternalSyntaxOff}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Programming tools}
%
% The whole idea is to provide programming tools that are convenient
% but not yet widely available. I hope this'll be obsolete soon!
%
% Firstly we set up a few helper functions.
% \begin{macro}{\MH_let:NwN}
% An alias for \cs{let}.
% \begin{macrocode}
\let\MH_let:NwN \let
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MH_let:cN}
% This one takes a \cs{csname}-\cs{endcsname} name and \cs{let}s it
% to a single macro. We'll use this to setup our conditionals.
% \begin{macrocode}
\def\MH_let:cN #1#2{
\expandafter\MH_let:NwN \csname#1\endcsname#2}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\MH_let:cc}
% This one takes a \cs{csname}-\cs{endcsname} name and \cs{let}s
% it to another \cs{csname}-\cs{endcsname} name. To be used in
% constructions with weird characters like \texttt{*} or alike in
% them and can take a \cs{global} prefix if wanted (we want that
% later on).
% \begin{macrocode}
\def\MH_let:cc #1#2{
\expandafter\MH_let:NwN\csname#1\expandafter\endcsname
\csname#2\endcsname}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\MH_new_boolean:n}
% \begin{macro}{\MH_set_boolean_F:n}
% \begin{macro}{\MH_set_boolean_T:n}
% \begin{macro}{\MH_if_boolean:nTF}
% \begin{macro}{\MH_if_boolean:nT}
% \begin{macro}{\MH_if_boolean:nF}
% Sets up conditionals. For instance
% \begin{quote}
% \cs{MH_new_boolean:n} \marg{name}
% \end{quote}
% defines the boolean \meta{name} but also the conditional
% \cs{MH_if_boolean_\meta{name}:} to be used in the ordinary
% \begin{tabbing}
% \mbox{}\quad\= \kill
% \cs{MH_if_boolean_\meta{name}:}\\
% \> \meta{true code} \\
% \cs{MH_else:} \\
% \> \meta{false code} \\
% \cs{MH_fi:}
% \end{tabbing}
% There is also a more ``\LaTeX-like'' interface available by using
% the commands
% \begin{quote}
% \cs{MH_if_boolean:nT}\marg{name}\marg{arg}
% \end{quote}
% which will execute the argument if the current value of the
% boolean is `true' while
% \begin{quote}
% \cs{MH_if_boolean:nF}\marg{name}\marg{arg}
% \end{quote}
% is the equivalent with `false'. Finally we have
% \begin{quote}
% \cs{MH_if_boolean:nTF}\marg{name}\marg{true code}\marg{false code}.
% \end{quote}
% This is the interface I have used in this package.
%
% Initially \cs{MH_if_boolean_\meta{name}:} is `false'. This can be
% changed by saying
% \begin{tabbing}
% \quad \= \LaTeX:\quad \= \kill
% \> \TeX: \> \cs{MH_boolean_\meta{name}_true:} \quad \emph{or}\\
% \> \LaTeX: \> \cs{MH_set_boolean_T:n}\marg{name}
% \end{tabbing}
% and changed back again by
% \begin{tabbing}
% \quad \= \LaTeX:\quad \= \kill
% \> \TeX: \> \cs{MH_boolean_\meta{name}_false:} \quad \emph{or}\\
% \> \LaTeX: \> \cs{MH_set_boolean_F:n}\marg{name}
% \end{tabbing}
%
% And yes, we're also using alternative names for \cs{else} and
% \cs{fi} now. That way a simple search and replace will be all that
% is needed for this package to be a certified \LaTeX3 package (well,
% maybe a little more is needed, but not much).
% \changes{v1.3}{2017/03/31}{Prefixed with MH\_}
% \begin{macrocode}
\def\MH_new_boolean:n #1{
\expandafter\@ifdefinable\csname MH_if_boolean_#1:\endcsname{
\@namedef{MH_boolean_#1_true:}
{\MH_let:cN{MH_if_boolean_#1:}\iftrue}
\@namedef{MH_boolean_#1_false:}
{\MH_let:cN{MH_if_boolean_#1:}\iffalse}
\@nameuse{MH_boolean_#1_false:}%
}
}
\def\MH_set_boolean_F:n #1{ \@nameuse{MH_boolean_#1_false:} }
\def\MH_set_boolean_T:n #1{ \@nameuse{MH_boolean_#1_true:} }
\def\MH_if_boolean:nTF #1{
\@nameuse{MH_if_boolean_#1:}
\expandafter\@firstoftwo
\MH_else:
\expandafter\@secondoftwo
\MH_fi:
}
\def\MH_if_boolean:nT #1{
\@nameuse{MH_if_boolean_#1:}
\expandafter\@firstofone
\MH_else:
\expandafter\@gobble
\MH_fi:
}
\def\MH_if_boolean:nF #1{
\@nameuse{MH_if_boolean_#1:}
\expandafter\@gobble
\MH_else:
\expandafter\@firstofone
\MH_fi:
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \changes{v1.3}{2017/03/31}{Prefixed all with MH\_}
% \begin{macro}{\MH_if:w}
% \changes{v1.0b}{2004/10/10}{Use different test}
% \begin{macro}{\MH_if_meaning:NN}
% \changes{v1.0b}{2004/10/10}{Use different test}
% \begin{macro}{\MH_else:}
% \changes{v1.0b}{2004/10/10}{Use different test}
% \begin{macro}{\MH_fi:}
% \changes{v1.0b}{2004/10/10}{Use different test}
% \begin{macro}{\MH_if_num:w}
% \changes{v1.0b}{2004/10/10}{Use different test}
% \changes{v1.2a}{2010/01/21}{Define at start of document}
% \begin{macro}{\MH_if_dim:w}
% \changes{v1.0b}{2004/10/10}{Use different test}
% \changes{v1.2a}{2010/01/21}{Define at start of document}
% \begin{macro}{\MH_if_case:w}
% \changes{v1.0b}{2004/10/10}{Use different test}
% \changes{v1.2a}{2010/01/21}{Define at start of document}
% \begin{macro}{\MH_or:}
% \changes{v1.0b}{2004/10/10}{Use different test}
% Copies of \TeX{} primitives.
% \begin{macrocode}
\@ifundefined{MH_if:w}{\MH_let:NwN \MH_if:w =\if}{}
\@ifundefined{MH_if_meaning:NN}{\MH_let:NwN \MH_if_meaning:NN =\ifx}{}
\@ifundefined{MH_else:}{\MH_let:NwN \MH_else:=\else}{}
\@ifundefined{MH_fi:}{\MH_let:NwN \MH_fi:=\fi}{}
\AtBeginDocument{
\@ifundefined{MH_if_num:w}{\MH_let:NwN \MH_if_num:w =\ifnum}{}
\@ifundefined{MH_if_dim:w}{\MH_let:NwN \MH_if_dim:w =\ifdim}{}
\@ifundefined{MH_if_case:w}{\MH_let:NwN \MH_if_case:w =\ifcase}{}
}
\@ifundefined{MH_or:}{\MH_let:NwN \MH_or:=\or}{}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\MH_cs_to_str:N}
% Strip off the backslash of a macro name.
% \begin{macrocode}
\def\MH_cs_to_str:N {\expandafter\@gobble\string}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\MH_protected:}
% \begin{macro}{\MH_setlength:dn}
% \changes{v1.0a}{2004/08/23}{Fixed bug in \cs{MH_setlength:dn} so that
% it now uses the \pkg{calc} definition of \cs{setlength}}
% \begin{macro}{\MH_addtolength:dn}
% \changes{v1.0a}{2004/08/23}{Fixed bug in \cs{MH_addtolength:dn} so that
% it now uses the \pkg{calc} definition of \cs{addtolength}}
% We might as well make use of some of the extended features from
% \eTeX. We use \cs{dimexpr} for some simple calculations as it
% saves a lot of the scanning that goes on inside \pkg{calc}. The
% \cs{protected} primitive comes in handy when we want to declare a
% robust command, that cannot be `robustified' with
% \cs{DeclareRobustCommand}. If we don't have \eTeX{} we'll just let
% our private macros be aliases for the less effective alternatives.
% \begin{macrocode}
\@ifundefined{eTeXversion}
{
\MH_let:NwN \MH_protected:\relax
\def\MH_setlength:dn{\setlength}
\def\MH_addtolength:dn{\addtolength}
}
{
\MH_let:NwN \MH_protected:\protected
\def\MH_setlength:dn #1#2{#1=\dimexpr#2\relax\relax}
\def\MH_addtolength:dn #1#2{\advance#1 \dimexpr#2\relax\relax}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\MH_keyval_alias_with_addon:nnnn}
% \begin{macro}{\MH_keyval_alias:nnn}
% A way to make aliases with \pkg{keyval}. This will come in
% handy later.
% \begin{macrocode}
\def\MH_keyval_alias_with_addon:nnnn #1#2#3#4{
\@namedef{KV@#1@#2}{\@nameuse{KV@#1@#3}#4}
\@namedef{KV@#1@#2@default}{\@nameuse{KV@#1@#3@default}#4}}
\def\MH_keyval_alias:nnn #1#2#3{
\MH_keyval_alias_with_addon:nnnn {#1}{#2}{#3}{}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\MH_use_choice_i:nnnn}
% \begin{macro}{\MH_use_choice_ii:nnnn}
% \begin{macro}{\MH_use_choice_iii:nnnn}
% \begin{macro}{\MH_use_choice_iv:nnnn}
% I need to be able to pick up individual arguments in a list of
% four (similar to \cs{@secondoftwo}).
% \begin{macrocode}
\def\MH_use_choice_i:nnnn #1#2#3#4{#1}
\def\MH_use_choice_ii:nnnn #1#2#3#4{#2}
\def\MH_use_choice_iii:nnnn #1#2#3#4{#3}
\def\MH_use_choice_iv:nnnn #1#2#3#4{#4}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\MH_nospace_ifnextchar:Nnn}
% \begin{macro}{\MH_nospace_nextchar:}
% \begin{macro}{\MH_nospace_testopt:nn}
% \begin{macro}{\MH_nospace_protected_testopt:n}
% Scanning for the next character but disallow spaces.
% \changes{v1.3}{2017/03/31}{Added MH\_ prefix to several \cs{if...} macros}
% \changes{v1.4}{2021/01/14}{Added
% \cs{MH\_group\_align\_safe\_begin/end:} as suggested by
% Phelype Oleinik in issue \#15. This enables
% \cs{MH\_nospace\_ifnextchar:Nnn} to work correctly inside nested alignments}
% \begin{macrocode}
\long\def\MH_nospace_ifnextchar:Nnn #1#2#3{
\MH_group_align_safe_begin: % added 2021/01/14
\MH_let:NwN\reserved@d=~#1
\def\reserved@a{\MH_group_align_safe_end: #2} % changed 2021/01/14
\def\reserved@b{\MH_group_align_safe_end: #3} % changed 2021/01/14
\futurelet\@let@token\MH_nospace_nextchar:
}
\def\MH_nospace_nextchar:{
\MH_if_meaning:NN \@let@token\reserved@d
\MH_let:NwN \reserved@b\reserved@a
\MH_fi:
\reserved@b
}
\long\def\MH_nospace_testopt:nn #1#2{
\MH_nospace_ifnextchar:Nnn[
{#1}
{#1[{#2}]}
}
\def\MH_nospace_protected_testopt:n #1{
\MH_if_meaning:NN \protect\@typeset@protect
\expandafter\MH_nospace_testopt:nn
\MH_else:
\@x@protect#1
\MH_fi:
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\kernel@ifnextchar}
% \begin{macro}{\MH_kernel_xargdef:nwwn}
% \begin{macro}{\MH_nospace_xargdef:nwwn}
% \begin{macro}{\MHPrecedingSpacesOff}
% \begin{macro}{\MHPrecedingSpacesOn}
% The code for the space sensitive peek ahead.
% \begin{macrocode}
\@ifundefined{kernel@ifnextchar}
{\MH_let:NwN \kernel@ifnextchar \@ifnextchar}
{}
\MH_let:NwN \MH_kernel_xargdef:nwwn \@xargdef
\long\def\MH_nospace_xargdef:nwwn #1[#2][#3]#4{
\@ifdefinable#1{
\expandafter\def\expandafter#1\expandafter{
\expandafter
\MH_nospace_protected_testopt:n
\expandafter
#1
\csname\string#1\endcsname
{#3}}
\expandafter\@yargdef
\csname\string#1\endcsname
\tw@
{#2}
{#4}}}
\providecommand*\MHPrecedingSpacesOff{
\MH_let:NwN \@xargdef \MH_nospace_xargdef:nwwn
}
\providecommand*\MHPrecedingSpacesOn{
\MH_let:NwN \@xargdef \MH_kernel_xargdef:nwwn
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\MH_group_align_safe_begin:}
% \begin{macro}{\MH_group_align_safe_end:}
% \begin{macrocode}
\def \MH_group_align_safe_begin: {\iffalse{\fi\ifnum0=`}\fi}
\def \MH_group_align_safe_end: {\ifnum0=`{}\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macrocode}
%</package>
% \end{macrocode}
%
% \Finale
\endinput