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