From bb8fed912dec0ce6c7a7c8171411cd77ee7b1929 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 14 Jul 2006 22:41:04 +0000 Subject: new package xifthen (25mar06) git-svn-id: svn://tug.org/texlive/trunk@1840 c570f23f-e606-0410-a88d-b1316a301751 --- Build/tools/tpm-ctan-check | 2 +- Master/texmf-dist/doc/latex/xifthen/README | 6 + Master/texmf-dist/doc/latex/xifthen/xifthen.pdf | Bin 0 -> 313393 bytes Master/texmf-dist/doc/latex/xifthen/xifthen.tex | 179 ++++++++++++++++++++++++ Master/texmf-dist/tex/latex/xifthen/xifthen.sty | 118 ++++++++++++++++ Master/texmf-dist/tpm/xifthen.tpm | 26 ++++ Master/texmf/lists/xifthen | 8 ++ Master/texmf/tpm/collection-latexextra.tpm | 1 + 8 files changed, 339 insertions(+), 1 deletion(-) create mode 100644 Master/texmf-dist/doc/latex/xifthen/README create mode 100644 Master/texmf-dist/doc/latex/xifthen/xifthen.pdf create mode 100644 Master/texmf-dist/doc/latex/xifthen/xifthen.tex create mode 100644 Master/texmf-dist/tex/latex/xifthen/xifthen.sty create mode 100644 Master/texmf-dist/tpm/xifthen.tpm create mode 100644 Master/texmf/lists/xifthen diff --git a/Build/tools/tpm-ctan-check b/Build/tools/tpm-ctan-check index 57aa79544d8..c5c6b392d56 100755 --- a/Build/tools/tpm-ctan-check +++ b/Build/tools/tpm-ctan-check @@ -94,7 +94,7 @@ sub main "twoup", "typedref", "velthuis", "verse", "vhistory", "volumes", "wordlike", "wrapfig", - "xltxtra", "xypic-tut-pt", + "xifthen", "xltxtra", "xypic-tut-pt", "york-thesis", "xcolor", "xkeyval" ); diff --git a/Master/texmf-dist/doc/latex/xifthen/README b/Master/texmf-dist/doc/latex/xifthen/README new file mode 100644 index 00000000000..56478335291 --- /dev/null +++ b/Master/texmf-dist/doc/latex/xifthen/README @@ -0,0 +1,6 @@ +This package implements new commands to go within the first argument of +\ifthenelse to test whether a string is void or not, if a command is +defined or equivalent to another. It includes also the possibility to make +use of the complex expressions introduced by the package calc, together +with the ability of defining new commands to handle complex tests. This +package requires the e-TEX features. diff --git a/Master/texmf-dist/doc/latex/xifthen/xifthen.pdf b/Master/texmf-dist/doc/latex/xifthen/xifthen.pdf new file mode 100644 index 00000000000..4ba6100024b Binary files /dev/null and b/Master/texmf-dist/doc/latex/xifthen/xifthen.pdf differ diff --git a/Master/texmf-dist/doc/latex/xifthen/xifthen.tex b/Master/texmf-dist/doc/latex/xifthen/xifthen.tex new file mode 100644 index 00000000000..ee6549dff24 --- /dev/null +++ b/Master/texmf-dist/doc/latex/xifthen/xifthen.tex @@ -0,0 +1,179 @@ +% $Id: xifthen.tex,v 1.1.1.1 2006/03/25 01:24:34 noirel Exp $ +\documentclass{article} + +\usepackage{etex} +\usepackage{xifthen} +\usepackage[ascii]{inputenc} +\usepackage[T1]{fontenc} +\usepackage[warn]{textcomp} +\usepackage{fourier} + \renewcommand*{\sfdefault}{lmss} + \renewcommand*{\ttdefault}{lmtt} + \renewcommand*{\textcompsubstdefault}{lmr} +\usepackage{microtype} +\usepackage{typetex} +\usepackage[babel]{csquotes} +\usepackage[british]{babel} + +\makeatletter +\newenvironment*{texdescription}{% + \list{}{% + \labelwidth\z@ + \itemindent-\leftmargin + \itemsep = 0pt + \def \makelabel ##1{\hspace{\labelsep}\normalfont\tex{##1}}% + }% +}{% + \endlist +} +\makeatother + +\newcommand*{\pack}{\textsf} +\newcommand*{\true}{\emph{true}} +\newcommand*{\false}{\emph{false}} + +\newtest \sillytest [2]{% + \cnttest{(#1)*(#2)}>{100}% + \AND + \cnttest{((#1)+(#2))*2}<{60}% +} + +\texsetup {% + meta-left-char = {\textlangle}, + meta-right-char = {\textrangle} +} + +\title {The \pack{xifthen} package} +\author {Josselin Noirel} + +\begin{document} + +\maketitle + +\begin{abstract} + This package implements new commands to go within the first argument of + \cmd{ifthenelse} to test whether a string is void or not, if a command + is defined or equivalent to another. It includes also the possibility + to make use of the complex expressions introduced by the + package~\pack{calc}, together with the ability of defining new commands + to handle complex tests. This package requires the \eTeX{} features. +\end{abstract} + +\section{General syntax} + +The general syntax is inherited of that of the package~\pack{ifthen}: +% +\begin{displaytex} + \cmdsyntax[3]{ifthenelse}{test expression}{true code}{false code} +\end{displaytex} +% +Evaluates the \meta{test expression} and executes \meta{true code} if the +test turns out to be true and \meta{false code} otherwise. \pack{ifthen} +provides the following tests: +% +\begin{texdescription} +\item [\meta{value $1$} = \meta{value $2$}] +\item [\meta{value $1$} < \meta{value $2$}] +\item [\meta{value $1$} > \meta{value $2$}] + Simple tests on integer comparisons. + +\item [{\cmdsyntax[1]{isodd}{number}}] + Is \meta{number} odd? + +\item [\cmd{isundefined}\meta{command}] + Id \meta{command} undefined? + +\item [{\cmdsyntax[2]{equal}{string $1$}{string $2$}}] + Are \meta{string $1$} and \meta{string $2$} equivalent (after + expansion)? + +\item [{\cmdsyntax[1]{boolean}{boolean}}] + Does the boolean \meta{boolean} hold the value \true{} or \false{}? + +\item [{\cmd[1]{lengthtest}{\meta{dimen $1$} = \meta{dimen $2$}}}] +\item [{\cmd[1]{lengthtest}{\meta{dimen $1$} < \meta{dimen $2$}}}] +\item [{\cmd[1]{lengthtest}{\meta{dimen $1$} > \meta{dimen $2$}}}] + Simple dimension comparisons. + +\item [\cmd{(}\dots\cmd{)}] + Parenthesis. + +\item [\cmd{AND}] +\item [\cmd{OR}] +\item [\cmd{NOT}] + Conjunction, disjunction, negation. +\end{texdescription} + +\section{New tests} + +\begin{displaytex} + \cmdsyntax[1]{isnamedefined}{command name} +\end{displaytex} +% +Returns \true{} if the command \cmd{\meta{command name}} is defined. + +\begin{displaytex} + \cmdsyntax[1]{isempty}{content} +\end{displaytex} +% +Returns \true{} is \meta{content} is empty (in the sense used by +\pack{ifmtarg} which is used internally). It is essentially equivalent to +\tex{\cmd[2]{equal}{\meta{content}}{}} except that the argument of +\cmd{isempty} isn't expanded and therefore isn't affected by fragile +commands. + +\begin{displaytex} + \cmdsyntax[2]{isequivalentto}{command~$1$}{command~$2$} +\end{displaytex} +% +Corresponds to the \cmd{ifx} test: it returns \true{} when the two +commands are exactly equivalent (same definition, same number of +arguments, etc., otherwise \false{} is returned. + +\begin{displaytex} + \cmd{cnttest}\marg{counter expression $1$}\meta{comparison}% + \marg{counter expression $2$} +\end{displaytex} +% +Compares the two counter expressions (having the usual syntax of the +package \pack{calc}) and returns the value of the test. The comparison +can be one of the following characters \tex{<}, \tex{>},~and~\tex{=}. + +\begin{displaytex} + \cmd{dimtest}\marg{dimen expression $1$}\meta{comparison}% + \marg{dimen expression $2$} +\end{displaytex} +% +Compares the two dimension expressions (having the usual syntax of the +package \pack{calc}) and returns the value of the test. The comparison +can be one of the following characters \tex{<}, \tex{>},~and~\tex{=}. + +\section{Defining new complex test commands} + +\begin{displaytex} + \cmdsyntax[3]{newtest}{command}[$n$]{test expression} +\end{displaytex} +% +Defines a command named \meta{command} taking $n$~arguments (no optional +argument is allowed) consisting of the test as specified by \meta{test + expression} that can be used in the argument of \cmd{ifthenelse}. For +instance, if we want to test whether a rectangle having dimensions +$l$~and~$L$ meets the two following conditions: $S = l \times L > 100$ +and~$P = 2 (l +\nobreak L) < 60$: +% +\begin{displaytex} +\cmd{newtest}\{\cmd{sillytest}\}[2]\{\%\newline +\ \ \cmd{cnttest}\{(\#1)*(\#2)\}>\{100\}\%\newline +\ \ \cmd{AND}\newline +\ \ \cmd{cnttest}\{((\#1)+(\#2))*2\}<\{60\}\%\newline +\} +\end{displaytex} +% +Then \tex{\cmd{ifthenelse}\{\cmd{sillytest}\{14\}\{7\}\}\{TRUE\}\{FALSE\}} +returns \ifthenelse{\sillytest{14}{7}}{TRUE}{FALSE} because $14\times 7 = +98$ and $2\times (14 +\nobreak 7) = 42$, while +\tex{\cmd{ifthenelse}\{\cmd{sillytest}\{11\}\{11\}\}\{TRUE\}\allowbreak + \{FALSE\}} returns \ifthenelse{\sillytest{11}{11}}{TRUE}{FALSE} because +$11 \times 11 = 121$ and $2\times (11 +\nobreak 11) = 44$. + +\end{document} diff --git a/Master/texmf-dist/tex/latex/xifthen/xifthen.sty b/Master/texmf-dist/tex/latex/xifthen/xifthen.sty new file mode 100644 index 00000000000..081ac3ab696 --- /dev/null +++ b/Master/texmf-dist/tex/latex/xifthen/xifthen.sty @@ -0,0 +1,118 @@ +\def \@tempa $#1 #2 #3 #4 #5 #6 #7 ${% + \def \filedate {#4}% + \def \fileversion {v#3}% +} +\@tempa $Id: xifthen.sty,v 1.1.1.1 2006/03/25 01:24:34 noirel Exp $ +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{xifthen}% + [\filedate \space \fileversion \space Extended ifthen features] + +\RequirePackage{etex} +\RequirePackage{calc} +\RequirePackage{ifthen} +\RequirePackage{ifmtarg} + +\newcommand*{\TE@cnttest}[4]{% + \TE@throw + \noexpand \calc@assign@count{\@tempcnta}{\unexpanded{#1}}% + \noexpand \calc@assign@count{\@tempcntb}{\unexpanded{#3}}% + \noexpand \ifnum \@tempcnta#2\@tempcntb + #4% +} + +\newcommand*{\TE@dimtest}[4]{% + \TE@throw + \noexpand \calc@assign@skip{\@tempskipa}{\unexpanded{#1}}% + \noexpand \calc@assign@skip{\@tempskipb}{\unexpanded{#3}}% + \noexpand \ifdim \@tempskipa#2\@tempskipb + #4% +} + +\newcommand*{\TE@isnamedefined}[2]{% + \TE@throw + \noexpand \ifcsname #1\endcsname + #2% +} + +\newcommand*{\TE@isempty}[2]{% + \TE@throw + \noexpand \if FF\noexpand \@nameuse{fi}% + \noexpand \@ifmtarg{\unexpanded{#1}}{% + \noexpand \@nameuse{iftrue}% + }{% + \noexpand \@nameuse{iffalse}% + }% + #2% +} + +\newcommand*{\TE@isequivalentto}[3]{% + \TE@throw + \noexpand \ifx \noexpand #1\noexpand#2% + #3% +} + +\newcommand*{\newtest}[1]{% + \@ifnextchar[{% + \@newtest{#1}% + }{% + \@newtest{#1}[0]% + }% +}% + +\newcommand*{\@newtest}{} +\def \@newtest #1[#2]#3{% + \toks@ = {\(#3\)}% + \TE@repl \or \TE@or + \TE@repl \and \TE@and + \TE@repl \not \TE@neg + \TE@repl \OR \TE@or + \TE@repl \AND \TE@and + \TE@repl \NOT \TE@neg + \edef \@tempa {% + \unexpanded{\newcommand*{#1}[{#2}]}{\the \toks@}% + }% + \@tempa +}% + +\newcommand*{\TE@hook}{% + \let \isequivalentto = \TE@isequivalentto + \let \isnamedefined = \TE@isnamedefined + \let \isempty = \TE@isempty + \let \cnttest = \TE@cnttest + \let \dimtest = \TE@dimtest +} + +\renewcommand{\ifthenelse}[1]{% + \toks@{#1}% + \TE@repl \or \TE@or + \TE@repl \and \TE@and + \TE@repl \not \TE@neg + \TE@repl \OR \TE@or + \TE@repl \AND \TE@and + \TE@repl \NOT \TE@neg + \begingroup + \let \protect = \@unexpandable@protect + \def \@setref ##1##2##3{\ifx ##1\relax \z@ \else \expandafter ##2##1\fi}% + \def \value ##1{\the \csname c@##1\endcsname}% + \let \equal = \TE@equal + \let \( = \TE@lparen + \let \) = \TE@rparen + \let \isodd = \TE@odd + \let \lengthtest = \TE@length + \let \isundefined = \TE@undef + \TE@hook + \begingroup + \let \@tempa = \relax + \let \@tempb = \relax + \xdef \@gtempa {\expandafter \TE@eval \the \toks@ \TE@endeval}% + \endgroup + \@gtempa + \expandafter \endgroup + \ifTE@val + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi +} + +\endinput diff --git a/Master/texmf-dist/tpm/xifthen.tpm b/Master/texmf-dist/tpm/xifthen.tpm new file mode 100644 index 00000000000..eb96397a33c --- /dev/null +++ b/Master/texmf-dist/tpm/xifthen.tpm @@ -0,0 +1,26 @@ + + + + xifthen + Package + 2006/03/25 01:34:00 + + karl + The xifthen package. + + + 322056 + + +texmf-dist/tex/latex/xifthen/xifthen.sty +texmf-dist/tpm/xifthen.tpm + + +texmf-dist/doc/latex/xifthen/README +texmf-dist/doc/latex/xifthen/xifthen.pdf +texmf-dist/doc/latex/xifthen/xifthen.tex + + Package/xifthen + + + diff --git a/Master/texmf/lists/xifthen b/Master/texmf/lists/xifthen new file mode 100644 index 00000000000..06931d7f757 --- /dev/null +++ b/Master/texmf/lists/xifthen @@ -0,0 +1,8 @@ +texmf-dist/doc/latex/xifthen/README +texmf-dist/doc/latex/xifthen/xifthen.pdf +texmf-dist/doc/latex/xifthen/xifthen.tex + +texmf-dist/tex/latex/xifthen/xifthen.sty +texmf-dist/tpm/xifthen.tpm + +texmf/lists/xifthen diff --git a/Master/texmf/tpm/collection-latexextra.tpm b/Master/texmf/tpm/collection-latexextra.tpm index c92e4e89a42..65609e52306 100644 --- a/Master/texmf/tpm/collection-latexextra.tpm +++ b/Master/texmf/tpm/collection-latexextra.tpm @@ -519,6 +519,7 @@ A large collection of add-on packages for LaTeX. + -- cgit v1.2.3