diff options
Diffstat (limited to 'Master/texmf-dist/doc/latex/datatool/datatool-user.tex')
-rw-r--r-- | Master/texmf-dist/doc/latex/datatool/datatool-user.tex | 128 |
1 files changed, 122 insertions, 6 deletions
diff --git a/Master/texmf-dist/doc/latex/datatool/datatool-user.tex b/Master/texmf-dist/doc/latex/datatool/datatool-user.tex index 140fe1f1282..b5e65957904 100644 --- a/Master/texmf-dist/doc/latex/datatool/datatool-user.tex +++ b/Master/texmf-dist/doc/latex/datatool/datatool-user.tex @@ -102,11 +102,11 @@ \MakeShortVerb{"} - \title{User Manual for datatool bundle version~2.26} + \title{User Manual for datatool bundle version~2.27} \author{Nicola L.C. Talbot\\ \url{http://www.dickimaw-books.com/}} - \date{2016-07-20} + \date{2016-07-28} \maketitle \pagenumbering{roman} @@ -121,7 +121,7 @@ The \styfmt{datatool} bundle comes with the following documentation: \item[\url{datatool-code.pdf}] Advanced users wishing to know more about the inner workings of all the packages provided in the \styfmt{datatool} bundle should - read \qt{Documented Code for datatool v2.26} + read \qt{Documented Code for datatool v2.27} \item[INSTALL] Installation instructions. @@ -2043,6 +2043,122 @@ produces: \renewcommand*{\DTLinitialhyphen}{}\relax \DTLinitials{Marie-{\'E}lise del~Rosario}} +\chapter{Comma-Separated Lists} +\label{sec:csvlists} + +The \styfmt{datatool-base} package automatically loads the +\sty{etoolbox} package, so you can use any of the list +commands provided by that package, or you can use +the internal command \cs{@for} provided by the \LaTeX\ kernel +(and modified by the \sty{xfor} package, which is also loaded +by \styfmt{datatool-base}). + +In addition to those commands, \styfmt{datatool-base} +provides some commands that deal with comma-separated lists. +Note that this just refers to a control sequence that stores +a list of elements separated by commands, for example: +\begin{verbatim} +\newcommand{\mylist}{elephant,ant,zebra,duck} +\end{verbatim} +This isn't the same as comma-separated files, which is dealt +with in \sectionref{sec:databases}. + +\begin{definition}[\DescribeMacro\dtlsortlist] +\cs{dtlsortlist}\marg{list cs}\marg{criteria cs} +\end{definition} +This sorts the comma-separated list stored in the command +\meta{list cs} according to the criteria command +\meta{criteria cs}. The criteria command must take three arguments: +a count register in which to store the result, element \meta{A} and +element \meta{B}. If \meta{A} is considered less that \meta{B}, the +count register should be set to $-1$, if \meta{A} and \meta{B} are +considered the same then the count register should be set to 0, +and if \meta{A} is considered greater than \meta{B}, then the count +register should be set to 1. + +The \styfmt{datatool-base} package provides some predefined +criteria commands: +\begin{definition}[\DescribeMacro\dtlcompare] +\cs{dtlcompare}\marg{register}\marg{A}\marg{B} +\end{definition} +A case-sensitive comparison. +\begin{definition}[\DescribeMacro\dtlicompare] +\cs{dtlicompare}\marg{register}\marg{A}\marg{B} +\end{definition} +A case-insensitive comparison. +\begin{definition}[\DescribeMacro\dtlwordindexcompare] +\cs{dtlwordindexcompare}\marg{register}\marg{A}\marg{B} +\end{definition} +English word-ordering comparison for indexes, as described by +the Oxford Style Manual. +\begin{definition}[\DescribeMacro\dtlletterindexcompare] +\cs{dtlletterindexcompare}\marg{register}\marg{A}\marg{B} +\end{definition} +English letter-ordering comparison for indexes. +Those last two commands are described in more detail in +\sectionref{sec:sort}. + +For example: +\begin{verbatim} +\newcommand{\mylist}{elephant,ant,zebra,duck} +\dtlsortlist{\mylist}{\dtlcompare} + +\mylist. +\end{verbatim} +produces: +\begin{display} +\newcommand{\mylist}{elephant,ant,zebra,duck} +\dtlsortlist{\mylist}{\dtlcompare} + +\mylist. +\end{display} + +If you are building up a list, you may prefer to use: +\begin{definition}[\DescribeMacro\dtlinsertinto] +\cs{dtlinsertinto}\marg{element}\marg{list cs}\marg{criteria cs} +\end{definition} +which inserts \meta{element} into the list stored in the +command \meta{list cs} according to the criteria command +\meta{criteria cs}. This is more efficient than first building the +list and then sorting it. + +For example: +\begin{verbatim} +\newcommand{\mylist}{} +\dtlinsertinto{elephant}{\mylist}{\dtlcompare} +\dtlinsertinto{ant}{\mylist}{\dtlcompare} +\dtlinsertinto{zebra}{\mylist}{\dtlcompare} +\dtlinsertinto{duck}{\mylist}{\dtlcompare} + +\mylist. +\end{verbatim} +produces: +\begin{display} +\newcommand{\mylist}{} +\dtlinsertinto{elephant}{\mylist}{\dtlcompare} +\dtlinsertinto{ant}{\mylist}{\dtlcompare} +\dtlinsertinto{zebra}{\mylist}{\dtlcompare} +\dtlinsertinto{duck}{\mylist}{\dtlcompare} + +\mylist. +\end{display} + +Note that \cs{dtlinsertinto} doesn't expand \meta{element}. +If the element is stored in a command, you need to +expand it first. For example: +\begin{verbatim} +\newcommand*{\element}{ant} +\expandafter\dtlinsertinto\expandafter{\element}{\mylist}{\dtlcompare} +\end{verbatim} + +To ensure that the element is first fully expanded, you can +use: +\begin{definition}[\DescribeMacro\edtlinsertinto] +\cs{edtlinsertinto}\marg{element}\marg{list cs}\marg{criteria cs} +\end{definition} +This will fully expand \meta{element} using \cs{protected@edef} +and then use \cs{dtlinsertinto}. + \chapter{Databases} \label{sec:databases} @@ -4522,9 +4638,9 @@ the data type for a given key, and uses this to determine whether an alphabetical or numerical sort is required. The final argument \meta{handler} is the command used for the -comparisons. These handlers are described in more detail on -page~\pageref*{src:dtlcompare} of the documented code (datatool-code.pdf). The following -handlers are provided: +comparisons and is the same as the \meta{criteria cs} command +used by \cs{dtlsortlist} and \cs{dtlinsertinto}, described +in \sectionref{sec:csvlists}. The predefined handlers are: \begin{description} \item[\ics{dtlcompare}] A case-sensitive comparison. \item[\ics{dtlicompare}] A case-insensitive comparison. |