| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 1993-2025 |
| 4 |
% The LaTeX Project and any individual authors listed elsewhere |
| 5 |
% in this file. |
| 6 |
% |
| 7 |
% This file is part of the LaTeX base system. |
| 8 |
% ------------------------------------------- |
| 9 |
% |
| 10 |
% It may be distributed and/or modified under the |
| 11 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 12 |
% of this license or (at your option) any later version. |
| 13 |
% The latest version of this license is in |
| 14 |
% https://www.latex-project.org/lppl.txt |
| 15 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 16 |
% version 2008 or later. |
| 17 |
% |
| 18 |
% This file has the LPPL maintenance status "maintained". |
| 19 |
% |
| 20 |
% The list of all files belonging to the LaTeX base distribution is |
| 21 |
% given in the file `manifest.txt'. See also `legal.txt' for additional |
| 22 |
% information. |
| 23 |
% |
| 24 |
% The list of derived (unpacked) files belonging to the distribution |
| 25 |
% and covered by LPPL is defined by the unpacking scripts (with |
| 26 |
% extension .ins) which are part of the distribution. |
| 27 |
% |
| 28 |
% \fi |
| 29 |
% \iffalse |
| 30 |
%% |
| 31 |
%% File `ifthen.dtx'. |
| 32 |
%% Copyright (C) 1991 by Leslie Lamport |
| 33 |
%% Copyright (C) 1994-2025 LaTeX project, David Carlisle |
| 34 |
%% all rights reserved. |
| 35 |
%% |
| 36 |
% |
| 37 |
%<*dtx> |
| 38 |
\ProvidesFile{ifthen.dtx} |
| 39 |
%</dtx> |
| 40 |
%<package>\NeedsTeXFormat{LaTeX2e}[1994/12/01] |
| 41 |
%<package>\ProvidesPackage{ifthen} |
| 42 |
%<driver>\ProvidesFile{ifthen.drv} |
| 43 |
% \fi |
| 44 |
% \ProvidesFile{ifthen.dtx} |
| 45 |
[2024/03/16 v1.1e Standard LaTeX ifthen package (DPC)] |
| 46 |
% |
| 47 |
% \iffalse |
| 48 |
%<*driver> |
| 49 |
\documentclass{ltxdoc} |
| 50 |
\begin{document} |
| 51 |
\DocInput{ifthen.dtx} |
| 52 |
\end{document} |
| 53 |
%</driver> |
| 54 |
% \fi |
| 55 |
% |
| 56 |
% \GetFileInfo{ifthen.dtx} |
| 57 |
% |
| 58 |
% \title{The \textsf{ifthen} package\thanks{This file |
| 59 |
% has version number \fileversion, last |
| 60 |
% revised \filedate.}} |
| 61 |
% \author{David Carlisle} |
| 62 |
% \date{\filedate} |
| 63 |
% \MaintainedByLaTeXTeam{latex} |
| 64 |
% \maketitle |
| 65 |
% |
| 66 |
% |
| 67 |
% |
| 68 |
% \begin{abstract} |
| 69 |
% This file implements an |\ifthenelse| command for \LaTeXe. |
| 70 |
% The algorithm used is compatible with that used in the \LaTeX~2.09 |
| 71 |
% |ifthen| style option. It has been recoded, making the resulting |
| 72 |
% definitions somewhat more compact and efficient. |
| 73 |
% \end{abstract} |
| 74 |
% |
| 75 |
% \changes{v1.0a}{1993/10/15}{New implementation} |
| 76 |
% \changes{v1.0b}{1993/12/17}{Upgrade to LaTeX2e} |
| 77 |
% \changes{v1.0e}{1994/02/11}{Improve documentation} |
| 78 |
% \changes{v1.0f}{1994/03/02}{Remove need for dtx file} |
| 79 |
% \changes{v1.0g}{1994/03/14}{Modify for the new ltxdoc.cls} |
| 80 |
% \changes{v1.0k}{1995/04/25}{Fix `driver' docstrip guards.} |
| 81 |
% \changes{v1.0n}{1997/11/03}{Documentation fix.} |
| 82 |
% \changes{v1.0o}{1998/08/17}{Documentation fix.} |
| 83 |
% \changes{v1.1d}{2022/04/13}{Make reference command locally expandable.} |
| 84 |
% |
| 85 |
% \section{Introduction} |
| 86 |
% |
| 87 |
% \DescribeMacro{\ifthenelse} |
| 88 |
% |\ifthenelse{|^^A |
| 89 |
% \meta{test}|}{|\meta{then clause}|}{|\meta{else clause}|}| |
| 90 |
% |
| 91 |
% Evaluates \meta{test} as a boolean function, and then executes |
| 92 |
% either \meta{then clause} or \meta{else clause}. |
| 93 |
% |
| 94 |
% \meta{test} is a boolean expression using the infix connectives, |
| 95 |
% |\and|, |\or|, the unary |\not| and parentheses |\( \)|. |
| 96 |
% |
| 97 |
% As an alternative notation |\AND|, |\OR| and |\NOT| can be |
| 98 |
% used. This is safer since it can't be misinterpreted |
| 99 |
% when appearing inside a \TeX-conditional in which |\or| has a |
| 100 |
% different meaning. |
| 101 |
% |
| 102 |
% The atomic propositions are:\\ |
| 103 |
% \meta{number} |<| \meta{number} \\ |
| 104 |
% \meta{number} |=| \meta{number} \\ |
| 105 |
% \meta{number} |>| \meta{number} \\ |
| 106 |
% |\isodd{| \meta{number} |}|\\ |
| 107 |
% |\isundefined{| \meta{command name} |}|\\ |
| 108 |
% |\equal{|\meta{string}|}{|\meta{string}|}|\\ |
| 109 |
% |\lengthtest{|\meta{dimen}|<|\meta{dimen}|}|\\ |
| 110 |
% |\lengthtest{|\meta{dimen}|=|\meta{dimen}|}|\\ |
| 111 |
% |\lengthtest{|\meta{dimen}|>|\meta{dimen}|}|\\ |
| 112 |
% |\boolean{|\meta{name}|}| |
| 113 |
% |
| 114 |
% The \meta{string}s tested by |\equal| may be any sequence of commands |
| 115 |
% that expand to a list of tokens. If these expansions are equal, then |
| 116 |
% the proposition is true. |
| 117 |
% |
| 118 |
% |\isodd| is true if the \meta{number} is odd, and false otherwise |
| 119 |
% (even if the argument is not a number). |
| 120 |
% |
| 121 |
% |\isundefined{\cmd}| is true if |\cmd| is not defined. |
| 122 |
% |
| 123 |
% |\boolean{xyz}| returns the truth value contained in the primitive |
| 124 |
% \TeX\ |\if|, |\ifxyz|. This is usually used with boolean flags |
| 125 |
% created with |\newboolean| and |\provideboolean| described below. |
| 126 |
% It can also be used with the names of |\newif| created tokens, and |
| 127 |
% primitive \TeX\ |\if| constructs, for example |\boolean{true}| |
| 128 |
% (|\iftrue|), |\boolean{mmode}| (|\ifmmode|) etc. |
| 129 |
% |
| 130 |
% |
| 131 |
% The commands:\\ |
| 132 |
% |\newboolean|\marg{name}\DescribeMacro{\newboolean}\ and\ |
| 133 |
% |\provideboolean|\marg{name}\DescribeMacro{\provideboolean}\ |
| 134 |
% are provided so the user can easily create new boolean flags. |
| 135 |
% As for |\newcommand|, |\newboolean| generates an error if the |
| 136 |
% command name is not new. |\provideboolean| silently does nothing in |
| 137 |
% that case. |
| 138 |
% |
| 139 |
% The boolean flags may be set with:\\ |
| 140 |
% |\setboolean|\marg{name}\marg{value}\DescribeMacro{\setboolean}\\ |
| 141 |
% \meta{value} may be either |true| or |false| (any CaSe). |
| 142 |
% |
| 143 |
% Note that there is no precedence between |\and| and |\or|. |
| 144 |
% The proposition is evaluated in a left right manner. |\not| only |
| 145 |
% applies to the immediately following proposition. (This is consistent |
| 146 |
% with Lamport's |ifthen.sty|.) In this style, though the test is |
| 147 |
% `lazily' evaluated, so for instance if the first proposition in an |
| 148 |
% |\or| is true, the second one is skipped. (On the second pass---the |
| 149 |
% first pass in an |\edef| expands clauses in all propositions.) |
| 150 |
% |
| 151 |
% Apart from the addition of the extra atomic propositions |\isodd|, |
| 152 |
% |\boolean|, |\lengthtest| and |\isundefined|, |
| 153 |
% the only known incompatibility is that |
| 154 |
% in this package the expression|\not\not|\meta{P} is equivalent to |
| 155 |
% \meta{P}. |
| 156 |
% However in the original style it was equivalent to |\not|\meta{P}. |
| 157 |
% This is intentional (bug fix:-). |
| 158 |
% |
| 159 |
% \DescribeMacro{\whiledo} |
| 160 |
% The command |\whiledo| is also defined (copied directly from |
| 161 |
% the \LaTeX2.09 definition). |
| 162 |
% |
| 163 |
% |\whiledo{|\meta{test}|}{|\meta{while clause}|}| |
| 164 |
% |
| 165 |
% With \meta{test} as above, repeatedly executes \meta{while clause} |
| 166 |
% while the test remains true. |
| 167 |
% |
| 168 |
% \MaybeStop{} |
| 169 |
% |
| 170 |
% \section{The Implementation} |
| 171 |
% |
| 172 |
% \begin{macrocode} |
| 173 |
%<*package> |
| 174 |
% \end{macrocode} |
| 175 |
% |
| 176 |
% \begin{macro}{\TE@throw} |
| 177 |
% In order to support the syntax of |ifthen.sty|, which allows access |
| 178 |
% to the primitive \TeX\ syntax for a numeric test, rather than a |{}| |
| 179 |
% delimited argument form, it is most convenient to work `within' an |
| 180 |
% |\ifnum|. |\ift@throw| `throws' you out of the current |\ifnum| so |
| 181 |
% that you can (eg) start an |\ifdim| for the length tests. |
| 182 |
% \begin{macrocode} |
| 183 |
\def\TE@throw{\@ne=\@ne\noexpand\fi} |
| 184 |
% \end{macrocode} |
| 185 |
% \end{macro} |
| 186 |
% |
| 187 |
% \begin{macro}{\boolean} |
| 188 |
% A non-standard extension to |ifthen|, supporting boolean was |
| 189 |
% previously available, this is a simpler implementation. |
| 190 |
% \begin{macrocode} |
| 191 |
\def\boolean#1#2{% |
| 192 |
\TE@throw\expandafter\noexpand\csname if#1\endcsname#2} |
| 193 |
% \end{macrocode} |
| 194 |
% \end{macro} |
| 195 |
% |
| 196 |
% \begin{macro}{\TE@length} |
| 197 |
% Testing lengths. |#1| is the test. The extra argument gobbles spaces. |
| 198 |
% \begin{macrocode} |
| 199 |
\def\TE@length#1#2{\TE@throw\noexpand\ifdim#1#2} |
| 200 |
% \end{macrocode} |
| 201 |
% \end{macro} |
| 202 |
% |
| 203 |
% \begin{macro}{\TE@odd} |
| 204 |
% \begin{macro}{\TE@@odd} |
| 205 |
% Testing odd/even. This is true if |#1| is an odd number, and false |
| 206 |
% otherwise (even if |#1| is not a number at all). |
| 207 |
% |
| 208 |
% It is hard to make this completely reliable. Here I have erred on the |
| 209 |
% side of safety. This should not generate a \TeX\ error if given any |
| 210 |
% robust commands as its argument. However it returns true on any |
| 211 |
% argument that \emph{starts} with an odd number |11xx| which is bad, |
| 212 |
% and it can not deal with \TeX's count registers, although \LaTeX\ |
| 213 |
% counters work (via |\value|). |
| 214 |
% \changes{v1.0b}{1993/12/17}{Improve \cs{isodd}.} |
| 215 |
% \changes{v1.0c}{1994/01/20}{Improve \cs{isodd} again.} |
| 216 |
% \begin{macrocode} |
| 217 |
\def\TE@odd#1#2{% |
| 218 |
\TE@throw\noexpand\TE@@odd#1\noexpand\@nil\noexpand\ifodd\count@#2} |
| 219 |
% \end{macrocode} |
| 220 |
% |
| 221 |
% |\TE@@odd| is not expanded on the first pass. |
| 222 |
% \begin{macrocode} |
| 223 |
\def\TE@@odd#1#2\@nil{% |
| 224 |
\@defaultunits |
| 225 |
\count@\if-#1-0\else0\expandafter#1\fi#2\relax\@nnil} |
| 226 |
% \end{macrocode} |
| 227 |
% \end{macro} |
| 228 |
% \end{macro} |
| 229 |
% |
| 230 |
% \begin{macro}{\TE@repl} |
| 231 |
% |\TE@repl| replaces the single token |#1| by |#2|. (Not within |{}| |
| 232 |
% groups.) It is used to replace |\or| by |\TE@or| without the need to |
| 233 |
% redefine |\or|. Earlier versions just |\let\or\TE@or| but this has a |
| 234 |
% bad effect on the expansion of commands which use the primitive |
| 235 |
% |\or| internally, eg |\alph|, and so caused surprising results if |
| 236 |
% these commands were used inside |\equal|. |
| 237 |
% \changes{v1.0h}{1994/05/14}{macro added} |
| 238 |
% \begin{macrocode} |
| 239 |
\def\TE@repl#1#2{% |
| 240 |
\long\def\@tempc##1#1##2{% |
| 241 |
\def\@tempa{##2}\def\@tempb{\@tempc}% |
| 242 |
\ifx\@tempa\@tempb |
| 243 |
\toks@\expandafter{\the\toks@##1}% |
| 244 |
\expandafter\@gobble |
| 245 |
\else |
| 246 |
\toks@\expandafter{\the\toks@##1#2}% |
| 247 |
\expandafter\@tempc |
| 248 |
\fi |
| 249 |
##2}% |
| 250 |
\expandafter\toks@\expandafter{\expandafter}% |
| 251 |
\expandafter\@tempc\the\toks@#1\@tempc} |
| 252 |
% \end{macrocode} |
| 253 |
% \end{macro} |
| 254 |
% |
| 255 |
% |
| 256 |
% \begin{macro}{\ifthenelse} |
| 257 |
% The remaining macros in this file are derived from the ones in |
| 258 |
% |ifthen.sty| but recoded and simplified. The main simplification is |
| 259 |
% that the original style (and the |\boolean| extensions) expressed |
| 260 |
% logical values always in terms of |\ifnum|. As |\fi| is `untyped' this |
| 261 |
% is not necessary, so for example the length tests can return values |
| 262 |
% via |\ifdim|, the trailing |\fi| will not complain, even though it was |
| 263 |
% `expecting' an |\ifnum|. Also the system of passing information via |
| 264 |
% macros expanding to |T| or |F| has been completely replaced by a |
| 265 |
% simpler system using |\iftrue|, which furthermore allows lazy |
| 266 |
% evaluation on the second pass. |
| 267 |
% With a LaTeX 2022/06/01 we have to ensure that |\pageref| is expandable. |
| 268 |
% \begin{macrocode} |
| 269 |
\@ifl@t@r\fmtversion{2022/06/01} |
| 270 |
{\def\TE@ref@exp{\let\pageref\@kernel@pageref@exp |
| 271 |
\let\ref\@kernel@ref@exp}} |
| 272 |
{\def\TE@ref@exp{\def\@setref##1##2##3{% |
| 273 |
\ifx##1\relax\z@\else\expandafter##2##1\fi}}} |
| 274 |
% \end{macrocode} |
| 275 |
% \begin{macrocode} |
| 276 |
\begingroup |
| 277 |
\lccode`\~`\> % |
| 278 |
\catcode`\+\active |
| 279 |
\lccode`\+`\< % |
| 280 |
\catcode`\!\active |
| 281 |
\lccode`\!`\= % |
| 282 |
\lowercase{\endgroup |
| 283 |
% \end{macrocode} |
| 284 |
% \begin{macrocode} |
| 285 |
\def\TE@repl@active{% |
| 286 |
\TE@repl~>% |
| 287 |
\TE@repl+<% |
| 288 |
\TE@repl!=% |
| 289 |
} |
| 290 |
% \end{macrocode} |
| 291 |
% \begin{macrocode} |
| 292 |
\long\def\ifthenelse#1{% |
| 293 |
% \end{macrocode} |
| 294 |
% \changes{v1.0h}{1994/05/14}{Use \cs{TE@repl}} |
| 295 |
% \changes{v1.1e}{2024/03/16}{replace active \cs{ifnum} syntax} |
| 296 |
% \begin{macrocode} |
| 297 |
\toks@{#1}% |
| 298 |
\TE@repl\or\TE@or |
| 299 |
\TE@repl\and\TE@and |
| 300 |
\TE@repl\not\TE@neg |
| 301 |
% \end{macrocode} |
| 302 |
% \begin{macrocode} |
| 303 |
\TE@repl@active |
| 304 |
% \end{macrocode} |
| 305 |
% |
| 306 |
% \changes{v1.1c}{2001/05/25}{Added \cs{AND}, \cs{OR} and \cs{NOT} as |
| 307 |
% boolean operators as alternative to the lower case versions |
| 308 |
% (pr/3297)} |
| 309 |
% Support alternate names for the boolean operators (strictly |
| 310 |
% speaking only |\OR| would be necessary). |
| 311 |
% \begin{macrocode} |
| 312 |
\TE@repl\OR\TE@or |
| 313 |
\TE@repl\AND\TE@and |
| 314 |
\TE@repl\NOT\TE@neg |
| 315 |
% \end{macrocode} |
| 316 |
% The original |ifthen.sty| processed everything inside a box |
| 317 |
% assignment, to catch any extra spaces before they appeared in the |
| 318 |
% output. Instead I have added extra arguments to the commands so they |
| 319 |
% each remove any following space. |
| 320 |
% |
| 321 |
% Set up the user level names |\not| etc. |
| 322 |
% \changes{v1.0c}{1994/01/20}{Modify \cs{protect} and \cs{value}} |
| 323 |
% \changes{v1.0j}{1994/11/15}{Modify \cs{protect} add \cs{@setref}} |
| 324 |
% \changes{v1.0l}{1996/03/22} |
| 325 |
% {Use \cs{begingroup} not \cs{bgroup} for latex/2105} |
| 326 |
% \changes{v1.1a}{1999/01/07}{\cs{isundefined} added for /2824} |
| 327 |
% \changes{v1.1d}{2022/04/13}{changed method to make \cs{pageref} and \cs{ref} locally expandable.} |
| 328 |
% \begin{macrocode} |
| 329 |
\begingroup |
| 330 |
\let\protect\@unexpandable@protect |
| 331 |
\TE@ref@exp |
| 332 |
\def\value##1{\the\csname c@##1\endcsname}% |
| 333 |
\let\equal\TE@equal \let\(\TE@lparen \let\)\TE@rparen |
| 334 |
\let\isodd\TE@odd \let\lengthtest\TE@length |
| 335 |
\let\isundefined\TE@undef |
| 336 |
% \end{macrocode} |
| 337 |
% For the first pass, in a group, make various tokens non-expandable. |
| 338 |
% |
| 339 |
% It is unfortunate that in order to remain compatible with |ifthen| |
| 340 |
% syntax, it is necessary to have a two pass system. The first pass |
| 341 |
% inside an |\edef| `exposes' the |\if|\ldots\ |\fi| tokens, so the |
| 342 |
% correct clauses may be skipped on the second pass. This means that the |
| 343 |
% whole |\ifthenelse| command does not work by expansion, and so |
| 344 |
% possibly has only limited usefulness for macro code writers. |
| 345 |
% The main problem with the |ifthen:| syntax is that (unique for \LaTeX) |
| 346 |
% it does not uses a brace delimited argument form, and exposes the |
| 347 |
% primitive \TeX\ syntax for \meta{number}. Pretty much the only way of |
| 348 |
% parsing |1 > 2 \or 2 < 1| is to actually evaluate the primitive |
| 349 |
% |\ifnum|s. A syntax such as:\\% |
| 350 |
% |\or{\numtest{1<2}}{\lengthtest{1pt<1in}}|\\ |
| 351 |
% could easily be evaluated in a one pass way, operating directly via |
| 352 |
% expansion, and leaving no extra tokens in the token stream. |
| 353 |
% |
| 354 |
% Still, on with the code\ldots\ make |\@tempa| and |\@tempb| tokens |
| 355 |
% non-expandable on the first pass. |
| 356 |
% \changes{v1.0l}{1996/03/22} |
| 357 |
% {Use \cs{begingroup} not \{ for latex/2105} |
| 358 |
% \begin{macrocode} |
| 359 |
\begingroup |
| 360 |
\let\@tempa\relax\let\@tempb\relax |
| 361 |
\xdef\@gtempa{\expandafter\TE@eval\the\toks@\TE@endeval}% |
| 362 |
\endgroup |
| 363 |
% \end{macrocode} |
| 364 |
% Now outside the group, execute |\@gtempa| which causes all the |
| 365 |
% |\if|s etc., to be evaluated, the final truth value is contained in |
| 366 |
% the |\newif| token |\ifTE@val|. Finally this is tested and either the |
| 367 |
% first or second following argument is chosen accordingly. |
| 368 |
% \changes{v1.0d}{1994/01/24} |
| 369 |
% {Use \cs{@firstoftwo} not \cs{@leftmark}.} |
| 370 |
% \begin{macrocode} |
| 371 |
\@gtempa |
| 372 |
\expandafter\endgroup\ifTE@val |
| 373 |
\expandafter\@firstoftwo |
| 374 |
\else |
| 375 |
\expandafter\@secondoftwo |
| 376 |
\fi}% |
| 377 |
% \end{macrocode} |
| 378 |
% \begin{macrocode} |
| 379 |
} |
| 380 |
% \end{macrocode} |
| 381 |
% \end{macro} |
| 382 |
% |
| 383 |
% \begin{macro}{\TE@eval} |
| 384 |
% Initialise a term. (Expanded on the first pass). |
| 385 |
% \begin{macrocode} |
| 386 |
\def\TE@eval{\noexpand\TE@negatefalse\noexpand\iftrue\noexpand\ifnum} |
| 387 |
% \end{macrocode} |
| 388 |
% \end{macro} |
| 389 |
% |
| 390 |
% \begin{macro}{\ifTE@val} |
| 391 |
% \begin{macro}{\ifTE@negate} |
| 392 |
% Two |\newif|s the first holds the current truth value of the |
| 393 |
% expression. The second is a temporary flag which is true if we need to |
| 394 |
% negate the current proposition. |
| 395 |
% \begin{macrocode} |
| 396 |
\newif\ifTE@val |
| 397 |
\newif\ifTE@negate |
| 398 |
% \end{macrocode} |
| 399 |
% \end{macro} |
| 400 |
% \end{macro} |
| 401 |
% |
| 402 |
% \begin{macro}{\TE@endeval} |
| 403 |
% Finalize a term. (Expanded on the first pass). |
| 404 |
% \begin{macrocode} |
| 405 |
\def\TE@endeval{\relax |
| 406 |
\noexpand\TE@setvaltrue\noexpand |
| 407 |
\else |
| 408 |
\noexpand\TE@setvalfalse\noexpand |
| 409 |
\fi |
| 410 |
\noexpand\TE@negatefalse\noexpand |
| 411 |
\fi} |
| 412 |
% \end{macrocode} |
| 413 |
% \end{macro} |
| 414 |
% |
| 415 |
% \begin{macro}{\TE@setvaltrue} |
| 416 |
% \begin{macro}{\TE@setvalfalse} |
| 417 |
% Set the |\ifTE@val| to true or false depending on the value of the |
| 418 |
% current proposition, and the negate flag. (Not expanded on the first |
| 419 |
% pass.) |
| 420 |
% \begin{macrocode} |
| 421 |
\def\TE@setvaltrue{% |
| 422 |
\ifTE@negate\TE@valfalse\else\TE@valtrue\fi} |
| 423 |
\def\TE@setvalfalse{\let\ifTE@val\ifTE@negate} |
| 424 |
% \end{macrocode} |
| 425 |
% \end{macro} |
| 426 |
% \end{macro} |
| 427 |
% |
| 428 |
% \begin{macro}{\TE@or} |
| 429 |
% The internal version of |\or|. Ends the current term. |
| 430 |
% If true skip the remaining terms. |
| 431 |
% \begin{macrocode} |
| 432 |
\def\TE@or{\TE@endeval\noexpand\ifTE@val\noexpand\else\noexpand\ifnum} |
| 433 |
% \end{macrocode} |
| 434 |
% \end{macro} |
| 435 |
% |
| 436 |
% \begin{macro}{\TE@and} |
| 437 |
% The internal version of |\and|. If false skip the remaining terms. |
| 438 |
% \begin{macrocode} |
| 439 |
\def\TE@and{\TE@endeval\noexpand\ifTE@val\noexpand\ifnum} |
| 440 |
% \end{macrocode} |
| 441 |
% \end{macro} |
| 442 |
% |
| 443 |
% \begin{macro}{\TE@neg} |
| 444 |
% \begin{macro}{\TE@negswitch} |
| 445 |
% |\not|. Throw the current context, set a negate flag, then restart |
| 446 |
% the |\ifnum|. |\TE@negswitch| is not expanded on the first pass. |
| 447 |
% \begin{macrocode} |
| 448 |
\def\TE@neg{\TE@throw\noexpand\TE@negswitch\noexpand\ifnum} |
| 449 |
\def\TE@negswitch{\ifTE@negate\TE@negatefalse\else\TE@negatetrue\fi} |
| 450 |
% \end{macrocode} |
| 451 |
% \end{macro} |
| 452 |
% \end{macro} |
| 453 |
% |
| 454 |
% \begin{macro}{\TE@lparen} |
| 455 |
% |\(|. Throw the current context, then restart a term inside a group. |
| 456 |
% \begin{macrocode} |
| 457 |
\def\TE@lparen#1{\TE@throw\begingroup\TE@eval#1} |
| 458 |
% \end{macrocode} |
| 459 |
% \end{macro} |
| 460 |
% |
| 461 |
% \begin{macro}{\TE@rparen} |
| 462 |
% |\)| end the current term, and the local group started by |\(|, but |
| 463 |
% pass on the boolean value in |\if\@val T|. The |\noexpand| stops the |
| 464 |
% |\expandafter| from expanding on the first pass. |
| 465 |
% \begin{macrocode} |
| 466 |
\def\TE@rparen#1{% |
| 467 |
\TE@endeval |
| 468 |
\noexpand\expandafter\endgroup\noexpand\ifTE@val#1} |
| 469 |
% \end{macrocode} |
| 470 |
% \end{macro} |
| 471 |
% |
| 472 |
% \begin{macro}{\TE@equal} |
| 473 |
% |\equal| greatly simplified from the original. |\def| may be used |
| 474 |
% rather than |\edef| as the whole thing is expanded anyway in the |
| 475 |
% first pass. The boolean can be directly encoded with the |\ifx|, |
| 476 |
% there is no need to start an equivalent |\ifnum|. |
| 477 |
% \changes{v1.0h}{1994/05/14}{make long} |
| 478 |
% \begin{macrocode} |
| 479 |
\long\def\TE@equal#1#2#3{\TE@throw |
| 480 |
\def\@tempa{#1}\def\@tempb{#2}% |
| 481 |
\noexpand\ifx\@tempa\@tempb#3} |
| 482 |
% \end{macrocode} |
| 483 |
% \end{macro} |
| 484 |
% |
| 485 |
% \begin{macro}{\setboolean} |
| 486 |
% |\setboolean| takes |true| or |false|, as |#2|, and sets |#1| |
| 487 |
% accordingly. |
| 488 |
% \changes{v1.0i}{1994/05/27}{New style error commands} |
| 489 |
% \begin{macrocode} |
| 490 |
\def\setboolean#1#2{% |
| 491 |
\lowercase{\def\@tempa{#2}}% |
| 492 |
\@ifundefined{@tempswa\@tempa}% |
| 493 |
{\PackageError{ifthen}% |
| 494 |
{You can only set a boolean to `true' or `false'}\@ehc}% |
| 495 |
{\@ifundefined{#1\@tempa}% |
| 496 |
{\PackageError{ifthen}{Boolean #1 undefined}\@ehc}% |
| 497 |
{\csname#1\@tempa\endcsname}}} |
| 498 |
% \end{macrocode} |
| 499 |
% \end{macro} |
| 500 |
% |
| 501 |
% \begin{macro}{\newboolean} |
| 502 |
% \changes{v1.0m}{1996/08/02}{Add \cs{@ifdefinable} test for latex/2220} |
| 503 |
% Define a new `boolean'. |
| 504 |
% \begin{macrocode} |
| 505 |
\def\newboolean#1{% |
| 506 |
\expandafter\@ifdefinable\csname if#1\endcsname{% |
| 507 |
\expandafter\newif\csname if#1\endcsname}} |
| 508 |
% \end{macrocode} |
| 509 |
% \end{macro} |
| 510 |
% |
| 511 |
% \begin{macro}{\provideboolean} |
| 512 |
% \changes{v1.0m}{1996/08/02}{Macro added for latex/2220} |
| 513 |
% Define a new `boolean' if it is not already defined. |
| 514 |
% \begin{macrocode} |
| 515 |
\def\provideboolean#1{% |
| 516 |
\@ifundefined{if#1}{% |
| 517 |
\expandafter\newif\csname if#1\endcsname}\relax} |
| 518 |
% \end{macrocode} |
| 519 |
% \end{macro} |
| 520 |
% |
| 521 |
% \begin{macro}{\whiledo} |
| 522 |
% |\whiledo| copied directly from the original.\\ |
| 523 |
% |\whiledo{|\meta{test}|}{|\meta{body}|}|\\ |
| 524 |
% repeatedly evaluates \meta{body} until \meta{test} is true. |
| 525 |
% \begin{macrocode} |
| 526 |
\long\def\whiledo#1#2{% |
| 527 |
\ifthenelse{#1}% |
| 528 |
{\@whiledotrue |
| 529 |
\@whilesw\if@whiledo\fi |
| 530 |
{#2% |
| 531 |
\ifthenelse{#1}\@whiledotrue\@whiledofalse}}% |
| 532 |
{}% |
| 533 |
} |
| 534 |
% \end{macrocode} |
| 535 |
% \end{macro} |
| 536 |
% |
| 537 |
% \begin{macro}{\TE@undef} |
| 538 |
% \changes{v1.1a}{1999/01/07}{Macro added for /2824} |
| 539 |
% test if csname is defined. |\ifx| test. |
| 540 |
% \begin{macrocode} |
| 541 |
\def\TE@undef#1#2{% |
| 542 |
\TE@throw\noexpand\ifx\noexpand\@undefined\noexpand#1#2} |
| 543 |
% \end{macrocode} |
| 544 |
% \end{macro} |
| 545 |
% |
| 546 |
% \begin{macro}{\if@whiledo} |
| 547 |
% Internal switch for |\whiledo|. |
| 548 |
% \begin{macrocode} |
| 549 |
\newif\if@whiledo |
| 550 |
% \end{macrocode} |
| 551 |
% \end{macro} |
| 552 |
% |
| 553 |
% \begin{macrocode} |
| 554 |
%</package> |
| 555 |
% \end{macrocode} |
| 556 |
% |
| 557 |
% \Finale |
| 558 |
\endinput |