Debian Codegraph @

texmf-dist/doc/latex/xifthen/xifthen.tex

raw
1 \documentclass{article}
2
3 \usepackage{etex}
4 \usepackage{xifthen}
5 \usepackage[utf8]{inputenc}
6 \usepackage[T1]{fontenc}
7 \usepackage[warn]{textcomp}
8 \usepackage[a4paper, pdftex, margin=1.5in]{geometry}
9 \usepackage{lmodern}
10 \usepackage{microtype}
11 \usepackage{xcolor}
12 \usepackage{url}
13 \usepackage[bottom,hang]{footmisc}
14 \usepackage[babel]{csquotes}
15 \usepackage[british]{babel}
16 \usepackage{hyperref}
17
18 \newcommand*{\cmd}[1]{\tex{\textbackslash #1}}
19 \newcommand*{\tex}{\texttt}
20 \newenvironment*{texcode}{\list{}{}\item\ttfamily}{\endlist}
21 \newcommand*{\marg}[1]{\{\meta{#1}\}}
22 \newcommand*{\oarg}[1]{[\meta{#1}]}
23 \newcommand*{\meta}[1]{\textnormal{\textlangle#1\textrangle}}
24
25 \setcounter{secnumdepth}{-\maxdimen}
26
27 \makeatletter
28 \newcommand*{\1}{$_1\m@th$}
29 \newcommand*{\2}{$_2\m@th$}
30
31 % Borrowed from doc.sty
32 \newcommand*{\getfileinfo}[1]{%
33 \def \filename {#1}%
34 \def \@tempb ##1 ##2 ##3\relax ##4\relax {%
35 \def \filedate {##1}%
36 \def \fileversion {##2}%
37 \def \fileinfo {##3}%
38 }%
39 \edef \@tempa {\csname ver@#1\endcsname}%
40 \expandafter \@tempb \@tempa \relax ? ? \relax \relax
41 }
42 \makeatother
43
44 \newenvironment*{texdescription}{%
45 \list{}{%
46 \setlength{\labelwidth}{0pt}%
47 \setlength{\itemindent}{-\leftmargin}%
48 \setlength{\itemsep}{0pt}%
49 \renewcommand*{\makelabel}[1]%
50 {\hspace{\labelsep}\normalfont\tex{\texmonospaces ##1}}%
51 }%
52 }{%
53 \endlist
54 }
55
56 \newcommand*{\pack}{\textsf}
57 \newcommand*{\true}{\emph{true}}
58 \newcommand*{\false}{\emph{false}}
59
60 \newtest \condition [2]{%
61 \cnttest{(#1)*(#2)}>{100}%
62 \AND
63 \cnttest{((#1)+(#2))*2}<{60}%
64 }
65
66 \getfileinfo{xifthen.sty}
67 \title {The \pack{xifthen} package}
68 \author {Josselin Noirel\footnote{This document corresponds to version
69 \fileversion\ (\filedate) of \pack{\filename}.}\\%
70 \url{https://github.com/JosselinNoirel/xifthen}}
71
72 \begin{document}
73
74 \maketitle
75
76 \begin{abstract}
77 This package implements new commands that can be used within the
78 first argument of \pack{ifthen}'s \cmd{ifthenelse} to test whether a
79 string is void or not, if a command is defined or equivalent to
80 another. It includes also the possibility to make use of the
81 complex expressions introduced by the package~\pack{calc}, together
82 with the ability of defining new commands to handle complex tests.
83 This package requires the \eTeX{} features.
84 \end{abstract}
85
86 \tableofcontents
87
88 \section{What's new}
89
90 \begin{itemize}
91 \item [1.1] Now \cmd{cnttest} and \cmd{dimtest} accept \tex{<=} and \tex{>=}.
92 \item I~renamed \cmd{terminateswith} in \cmd{endswith}.
93
94 \addvspace{\baselineskip}
95
96 \item [1.2] Corrected a~bug related to a~bad interaction between
97 new~tests and ifthen's replacement macro (credits go to MPG \&
98 P.~Albar\`ede).
99
100 \addvspace{\baselineskip}
101
102 \item [1.3] Removed a spurious space (thanks to Ulrike Fisher).
103
104 \item [1.4.0] Removed the reliance on the \cmd{etex} package, following
105 an exmail exchange with David Carlisle and Maïeul Rouquette.
106 (I also updated the documentation and pushed the files on GitHub.)
107 \end{itemize}
108
109 \section{\pack{ifthen}'s interface}
110
111 \subsection{Declaring and setting booleans}
112
113 You can declare boolean (presumably in the preamble of your document) with
114 %
115 \begin{texcode}
116 \cmd{newboolean}\marg{boolean}
117 \end{texcode}
118 %
119 where \meta{boolean} is a name made up of alphanumeric characters.
120 For instance,
121 %
122 \begin{texcode}
123 \cmd{newboolean}\{appendix\}\\
124 \cmd{first}\{appendix\}
125 \end{texcode}
126 %
127 Then your boolean is ready to be set with
128 %
129 \begin{texcode}
130 \cmd{setboolean}\marg{boolean}\marg{truth value}
131 \end{texcode}
132 %
133 where \meta{truth value} can be \tex{true} or \tex{false}.
134
135 \subsection{Executing conditional code}
136
137 The general syntax is inherited of that of the package~\pack{ifthen}:
138 %
139 \begin{texcode}
140 \cmd{ifthenelse}\marg{test expression}\marg{true code}\marg{false code}
141 \end{texcode}
142 %
143 Evaluates the \meta{test expression} and executes \meta{true code} if the
144 test turns out to be true and \meta{false code} otherwise. \pack{ifthen}
145 provides the tests explained in the next paragraphs.
146
147 \paragraph{Value of a~boolean}
148
149 You can use the value of a~boolean you declared, or the value of
150 a~primitive boolean of \TeX\footnote{The primitive booleans include:
151 \tex{mmode} (Are we in math mode?), \tex{hmode} (Are we in
152 horizontal mode?), \tex{vmode} (Are we in vertical mode?),~etc.}
153 %
154 \begin{texcode}
155 \cmd{boolean}\marg{boolean}
156 \end{texcode}
157
158 \paragraph{Tests on integers}
159
160 To test whether an~integer is equal to, strictly less than, or
161 strictly greater than, you write the expression straightforwardly.
162 %
163 \begin{list}{}{}
164 \item \tex{\meta{value\1} = \meta{value\2}}
165 \item \tex{\meta{value\1} < \meta{value\2}}
166 \item \tex{\meta{value\1} > \meta{value\2}}
167 \item \tex{\textbackslash isodd\marg{number}}
168 \end{list}
169
170 \paragraph{Tests on lengths}
171
172 There exist similar tests for the lengths, but you need in this case
173 to surround the whole expression with \cmd{lengthtest}.
174 %
175 \begin{list}{}{}
176 \item \tex{\cmd{lengthtest}\{\meta{dimen\1} = \meta{dimen\2}\}}
177 \item \tex{\cmd{lengthtest}\{\meta{dimen\1} < \meta{dimen\2}\}}
178 \item \tex{\cmd{lengthtest}\{\meta{dimen\1} > \meta{dimen\2}\}}
179 \end{list}
180
181 \paragraph{Tests on commands}
182
183 You can test if a command is undefined\footnote{This test differs from
184 \cmd{@ifundefined} in that it takes a~real command---and not
185 a~command name---as argument, and also in that command which is let
186 equal to \cmd{relax} is not considered undefined.}.
187 %
188 \begin{list}{}{}
189 \item \tex{\cmd{isundefined}\marg{command}}
190 \end{list}
191
192 \paragraph{Tests on character strings}
193
194 You want to know whether two character strings are equal? Use:
195 %
196 \begin{texcode}
197 \cmd{equal}\marg{string\1}\marg{string\2}
198 \end{texcode}
199 %
200 Remark that the two arguments are fully expanded. In other words, it
201 is the result of the expansion of the macros that is compared. This
202 behaviour also entails a~moving argument and you should protect
203 fragile command to avoid bizarre errors\footnote{Practically, the
204 fact that the content is expanded, means that if the macro \cmd{bar}
205 is defined as \tex{\cmd{baz}\{o\}}, and the command \cmd{baz} is defined
206 as \tex{f\#1\#1}, then \tex{\cmd{equal}\{\cmd{bar}\}\{foo\}} turns out to
207 be true, because \cmd{bar} eventually expands into \tex{foo}. This is
208 usually the desired behaviour.}.
209
210 \paragraph{Building more elaborated expressions}
211
212 You can build more sophisticated expressing using the \cmd{AND}
213 (conjunction), \cmd{OR} (disjunction), and \cmd{NOT} (negation)
214 operators\footnote{Lowercase versions of these commands also exist but
215 we advise the user to stick to the uppercase ones because \cmd{or}
216 is part of \TeX's syntax.}.
217 %
218 \begin{list}{}{}
219 \item \meta{expression\1} \cmd{AND} \meta{expression\2}
220 \item \meta{expression\1} \cmd{OR} \ \meta{expression\2}
221 \item \cmd{NOT} \meta{expression}
222 \end{list}
223 %
224 The evaluation is lazy, meaning that if you write
225 %
226 \begin{texcode}
227 \meta{expression\1} \cmd{AND} \meta{expression\2}
228 \end{texcode}
229 %
230 then \meta{expression\2} won't be evaluated if \meta{expression\1} is
231 true\footnote{The devil is in the details, however: \pack{ifthen} works by
232 reading its argument twice. The tests are evaluated on the second
233 pass, but the expansion is performed on the first one, regardless of
234 the truth value.}.
235
236 There is not precedence rules: the argument is read from left to right
237 and \cmd{NOT} applies to the very next test. When the precedence must
238 be changed you can use the parentheses:
239 %
240 \begin{texcode}
241 \cmd{(}\meta{expression}\cmd{)}
242 \end{texcode}
243
244 \section{New tests}
245
246 After this brief review of \pack{ifthen}'s principles, we introduce
247 the new tests provided by \pack{xifthen}.
248
249 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
250 \paragraph{Tests on integers}
251
252 One of the drawback of \TeX's tests and of \cmd{ifthen}'s as well, is
253 the impossibility to use \pack{calc}'s syntax in it. The
254 \cmd{numexpr} primitive of \eTeX\ somehow allows to overcome this
255 difficulty but it is not well documented and normal users are
256 certainly more familiar with the capabilities offered by \pack{calc}.
257 The \pack{xifthen} package allows to use \pack{calc}-valid expressions
258 via the new test \cmd{cnttest}. The syntax is as follows:
259 %
260 \begin{texcode}
261 \cmd{cnttest}\marg{counter expression\1}\marg{comparison}%
262 \marg{counter expression\2}
263 \end{texcode}
264 %
265 It evaluates the two counter expressions, compares them, and returns
266 the value of the test. The comparison can be one of the following
267 sequences \tex{<}, \tex{>}, \tex{=}, \tex{<=},~or~\tex{>=}.
268
269 \paragraph{Tests on lengths}
270
271 The similar test has been designed for the lengths and dimensions:
272 %
273 \begin{texcode}
274 \cmd{dimtest}\marg{dimen expression\1}\marg{comparison}%
275 \marg{dimen expression\2}
276 \end{texcode}
277 %
278 It evaluates the two dimension expressions, compares them, and returns
279 the value of the test. The comparison can be one of the following
280 sequences \tex{<}, \tex{>}, \tex{=}, \tex{<=},~or~\tex{>=}.
281
282 \paragraph{Tests on commands}
283
284 We define a~companion of \cmd{isundefined} that uses a~command name
285 rather than a~command\footnote{If you are stuck with the distinction
286 between `command' and `command name', let me explain it further with
287 an example: the command name of the command \cmd{foo} is \tex{foo}.
288 This is sometimes more convenient to use the command name than the
289 name. Still, this functionality is probably intended more for
290 experienced programmers who want to use the niceties of
291 \pack{ifthen} and \pack{xifthen}.}.
292 %
293 \begin{texcode}
294 \cmd[1,syntax]{isnamedefined}{command name}
295 \end{texcode}
296 %
297 Returns \true\ if the command \cmd{\meta{command name}} is defined\footnote{%
298 Uses \tex{\cmd{ifcsname}\dots\allowbreak\cmd{endcsname}} internally
299 and not \cmd{@ifundefined}.}.
300
301 Sometimes, you need to compare two macros \cmd{foo} and \cmd{bar} and
302 test whether they are actually the same macro.
303 %
304 \begin{texcode}
305 \cmd{isequivalentto}\marg{command\1}\marg{command\2}
306 \end{texcode}
307 %
308 Corresponds to the \cmd{ifx} test: it returns \true\ when the two
309 commands are exactly equivalent (same definition, same number of
310 arguments, same prefixes, etc., otherwise \false\ is returned).
311
312 \paragraph{Tests on character strings}
313
314 Very often, we see people using \cmd[2]{equal}{\#1}{} in their command
315 definitions (for instance, to test whether an optional argument had
316 been passed to their macro). A~more efficient test can be used:
317 %
318 \begin{texcode}
319 \cmd{isempty}\marg{content}
320 \end{texcode}
321 %
322 Returns \true\ if \meta{content} is empty. It is essentially equivalent to
323 \tex{\cmd{equal}\{\meta{content}\}\{\}} except that the argument of
324 \cmd{isempty} isn't expanded and therefore isn't affected by fragile
325 commands\footnote{Internally, it uses \cmd{unexpanded} and \pack{ifmtarg}.}.
326
327 It is possible to test whether a~substring appears within another
328 string\footnote{Uses \cmd{in@} and \cmd{ifin@} internally.}.
329 %
330 \begin{texcode}
331 \cmd{isin}\marg{substring}\marg{string}
332 \end{texcode}
333
334 Sometimes, you need to check whether a~string ends with a particular
335 substring. This can be achieved using\footnote{For compatibility
336 reasons, there exist a~command unfortunately called
337 \cmd{terminateswith} that performs the same test but it is
338 deprecated.}:
339 %
340 \begin{texcode}
341 \cmd{endswith}\marg{string}\marg{substring}
342 \end{texcode}
343
344 \paragraph{Building more elaborated expressions}
345 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
346
347 It is then possible to create new tests with:
348 %
349 \begin{texcode}
350 \cmd{newtest}\marg{command}[$n$]\marg{test expression}
351 \end{texcode}
352 %
353 Surprisingly, a~simple \cmd{newcommand} would not work. The
354 \cmd{newtest} macro defines a command \meta{command} taking
355 $n$~arguments (no optional argument is allowed\footnote{No optional
356 argument is allowed because the macro needs to be expanded in the
357 first pass and that optional arguments avoid that.} consisting of
358 the test as specified by \meta{test expression} that can be used in
359 the argument of \cmd{ifthenelse}.
360
361 \section{Examples}
362
363 Let's illustrate the most important features of \pack{xifthen} with
364 the following problem: if we want to test whether a rectangle having
365 dimensions $l$~and~$L$ meets the two following conditions: $S = l
366 \times\nobreak L > 100$ and~$P = 2 (l +\nobreak L) < 60$\footnote{Note
367 that, because within the arguments of \cmd{cnttest} the \pack{calc}
368 is used, you must use real parentheses \tex{(}~and~\tex{)} and not
369 \cmd{(}~and~\cmd{)}.}:
370 %
371 \begin{texcode}
372 \cmd{newtest}\{\cmd{condition}\}[2]\{\%\\
373 \mbox{}\ \ \cmd{cnttest}\{(\#1)*(\#2)\}>\{100\}\%\\
374 \mbox{}\ \ \cmd{AND}\\
375 \mbox{}\ \ \cmd{cnttest}\{((\#1)+(\#2))*2\}<\{60\}\%\\
376 \}
377 \end{texcode}
378 %
379 Then \tex{\cmd{ifthenelse}\{\cmd{condition}\{14\}\{7\}\}\{TRUE\}\{FALSE\}}
380 returns \ifthenelse{\condition{14}{7}}{TRUE}{FALSE} because $14\times 7 =
381 98$ and $2\times (14 +\nobreak 7) = 42$, while
382 \tex{\cmd{ifthenelse}\{\cmd{condition}\{11\}\{11\}\}\{TRUE\}\allowbreak
383 \{FALSE\}} returns \ifthenelse{\condition{11}{11}}{TRUE}{FALSE} because
384 $11 \times 11 = 121$ and $2\times (11 +\nobreak 11) = 44$.
385
386 \bigbreak
387
388 Now a~list of typical uses of \pack{xifthen}'s capabilities:
389
390 \small
391 \begin{list}{}{\setlength{\leftmargin}{0pt}%
392 \setlength{\rightmargin}{-\oddsidemargin}%
393 \setlength{\partopsep}{0pt}%
394 \setlength{\topsep}{\medskipamount}%
395 \setlength{\parsep}{0pt}}%
396 \item \newcommand*{\TRUE}{%
397 \ifthenelse{\equal{\csname f@family\endcsname}{lmtt}}{true}%
398 {\makebox[\widthof{false}][l]{\bfseries true}}%
399 }
400 \newcommand*{\FALSE}{false}
401 \newcommand*{\pt}{\ifmmode \,\mathrm{pt}\else pt\fi}
402
403 $4 - 1< 4$: \ifthenelse{\cnttest{4 - 1}{<}{4}}{\TRUE}{\FALSE}\quad
404 $4< 4$: \ifthenelse{\cnttest{4}{<}{4}}{\TRUE}{\FALSE}\quad
405 $4 + 1< 4$: \ifthenelse{\cnttest{4 + 1}{<}{4}}{\TRUE}{\FALSE}
406
407 $4 - 1\leq 4$: \ifthenelse{\cnttest{4 - 1}{<=}{4}}{\TRUE}{\FALSE}\quad
408 $4\leq 4$: \ifthenelse{\cnttest{4}{<=}{4}}{\TRUE}{\FALSE}\quad
409 $4 + 1\leq 4$: \ifthenelse{\cnttest{4 + 1}{<=}{4}}{\TRUE}{\FALSE}
410
411 $4 - 1= 4$: \ifthenelse{\cnttest{4 - 1}{=}{4}}{\TRUE}{\FALSE}\quad
412 $4= 4$: \ifthenelse{\cnttest{4}{=}{4}}{\TRUE}{\FALSE}\quad
413 $4 + 1= 4$: \ifthenelse{\cnttest{4 + 1}{=}{4}}{\TRUE}{\FALSE}
414
415 $4 - 1\geq 4$: \ifthenelse{\cnttest{4 - 1}{>=}{4}}{\TRUE}{\FALSE}\quad
416 $4\geq 4$: \ifthenelse{\cnttest{4}{>=}{4}}{\TRUE}{\FALSE}\quad
417 $4 + 1\geq 4$: \ifthenelse{\cnttest{4 + 1}{>=}{4}}{\TRUE}{\FALSE}
418
419 $4 - 1> 4$: \ifthenelse{\cnttest{4 - 1}{>}{4}}{\TRUE}{\FALSE}\quad
420 $4> 4$: \ifthenelse{\cnttest{4}{>}{4}}{\TRUE}{\FALSE}\quad
421 $4 + 1> 4$: \ifthenelse{\cnttest{4 + 1}{>}{4}}{\TRUE}{\FALSE}
422
423 \medskip
424
425 $4\pt - 1\pt< 4\pt$: \ifthenelse{\dimtest{4\pt - 1\pt}{<}{4\pt}}{\TRUE}{\FALSE}\quad
426 $4\pt< 4\pt$: \ifthenelse{\dimtest{4\pt}{<}{4\pt}}{\TRUE}{\FALSE}\quad
427 $4\pt + 1\pt< 4\pt$: \ifthenelse{\dimtest{4\pt + 1\pt}{<}{4\pt}}{\TRUE}{\FALSE}
428
429 $4\pt - 1\pt\leq 4\pt$: \ifthenelse{\dimtest{4\pt - 1\pt}{<=}{4\pt}}{\TRUE}{\FALSE}\quad
430 $4\pt\leq 4\pt$: \ifthenelse{\dimtest{4\pt}{<=}{4\pt}}{\TRUE}{\FALSE}\quad
431 $4\pt + 1\pt\leq 4\pt$: \ifthenelse{\dimtest{4\pt + 1\pt}{<=}{4\pt}}{\TRUE}{\FALSE}
432
433 $4\pt - 1\pt= 4\pt$: \ifthenelse{\dimtest{4\pt - 1\pt}{=}{4\pt}}{\TRUE}{\FALSE}\quad
434 $4\pt= 4\pt$: \ifthenelse{\dimtest{4\pt}{=}{4\pt}}{\TRUE}{\FALSE}\quad
435 $4\pt + 1\pt= 4\pt$: \ifthenelse{\dimtest{4\pt + 1\pt}{=}{4\pt}}{\TRUE}{\FALSE}
436
437 $4\pt - 1\pt\geq 4\pt$: \ifthenelse{\dimtest{4\pt - 1\pt}{>=}{4\pt}}{\TRUE}{\FALSE}\quad
438 $4\pt\geq 4\pt$: \ifthenelse{\dimtest{4\pt}{>=}{4\pt}}{\TRUE}{\FALSE}\quad
439 $4\pt + 1\pt\geq 4\pt$: \ifthenelse{\dimtest{4\pt + 1\pt}{>=}{4\pt}}{\TRUE}{\FALSE}
440
441 $4\pt - 1\pt> 4\pt$: \ifthenelse{\dimtest{4\pt - 1\pt}{>}{4\pt}}{\TRUE}{\FALSE}\quad
442 $4\pt> 4\pt$: \ifthenelse{\dimtest{4\pt}{>}{4\pt}}{\TRUE}{\FALSE}\quad
443 $4\pt + 1\pt> 4\pt$: \ifthenelse{\dimtest{4\pt + 1\pt}{>}{4\pt}}{\TRUE}{\FALSE}
444
445 \medskip
446
447 \tex{\cmd{ifthenelse}\{\cmd{isempty}\{\}\}\{\TRUE\}\{\FALSE\}}
448 \ifthenelse{\isempty{}}{\TRUE}{\FALSE}
449
450 \tex{\cmd{ifthenelse}\{\cmd{isempty}\{ \}\}\{\TRUE\}\{\FALSE\}}
451 \ifthenelse{\isempty{ }}{\TRUE}{\FALSE}
452
453 \tex{\cmd{ifthenelse}\{\cmd{isempty}\{ foo \}\}\{\TRUE\}\{\FALSE\}}
454 \ifthenelse{\isempty{ foo }}{\TRUE}{\FALSE}
455
456 \medskip
457
458 \tex{\cmd{ifthenelse}\{\cmd{endswith}\{foo.\}\{.\}\}\{\TRUE\}\{\FALSE\}}
459 \ifthenelse{\endswith{foo.}{.}}{\TRUE}{\FALSE}
460
461 \tex{\cmd{ifthenelse}\{\cmd{endswith}\{foo!\}\{.\}\}\{\TRUE\}\{\FALSE\}}
462 \ifthenelse{\endswith{foo!}{.}}{\TRUE}{\FALSE}
463
464 \medskip
465
466 \tex{\cmd{ifthenelse}\{\cmd{isin}\{foo\}\{foobar\}\}\{\TRUE\}\{\FALSE\}}
467 \ifthenelse{\isin{foo}{foobar}}{\TRUE}{\FALSE}
468
469 \tex{\cmd{ifthenelse}\{\cmd{isin}\{Foo\}\{foobar\}\}\{\TRUE\}\{\FALSE\}}
470 \ifthenelse{\isin{Foo}{foobar}}{\TRUE}{\FALSE}
471
472 \medskip
473
474 \tex{\cmd{ifthenelse}\{\cmd{cnttest}\{10 * 10 + 1\}>\{100\}\}\{\TRUE\}\{\FALSE\}}
475 \ifthenelse{\cnttest{10 * 10 + 1}>{100}}{\TRUE}{\FALSE}
476
477 \tex{\cmd{ifthenelse}\{\cmd{cnttest}\{10 * 10 + 1\}>\{100 * 100\}\}\{\TRUE\}\{\FALSE\}}
478 \ifthenelse{\cnttest{10 * 10 + 1}>{100 * 100}}{\TRUE}{\FALSE}
479
480 \medskip
481
482 \tex{\cmd{ifthenelse}\{\cmd{isequivalentto}\{\cmd{usepackage}\}\{\cmd{RequirePackage}\}\}\{\TRUE\}\{\FALSE\}}
483 \ifthenelse{\isequivalentto{\usepackage}{\RequirePackage}}{\TRUE}{\FALSE}
484
485 \tex{\cmd{ifthenelse}\{\cmd{isequivalentto}\{\cmd{usepackage}\}\{\cmd{textit}\}\}\{\TRUE\}\{\FALSE\}}
486 \ifthenelse{\isequivalentto{\usepackage}{\textit}}{\TRUE}{\FALSE}
487
488 \medskip
489
490 \tex{\cmd{ifthenelse}\{\cmd{isnamedefined}\{@foo\}\}\{\TRUE\}\{\FALSE\}}
491 \ifthenelse{\isnamedefined{@foo}}{\TRUE}{\FALSE}
492
493 \tex{\cmd{ifthenelse}\{\cmd{isnamedefined}\{@for\}\}\{\TRUE\}\{\FALSE\}}
494 \ifthenelse{\isnamedefined{@for}}{\TRUE}{\FALSE}
495 \end{list}
496
497 \end{document}