summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/etoolbox/etoolbox.tex
diff options
context:
space:
mode:
authorDr. Clea F. Rees <cfrees@imapmail.org>2009-08-07 00:42:54 +0000
committerDr. Clea F. Rees <cfrees@imapmail.org>2009-08-07 00:42:54 +0000
commite508801ab0b9dae308a9f31a025735094bf1ac22 (patch)
tree3999d390b587ec85895d91e5143cf88fdf2f32f7 /Master/texmf-dist/doc/latex/etoolbox/etoolbox.tex
parent9da4c719065a4811463ba831d25a81135a531894 (diff)
etoolbox new version
git-svn-id: svn://tug.org/texlive/trunk@14559 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/etoolbox/etoolbox.tex')
-rw-r--r--Master/texmf-dist/doc/latex/etoolbox/etoolbox.tex95
1 files changed, 90 insertions, 5 deletions
diff --git a/Master/texmf-dist/doc/latex/etoolbox/etoolbox.tex b/Master/texmf-dist/doc/latex/etoolbox/etoolbox.tex
index c05772bbeab..b433d9ea2e7 100644
--- a/Master/texmf-dist/doc/latex/etoolbox/etoolbox.tex
+++ b/Master/texmf-dist/doc/latex/etoolbox/etoolbox.tex
@@ -1,4 +1,4 @@
-% $Id: etoolbox.tex,v 1.7 2008/06/28 18:25:41 lehman stable $
+% $Id: etoolbox.tex,v 1.8 2009/08/06 16:50:04 lehman stable $
\documentclass{ltxdockit}
\usepackage[latin9]{inputenc}
\usepackage[american]{babel}
@@ -8,7 +8,7 @@
\MakeAutoQuote*{<}{>}
\MakeShortVerb{\|}
-\rcsid{$Id: etoolbox.tex,v 1.7 2008/06/28 18:25:41 lehman stable $}
+\rcsid{$Id: etoolbox.tex,v 1.8 2009/08/06 16:50:04 lehman stable $}
\titlepage{%
title={The \sty{etoolbox} package},
@@ -43,7 +43,7 @@ This package requires \etex. \tex distributions have been shipping \etex binarie
\subsection{License}
-Copyright \textcopyright\ 2007--2008 Philipp Lehman. Permission is granted to copy, distribute and\slash or modify this software under the terms of the \lppl, version 1.3.\fnurl{http://www.ctan.org/tex-archive/macros/latex/base/lppl.txt} This package is author"=maintained.
+Copyright \textcopyright\ 2007--2009 Philipp Lehman. Permission is granted to copy, distribute and\slash or modify this software under the terms of the \lppl, version 1.3.\fnurl{http://www.ctan.org/tex-archive/macros/latex/base/lppl.txt} This package is author"=maintained.
\subsection{Feedback}
@@ -113,9 +113,9 @@ The facilities in this section are replacements for \cmd{setcounter} and \cmd{se
Assigns a value to a \latex \prm{counter} previously initialized with \cmd{newcounter}. This command is similar in concept and syntax to \cmd{setcounter} except for two major differences. 1) The second argument may be an \prm{integer expression} which will be processed with \cmd{numexpr}. The \prm{integer expression} may be any arbitrary code which is valid in this context. The value assigned to the \prm{counter} will be the result of that calculation. 2) In contrast to \cmd{setcounter}, the assignment is local by default but \cmd{defcounter} may be prefixed with \cs{global}. The functional equivalent of \cmd{setcounter} would be \cs{global}\cmd{defcounter}.
-\cmditem{deflength}{length}{dimen expression}
+\cmditem{deflength}{length}{glue expression}
-Assigns a value to a \prm{length} register previously initialized with \cmd{newlength}. This command is similar in concept and syntax to \cmd{setlength} except that the second argument may be a \prm{dimen expression} which will be processed with \cmd{dimexpr}. The \prm{dimen expression} may be any arbitrary code which is valid in this context. The value assigned to the \prm{length} register will be the result of that calculation. The assignment is local by default but \cmd{deflength} may be prefixed with \cs{global}. This command may be used as a drop-in replacement for \cmd{setlength}.
+Assigns a value to a \prm{length} register previously initialized with \cmd{newlength}. This command is similar in concept and syntax to \cmd{setlength} except that the second argument may be a \prm{glue expression} which will be processed with \cmd{glueexpr}. The \prm{glue expression} may be any arbitrary code which is valid in this context. The value assigned to the \prm{length} register will be the result of that calculation. The assignment is local by default but \cmd{deflength} may be prefixed with \cs{global}. This command may be used as a drop-in replacement for \cmd{setlength}.
\end{ltxsyntax}
@@ -602,6 +602,77 @@ Expands to \prm{true} if the \prm{string} is blank (empty or spaces), and to \pr
\end{ltxsyntax}
+\subsubsection{Arithmetic tests}
+\label{aut:tst:num}
+
+\begin{ltxsyntax}
+
+\cmditem{ifnumcomp}{integer expression}{comparison}{integer expression}{true}{false}
+
+Compares two integer expressions according to \prm{comparison} and expands to \prm{true} or \prm{false} depending on the result. The \prm{comparison} may be |<|, |>|, or |=|. Both integer expressions will be processed with \cmd{numexpr}. An \prm{integer expression} may be any arbitrary code which is valid in this context. All arithmetic expressions may contain spaces. Here are some examples:
+
+\begin{ltxcode}
+\ifnumcomp{<<3>>}{<<>>>}{<<6>>}{true}{<<false>>}
+\ifnumcomp{<<(7 + 5) / 2>>}{<<=>>}{<<6>>}{<<true>>}{false}
+\ifnumcomp{<<(7+5) / 4>>}{<<>>>}{<<3*(12-10)>>}{true}{<<false>>}
+\newcounter{countA}
+\setcounter{countA}{<<6>>}
+\newcounter{countB}
+\setcounter{countB}{<<5>>}
+\ifnumcomp{<<\value{countA} * \value{countB}/2}>>{<<=>>}{<<15>>}{<<true>>}{false}
+\ifnumcomp{<<6/2>>}{<<=>>}{<<5/2>>}{<<true>>}{false}
+\end{ltxcode}
+%
+Technically, this command is a \latex wrapper for the \tex primitive \cmd{ifnum}, incorporating \cmd{numexpr}. Note that \cmd{numexpr} will round the result of all integer expressions, \ie both expressions will be processed and rounded prior to being compared. In the last line of the above examples, the result of the second expression is 2.5, which is rounded to 3, hence \cmd{ifnumcomp} will expand to \prm{true}.
+
+\cmditem{ifnumequal}{integer expression}{integer expression}{true}{false}
+
+Alternative syntax for |\ifnumcomp{...}{=}{...}{...}{...}|.
+
+\cmditem{ifnumgreater}{integer expression}{integer expression}{true}{false}
+
+Alternative syntax for |\ifnumcomp{...}{>}{...}{...}{...}|.
+
+\cmditem{ifnumless}{integer expression}{integer expression}{true}{false}
+
+Alternative syntax for |\ifnumcomp{...}{<}{...}{...}{...}|.
+
+\cmditem{ifdimcomp}{dimen expression}{comparison}{dimen expression}{true}{false}
+
+Compares two dimen expressions according to \prm{comparison} and expands to \prm{true} or \prm{false} depending on the result. The \prm{comparison} may be |<|, |>|, or |=|. Both dimen expressions will be processed with \cmd{dimexpr}. A \prm{dimen expression} may be any arbitrary code which is valid in this context. All arithmetic expressions may contain spaces. Here are some examples:
+
+\begin{ltxcode}
+\ifdimcomp{<<1cm>>}{<<=>>}{<<28.45274pt>>}{<<true>>}{false}
+\ifdimcomp{<<(7pt + 5pt) / 2>>}{<<<>>}{2pt}{true}{<<false>>}
+\ifdimcomp{<<(3.725pt + 0.025pt) * 2>>}{<<<>>}{<<7pt>>}{true}{<<false>>}
+\newlength{\lengthA}
+\setlength{\lengthA}{<<7.25pt>>}
+\newlength{\lengthB}
+\setlength{\lengthB}{<<4.75pt>>}
+\ifdimcomp{<<(\lengthA + \lengthB) / 2>>}{<<>>>}{<<2.75pt * 2>>}{<<true>>}{false}
+\ifdimcomp{<<(\lengthA + \lengthB) / 2>>}{<<>>>}{<<25pt / 6>>}{<<true>>}{false}
+\end{ltxcode}
+%
+Technically, this command is a \latex wrapper for the \tex primitive \cmd{ifdim}, incorporating \cmd{dimexpr}. Since both \cmd{ifdimcomp} and \cmd{ifnumcomp} are expandable, they may also be nested:
+
+\begin{ltxcode}
+<<\ifnumcomp>>{<<\ifdimcomp>>{<<5pt+5pt>>}{<<=>>}{<<10pt>>}{<<1>>}{<<0>>}}{<<>>>}{<<0>>}{<<true>>}{false}
+\end{ltxcode}
+
+\cmditem{ifdimequal}{dimen expression}{dimen expression}{true}{false}
+
+Alternative syntax for |\ifdimcomp{...}{=}{...}{...}{...}|.
+
+\cmditem{ifdimgreater}{dimen expression}{dimen expression}{true}{false}
+
+Alternative syntax for |\ifdimcomp{...}{>}{...}{...}{...}|.
+
+\cmditem{ifdimless}{dimen expression}{dimen expression}{true}{false}
+
+Alternative syntax for |\ifdimcomp{...}{<}{...}{...}{...}|.
+
+\end{ltxsyntax}
+
\subsection{Boolean switches}
\label{aut:bol}
@@ -834,6 +905,20 @@ This revision history is a list of changes relevant to users of this package. Ch
\begin{changelog}
+\begin{release}{1.8}{2009-08-06}
+
+\item Improved \cmd{deflength}\see{use:cal}
+\item Added \cmd{ifnumcomp}\see{aut:tst:num}
+\item Added \cmd{ifnumequal}\see{aut:tst:num}
+\item Added \cmd{ifnumgreater}\see{aut:tst:num}
+\item Added \cmd{ifnumless}\see{aut:tst:num}
+\item Added \cmd{ifdimcomp}\see{aut:tst:num}
+\item Added \cmd{ifdimequal}\see{aut:tst:num}
+\item Added \cmd{ifdimgreater}\see{aut:tst:num}
+\item Added \cmd{ifdimless}\see{aut:tst:num}
+
+\end{release}
+
\begin{release}{1.7}{2008-06-28}
\item Renamed \cmd{AfterBeginDocument} to \cmd{AfterEndPreamble} (name clash)\see{use:pre}