summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/xstring/xstring_doc_en.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/xstring/xstring_doc_en.tex')
-rw-r--r--Master/texmf-dist/doc/latex/xstring/xstring_doc_en.tex106
1 files changed, 74 insertions, 32 deletions
diff --git a/Master/texmf-dist/doc/latex/xstring/xstring_doc_en.tex b/Master/texmf-dist/doc/latex/xstring/xstring_doc_en.tex
index 44961af495b..3985badad65 100644
--- a/Master/texmf-dist/doc/latex/xstring/xstring_doc_en.tex
+++ b/Master/texmf-dist/doc/latex/xstring/xstring_doc_en.tex
@@ -18,8 +18,7 @@
\usepackage[T1]{fontenc}
\usepackage[dvips,colorlinks=true,hyperfootnotes=false,citecolor=black,filecolor=black,linkcolor=blue,urlcolor=blue,bookmarks=false,pdfauthor={Christian Tellechea},pdftitle={xstring},pdfsubject={package for strings},pdfkeywords={xstring,latex,string},pdfcreator={LaTeX}]{hyperref}
\usepackage[a4paper,dvips,margin=2cm]{geometry}
-\usepackage{amsmath,amssymb,amsfonts,textcomp}
-\usepackage{amssymb}
+\usepackage{amsmath,amssymb}
\usepackage{moreverb}
\usepackage{lmodern}
\usepackage{eurosym}
@@ -27,7 +26,7 @@
\usepackage[french,english]{babel}
\makeatletter
\newcommand*\exemple{\@ifstar{\def\frontiere{|}\@xs@MakeVerb}{\def\frontiere{}\@xs@MakeVerb}}
-\def\@xs@afterreadverb#1{%
+\long\def\@xs@afterreadverb#1{%
\normalexpandarg
\tokenize\cs@resultat{#1}%
\fullexpandarg
@@ -83,6 +82,7 @@
\item does a string contains at least $n$ times an another?
\item does a string starts (or ends) with another? etc.
\item is a string an integer? A decimal?
+ \item are 2 strings equal?
\end{itemize}
\item[$\triangleright$] extractions of substrings:
\begin{itemize}
@@ -114,7 +114,7 @@ This manual is a translation of the french manual. I apologize for my poor engli
\subsection{Description}
This extension\footnote{This extension does not require \LaTeX{} and can be compiled with Plain $\varepsilon$-\TeX{}.} provides macros and tests operating on strings, as other programmation languages have. They provides the usual strings operations, such as: test if a string contains another, begins or ends with another, extractions of strings, calculation of the position of a substring, of the number of occurrences, etc.\medskip
-Certainly, other packages exit (for example \href{http://www.ctan.org/tex-archive/macros/latex/contrib/substr/}{\nolinkurl{substr}} and \href{http://www.ctan.org/tex-archive/macros/latex/contrib/stringstrings/}{\nolinkurl{stringstrings}}), but as well as differences on features, they do not take into account occurrences so I found them too limited and difficult to use for programming.
+Certainly, other packages exist (for example \href{http://www.ctan.org/tex-archive/macros/latex/contrib/substr/}{\nolinkurl{substr}} and \href{http://www.ctan.org/tex-archive/macros/latex/contrib/stringstrings/}{\nolinkurl{stringstrings}}), but as well as differences on features, they do not take into account occurrences so I found them too limited and difficult to use for programming.
\subsection{Motivation}
I decided to write this package of macros because I have never really found tools in \LaTeX{} suiting my needs for strings. So, over the last few months,I wrote a few macros that I occasionally or regularly used. Their numbers have increased and become a little too dispersed in directories in my computer, so I have grouped them together in this package.
@@ -172,19 +172,19 @@ The macros of this package are not purely expandable, i.e. they cannot be put in
\qquad or this nested structure\par
\hspace{0.2\linewidth}\verb|\commandA{\commandB{\commandC{argument}}}|\smallskip
-For this reason, all the macros returning a result (i.e. all excepted the tests) have an optionnal argument in last position. The syntax is \arguC{nom}, where \argu{nom} is the name of the control sequence that will receive the result of the macro: the assignment is made with an \verb|\edef| which make the result of the macro |\argu{nom} purely expandable. Of course, if an optionnal argument is present, the macro does not display anything.\medskip
+For this reason, all the macros returning a result (i.e. all excepted the tests) have an optionnal argument in last position. The syntax is \arguC{name}, where \argu{name} is the name of the control sequence that will receive the result of the macro: the assignment is made with an \verb|\edef| which make the result of the macro \argu{name} purely expandable. Of course, if an optionnal argument is present, the macro does not display anything.\medskip
Thus, this structure not allowed, already seen above:\par
-\hspace{0.2\linewidth}\verb|\edef\Resultat{\commande{arguments}}|\par
+\hspace{0.2\linewidth}\verb|\edef\Result{\command{arguments}}|\par
\qquad is equivalent to:\par
-\hspace{0.2\linewidth}\verb|\commande{argument}[\Resultat]|\medskip
+\hspace{0.2\linewidth}\verb|\command{argument}[\Result]|\medskip
And this nested one:\par
-\hspace{0.2\linewidth}\verb|\commandeA{\commandeB{\commandeC{arguments}}}|\par
+\hspace{0.2\linewidth}\verb|\commandA{\commandB{\commandC{arguments}}}|\par
\qquad can be replaced by:\par
-\hspace{0.2\linewidth}\verb|\commandeC{arguments}[\MaChaine]|\par
-\hspace{0.2\linewidth}\verb|\commandeB{\MaChaine}[\MaChaine]|\par
-\hspace{0.2\linewidth}\verb|\commandeA{\MaChaine}|
+\hspace{0.2\linewidth}\verb|\commandC{arguments}[\MyString]|\par
+\hspace{0.2\linewidth}\verb|\commandB{\MyString}[\MyString]|\par
+\hspace{0.2\linewidth}\verb|\commandA{\MyString}|
\section{The macros}
\label{listemacros}
@@ -251,7 +251,7 @@ In \argu{string}, tests if the \argu{number1}\th{} occurrence of \argu{stringA}
The values of the optional arguments \argu{number1} and \argu{number2} are 1 by default.\par\smallskip
-In \argu{string}, tests if the \argu{number1}\th{} occurrence of \argu{stringA} is on the right of the \argu{number2}\th{} occurrence of \argu{stringB}. Runs \argu{true} if so, ands \argu{false} otherwise.\medskip
+In \argu{string}, tests if the \argu{number1}\th{} occurrence of \argu{stringA} is on the right of the \argu{number2}\th{} occurrence of \argu{stringB}. Runs \argu{true} if so, and \argu{false} otherwise.\medskip
\begin{Conditions}
\item If one of the occurrences is not found, it runs \argu{false};
@@ -306,7 +306,7 @@ Tests if \argu{string} ends with \argu{stringA}, and runs \argu{true} if so, and
\verb|\IfInteger|\ARGU{number}\ARGU{true}\ARGU{false}
\smallskip
-Tests if \argu{nombre} is an integer, and runs \argu{true} if so, and \argu{false} otherwise.\smallskip
+Tests if \argu{number} is an integer, and runs \argu{true} if so, and \argu{false} otherwise.\smallskip
If test is false because unexpected characters, the control sequence \verb|\@xs@afterinteger| contains the illegal part of \argu{number}.\medskip
@@ -320,8 +320,7 @@ If test is false because unexpected characters, the control sequence \verb|\@xs@
\exemple|\IfInteger{-}{true}{false}|
\exemple|\IfInteger{0000}{true}{false}|
-\subsubsection{IfDecimal}
-
+\subsubsection{IfDecimal}\label{ifdecimal}
\verb|\IfInteger|\ARGU{number}\ARGU{true}\ARGU{false}
\smallskip
@@ -338,20 +337,64 @@ If test is false because unexpected characters, the control sequence \verb|\@xs@
\item If what is on the left of decimal separator (if it exists) is empty, the integer part is assumed to be 0;
\end{Conditions}
-\exemple|\IfDecimal{3.14}{vrai}{faux}|
-\exemple|\IfDecimal{3,14}{vrai}{faux}|
-\exemple|\IfDecimal{-0.5}{vrai}{faux}|
-\exemple|\IfDecimal{.7}{vrai}{faux}|
-\exemple|\IfDecimal{,9}{vrai}{faux}|
-\exemple|\IfDecimal{1..2}{vrai}{faux}|
-\exemple|\IfDecimal{+6}{vrai}{faux}|
-\exemple|\IfDecimal{-15}{vrai}{faux}|
-\exemple|\IfDecimal{1.}{vrai}{faux}|
-\exemple|\IfDecimal{2,}{vrai}{faux}|
-\exemple|\IfDecimal{.}{vrai}{faux}|
-\exemple|\IfDecimal{,}{vrai}{faux}|
-\exemple|\IfDecimal{+}{vrai}{faux}|
-\exemple|\IfDecimal{-}{vrai}{faux}|
+\exemple|\IfDecimal{3.14}{true}{false}|
+\exemple|\IfDecimal{3,14}{true}{false}|
+\exemple|\IfDecimal{-0.5}{true}{false}|
+\exemple|\IfDecimal{.7}{true}{false}|
+\exemple|\IfDecimal{,9}{true}{false}|
+\exemple|\IfDecimal{1..2}{true}{false}|
+\exemple|\IfDecimal{+6}{true}{false}|
+\exemple|\IfDecimal{-15}{true}{false}|
+\exemple|\IfDecimal{1.}{true}{false}|
+\exemple|\IfDecimal{2,}{true}{false}|
+\exemple|\IfDecimal{.}{true}{false}|
+\exemple|\IfDecimal{,}{true}{false}|
+\exemple|\IfDecimal{+}{true}{false}|
+\exemple|\IfDecimal{-}{true}{false}|
+
+\subsubsection{IfStrEq}
+
+\verb|\IfStrEq|\ARGU{stringA}\ARGU{stringB}\ARGU{true}\ARGU{false}
+\smallskip
+
+Tests if the strings \argu{stringA} and \argu{stringB} are equal, i.e. if they contain successively the same characters in the same order. Runs \argu{true} if so, and \argu{false} otherwise.\smallskip
+
+\exemple|\IfStrEq{a1b2c3}{a1b2c3}{true}{false}|
+\exemple|\IfStrEq{abcdef}{abcd}{true}{false}|
+\exemple|\IfStrEq{abc}{abcdef}{true}{false}|
+\exemple|\IfStrEq{3,14}{3,14}{true}{false}|
+\exemple|\IfStrEq{12.34}{12.340}{true}{false}|
+\exemple|\IfStrEq{abc}{}{true}{false}|
+\exemple|\IfStrEq{}{abc}{true}{false}|
+\exemple|\IfStrEq{}{}{true}{false}|
+
+\subsubsection{IfEq}
+
+\verb|\IfStrEq|\ARGU{stringA}\ARGU{stringB}\ARGU{true}\ARGU{false}
+\smallskip
+
+Tests if the strings \argu{stringA} and \argu{stringB} are equal, \emph{except} if both \argu{stringA} and \argu{stringB} contain numbers in which case the macro tests if these numbers are equal. Runs \argu{true} if so, and \argu{false} otherwise.\smallskip
+
+\begin{Conditions}
+ \item The definition of \emph{number} is given with the macro \verb|IfDecimal| (see page~\pageref{ifdecimal}), and thus :
+ \item \guill{+} signs are optionnal;
+ \item Decimal separator can be a dot or a comma;
+ \item It is possible to evaluate an algebric expression with the $\varepsilon$-\TeX{} primitive \verb|\numexpr|, keeping in mind that it operate on integers only, and that results of divisions are \emph{rounded} and not truncated! It is wiser to avoid with no integer calculation.
+\end{Conditions}
+
+\exemple|\IfEq{a1b2c3}{a1b2c3}{true}{false}|
+\exemple|\IfEq{abcdef}{ab}{true}{false}|
+\exemple|\IfEq{ab}{abcdef}{true}{false}|
+\exemple|\IfEq{12.34}{12,34}{true}{false}|
+\exemple|\IfEq{+12.34}{12.340}{true}{false}|
+\exemple|\IfEq{10}{+10}{true}{false}|
+\exemple|\IfEq{-10}{10}{true}{false}|
+\exemple|\IfEq{+0,5}{,5}{true}{false}|
+\exemple|\IfEq{1.001}{1.01}{true}{false}|
+\exemple|\IfEq{3*4+2}{14}{true}{false}|
+\exemple|\IfEq{\number\numexpr3*4+2}{14}{true}{false}|
+\exemple|\IfEq{0}{-0.0}{true}{false}|
+\exemple|\IfEq{}{}{true}{false}|
\subsection{Extraction of substrings}
\subsubsection{StrBefore}
@@ -1230,11 +1273,10 @@ A control sequence \verb|\myCS| defined with an \verb|\edef| contains control se
\end{minipage}
\medskip
-Notice that 2 counters, 2 tests and a double recursion are necessary to find the group: one of each to find what "\verb|}|" delimits the end of the current group, and the others to know the number of the group being read.\bigskip\bigskip
+Notice that 2 counters, 2 tests and a double recursion are necessary to find the group: one of each to find whiwh "\verb|}|" delimits the end of the current group, and the others to calculate the number of the group being read.\bigskip\bigskip
\begin{center}
-$\star$
-
+$\star$\par
$\star$\quad$\star$
\end{center}
\bigskip\bigskip