summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/etextools/etextools-examples.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-10-03 14:55:06 +0000
committerKarl Berry <karl@freefriends.org>2009-10-03 14:55:06 +0000
commit95501215cb9ee689510d34f43334f95bdc383231 (patch)
treec51685bca784f65683c137863a7b9058f5b0f76d /Master/texmf-dist/doc/latex/etextools/etextools-examples.tex
parentfe341a1ce588bf3b07c6489abb26db11ae8d7683 (diff)
etextools 3.1 (1oct09)
git-svn-id: svn://tug.org/texlive/trunk@15600 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/etextools/etextools-examples.tex')
-rw-r--r--Master/texmf-dist/doc/latex/etextools/etextools-examples.tex350
1 files changed, 0 insertions, 350 deletions
diff --git a/Master/texmf-dist/doc/latex/etextools/etextools-examples.tex b/Master/texmf-dist/doc/latex/etextools/etextools-examples.tex
deleted file mode 100644
index 6347cb5c36d..00000000000
--- a/Master/texmf-dist/doc/latex/etextools/etextools-examples.tex
+++ /dev/null
@@ -1,350 +0,0 @@
-%%
-%% This is file `etextools-examples.tex',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% etextools.dtx (with options: `example')
-%%
-%% This is a generated file.
-%%
-%% Copyright (C) 2009 by Florent Chervet <florent.chervet@free.fr>
-%%
-%% This work may be distributed and/or modified under the
-%% conditions of the LaTeX Project Public License, either
-%% version 1.3 of this license or (at your option) any later
-%% version. The latest version of this license is in
-%% http://www.latex-project.org/lppl.txt
-%%
-%% This work consists of the main source file etextools.dtx
-%% and the derived files
-%% etextools.sty, etextools.pdf, etextools.ins,
-%% and etextools-examples.tex
-%%
-%%% etextools : e-TeX tools for LaTeX Users and package Writers (v.3.1)
-\documentclass[11pt,french,a4paper,oneside]{scrartcl}
-\usepackage[latin1]{inputenc}
-\usepackage[T1]{fontenc}
-\usepackage[american]{babel}
-\usepackage{geometry,doc,ltxdockit,txfonts,fancyhdr,stmaryrd,graphicx,enumitem}
-\usepackage{etextools}
-
-\usepackage{fancyvrb}
-
-\def\textvb#1{{\usefont{T1}{txtt}{m}{n}#1}}
-\def\thispackage{\textsf{etextools}}
-\hypersetup{colorlinks,pdfstartview={FitH}}
-\geometry{top=1.5cm,bottom=1.2cm,left=2.5cm,right=1cm}
-\fancyhf{}
-\fancyhead[L]{Examples for the \thispackage package}
-\pagestyle{fancy}
-\DefineShortVerb{\|}
-\catcode`\§ \active\def§{\par\nobreak\vskip-\parskip}
-\makeatletter
-\DefineVerbatimEnvironment{VerbLines}{Verbatim}
- {gobble=1,commandchars=!(),frame=lines,framesep=6pt,fontfamily=txtt,fontseries=m}
-\apptocmd\@list@extra{\parsep\parskip\topsep\z@\itemsep\z@}{}{}
-
-\def\smex{\leavevmode\hb@xt@2em{\hfil$\longrightarrow$\hfil}}
-\def\FE{\setbox8\hbox{$\m@th\bindnasrepma$}%
- \textcolor{fecc}{\scalebox{2}{$\copy8\mkern-13.5mu\copy8\mkern-13.5mu\copy8$}}}
-\def\pdfFE{\setbox8\hbox{$\m@th\bindnasrepma$}%
- \textcolor{fecc}{\llap{\textsf{pdf}\TeX{}\,}\scalebox{2}{$\copy8\mkern-13.5mu\copy8\mkern-13.5mu\copy8$}}}
-\definecolor{fecc}{rgb}{.2,.6,.2}
-\definecolor{dg}{rgb}{0.00,0.37,0.00} \newrobustcmd\dg{\color{dg}} \newrobustcmd\dgbf{\dg\bfseries}
-
-\newrobustcmd\blue{\color{blue}
-\newrobustcmd\nnn{\normalfont\mdseries\upshape}
-
-\def\make@macro#1{\string\def\string#1\parameters@meaning#1\string{\strip@meaning#1\string}}
-\newcommand\preline{\@ifstar{\@preline}{\hrulefill\par\@preline}}
-\newcommand\@preline[2][1.5ex]{\noindent\hskip6pt\textvb{\make@macro#2}\par\ifblank{#1}{}{\vskip#1}}
-
-\ifdef\pdfstrcmp{\let\ifpdfTeX\iffalse}{\let\ifpdfTeX\iftrue}
-
-\newcommand*\test{\@ifstar{\let\fe\pdfFE\testi}{\let\fe\FE\testi}}
-\newcommand\testi[1]{%
- \csname test#1\endcsname
- \edef\usercmd{\strip@meaningcs{test#1}}\edef\result{\meaningcs{#1Test}}\noindent
- \begin{tabular}{lp{15cm}}
- \multicolumn{2}{l}{\textcolor{blue}{\llap{\fe\,\smex}\tt \usercmd}} \\[1.5ex]
- \cmd{#1Test}= & \tt\bfseries\result
- \end{tabular}\par\nobreak\hrulefill\null\goodbreak}
-
-\begin{document}
-\title{etextools examples}
-\subtitle{Examples for some macros provided by the \thispackage package}
-\author{Florent Chervet}
-\date{July 22, 2009}
-\maketitle
-
-\tableofcontents\hyperdef{ettlex}{toc}{}
-
-\section{\cmd{expandnext} examples}
-
-\subsection{Test if the replacement text of macro is really empty}
-
-\def\xx{ }
-\def\testexpandnext{%
- \edef\expandnextTest{\string\xx\ is \expandnext\ifempty{\xx}{}{not} empty}
-}
-\preline\xx
-\test{expandnext}
-
-\def\xx{}
-\preline\xx
-\test{expandnext}
-
-\ClearPage
-\subsection{Test if the replacement text of a macro is blank (empty or spaces)}
-
-\def\xx{something}
-\def\testexpandnext{%
- \edef\expandnextTest{\string\xx\ is \expandnext\ifblank{\xx}{}{not} blank}
-}
-\preline\xx
-\test{expandnext}
-
-\def\xx{ }
-\preline\xx
-\test{expandnext}
-
-\section{\cmd{ExpandNext} examples}
-
-Example of the main documentation file to reverse the order of the characters in a string:
-
-\def\swap#1#2{{#2#1}} \def\do[#1]#2{\swap #2}% \do{abcdef} -> \swap ab + cdef -> {ba}cdef
- % \do{{ba}cdef} -> \swap {ba}c + def -> {cba}def
-
-\edef\result{\naturalloop[\do]{4}{12345}}
-\ExpandNext{\def\RESULT}{\naturalloop[\do]{4}{12345}}
-
-\begin{VerbLines}
-\def\swap#1#2{{#2#1}} \def\do[#1]#2{\swap #2}
-\edef\result{\naturalloop[\do]{4}{12345}}
-\meaning\result = !bfseries!meaning!result
-\ExpandNext{\def\RESULT}{\naturalloop[\do]{4}{12345}}
-\meaning\RESULT = !bfseries!meaning!RESULT
-\end{VerbLines}
-
-\subsection{Test the parameter string of a macro}
-
-The following commands create the filter for the string: "\textvb{[\#1]\#2"}":§
-\begin{VerbLines}[commandchars=!()]
-\ExpandNext{(!blue\DeclareStringFilter\ParaFilt)}
- {\ExpandAftercmds\@gobblescape{\expandafter\string\csname(!blue[#1]#2)\endcsname}}
-\end{VerbLines}
-
-\ExpandNext{\DeclareStringFilter\ParaFilt}
- {\ExpandAftercmds\@gobblescape{\expandafter\string\csname[#1]#2\endcsname}}
-
-\begin{enumerate}[label=\arabic*)~,noitemsep,nolistsep]
-\item |\csname[#1]#2\endcsname| is expanded first
-\item Immediately after: |\string|
-\item At this stage: |\[#1]#2| (everything in category code other) is no more expandable
-\item Then |\ExpandAftercmds| expands |\@gobblescape|
-\item |[#1]#2| is no more expandable
-\item Then |\ExpandNext| expands its first argument: |\DeclareStringFilter\ParaFilt{[#1]#2}|
-\end{enumerate}
-
-Remark: |\detokenize| would have doubled the \# characters. Another possibility is to temporarily change the
-category code of \# to 12 (other):
-\begin{VerbLines}[commandchars=!()]
-\begingroup\catcode`\#=12
- (!blue\DeclareStringFilter\ParaFilt{[#1]#2}) !nnn global declaration
-\endgroup
-\end{VerbLines}
-
-\def\macroA#1#2{Something to do with #1 and #2}
-\def\macroB[#1]#2{Something to do with #1 and #2}
-
-\makeatother
-
-\preline[]\macroA
-\preline*[]\macroB
-\begin{Verbatim}[commandchars=!()]
- !blue\ExpandNext{\ParaFilt=.}{\parameters@meaning\macroA}{macro complies with [\#1]\#2}
- !blue{macro does not comply }
-\end{Verbatim}
-\makeatletter
-\hfill\textvb{\dgbf\ExpandNext{\ParaFilt=.}{\parameters@meaning\macroA}{macro complies with [\#1]\#2}
- {macro does not comply }}
-\begin{Verbatim}[commandchars=!()]
- !blue\ExpandNext{\ParaFilt=.}{\parameters@meaning\macroB}{macro complies with [\#1]\#2}
- !blue{macro does not comply }
-\end{Verbatim}
-\hfill\textvb{\dgbf\ExpandNext{\ParaFilt=.}{\parameters@meaning\macroB}{macro complies with [\#1]\#2}
- {macro does not comply }}
-\par\hrulefill\par
-\makeatother
-
-\section{Testing characters}
-\subsection{\cmd{ifsinglechar} versus \cmd{iffirstchar}}
-\def\testifsinglechar{%
- \edef\ifsinglecharTest{\ifsinglechar *{*hello*}{ single star }{ something else }}
-}\hrulefill\par
-\test{ifsinglechar}
-
-\def\testifsinglechar{%
- \edef\ifsinglecharTest{\ifsinglechar *{ *}{ single star }{ something else }}
-}\hrulefill\par
-\test{ifsinglechar}
-
-\def\testifsinglechar{%
- \edef\ifsinglecharTest{\ifsinglechar *{ * }{ single star }{ something else }}
-}\hrulefill\par
-\test{ifsinglechar}
-{\small Note the space \textbf{after} the star $\uparrow$.}
-
-\def\testiffirstchar{%
- \edef\iffirstcharTest{\iffirstchar *{*hello*}{ first char is star }{ something else }}
-}\hrulefill\par
-\test{iffirstchar}
-
-\subsection{Fully Expandable starred macros}
-\def\starmacro#1{\FE@ifstar{#1}\starred\notstarred}
-\def\starred#1{your "#1" will be processed by the STAR form}
-\def\notstarred#1{your "#1" will be processed by the NORMAL form}
-\def\testFE@ifstar{%
- \edef\FE@ifstarTest{\starmacro{sample text}}}
-\preline\starmacro
-\preline*\starred
-\preline*\notstarred
-\test{FE@ifstar}
-
-\def\testFE@ifstar{%
- \edef\FE@ifstarTest{\starmacro*{sample text}}}
-\hrulefill\par
-\test{FE@ifstar}
-
-\subsection{Fully Expandable macros with options}
-\def\optmacro#1{\FE@testopt{#1}\OPTmacro{Mr.}}
-\def\OPTmacro[#1]#2{#1 #2}
-\def\testFE@testopt{%
- \edef\FE@testoptTest{\optmacro{Woody Allen}}}
-\preline\optmacro
-\preline*\OPTmacro
-\test{FE@testopt}
-
-\def\testFE@testopt{%
- \edef\FE@testoptTest{\optmacro[Ms.]{Vanessa Paradis}}}
-\hrulefill\par
-\test{FE@testopt}
-
-\section{Lists management}
-
-\subsection{\cmd{csvloop} and \cmd{csvloop*} examples}
-
-\subsubsection{\cmd{makequotes}}
-\def\makequotes#1{"#1"\space}
-\def\testcsvloop{%
- \edef\csvloopTest{\csvloop*[\makequotes]{hello,world}}
-}
-\preline\makequotes
-\test{csvloop}
-
-\subsubsection{\cmd{detokenize}}
-\def\testcsvloop{%
- \edef\csvloopTest{\csvloop*[\detokenize]{\un,\deux}}
-}\hrulefill\par
-\test{csvloop}
-
-\subsubsection{\cmd{numexpr}}
-\def\mylist{1,2,3,4,5}\def\BySeven#1{$#1\times 7 = \number\numexpr#1*7\relax$\par}
-\def\testcsvloop{%
- \edef\csvloopTest{\csvloop[\BySeven]\mylist}}
-\preline\mylist
-\preline*\BySeven
-\test{csvloop}
-
-\subsubsection{protected \cmd{textbf}}
-\def\testcsvloop{%
- \protected@edef\csvloopTest{\csvloop*[\textbf]{hello ,my ,friends}}
-}\hrulefill\par
-\test{csvloop}
-
-\subsection{Index in lists and items by index}
-
-\subsubsection{\cmd{getlistitem}}
-\csvtolist*\mylist{one,two,three,four,five,alpha,beta,gamma}
-\def\testgetlistitem{%
- \edef\getlistitemTest{\getlistitem{4}\mylist}
-}\hrulefill\par
-\noindent\hskip6pt|\csvtolist*\mylist{one,two,three,four,five,alpha,beta,gamma}|\par\vskip1.5ex
-\test{getlistitem}
-
-\subsubsection{\cmd{getlistindex}}
-\ifpdfTeX
-\leavevmode\vadjust{\textsl{Require the }\string\pdfstrcmp\ \textsl{primitive (pdf\TeX{}) :}}
-\def\testgetlistindex{%
- \edef\getlistindexTest{\getlistindex{alpha}\mylist}
-}\hrulefill\par
-\noindent\hskip6pt|\csvtolist*\mylist{one,two,three,four,five,alpha,beta,gamma}|\par\vskip1.5ex
-\test*{getlistindex}
-
-\leavevmode\vadjust{\textsl{Require the }\string\pdfstrcmp\ \textsl{primitive (pdf\TeX{}) :}}
-\def\testgetlistindex{%
- \edef\getlistindexTest{\getcsvlistindex*{alpha}{one,two,three,four,five,alpha,beta}}
-}\hrulefill\par
-\test*{getlistindex}
-\fi
-
-\hrulefill\par
-\getlistindex[\myindex]{alpha}\mylist
-{\color{blue}\noindent\hskip6pt\llap\smex|\getlistindex[\myindex]{alpha}\mylist|\par\vskip1.5ex}
-{\tt\string\myindex=\quad\textbf{\meaning\myindex}}
-\hrulefill\par\vskip.5ex
-
-\hrulefill\par
-\newcount\myindex
-\getcsvlistindex*[\myindex]{alpha}{one,two,three,four,five,alpha,beta}
-\noindent\hskip6pt|\newcount\myindex|\par
-{\color{blue}\noindent\hskip6pt\llap\smex|\getcsvlistindex*[\myindex]{alpha}{one,two,three,four,five,alpha,beta}|}\par\vskip.5ex
-{\tt\string\the\string\myindex=\qquad\textbf{\the\myindex}}
-\hrulefill\par\vskip.5ex
-
-\subsubsection{\cmd{xgetlistindex}}
-\ifpdfTeX
-\leavevmode\vadjust{\textsl{Require the }\string\pdfstrcmp\ \textsl{primitive (pdf\TeX{}) :}}
-\def\x{beta}
-\def\testxgetlistindex{%
- \edef\xgetlistindexTest{\xgetlistindex{\x}\mylist}
-}\hrulefill\par
-\noindent\hskip6pt|\csvtolist*\mylist{one,two,three,four,five,alpha,beta,gamma}|\par\vskip1.5ex
-\preline*\x
-\test*{xgetlistindex}
-\fi
-
-\subsubsection{\cmd{getlistindex} with \cmd{ifcase}}
-
-\leavevmode\vadjust{Always purely expandable (no need of |\pdfstrcmp|, comparison done by |\ifx|):}
-\hrulefill\par\noindent
-\llap{\FE\,\smex}\par\vskip-2.5\baselineskip\strut
-\begin{Verbatim}
- \ifcase \gettokslistindex*{D}{LRDF\relax O}
- Problem
- \or What do to if L
- \or What do to if R
- \or What do to if D
- \or What do to if F
- \or What do to if \relax
- \or What do to if O
- \fi
-\end{Verbatim}
-
-{\tt Result=\qquad\bfseries
-\ifcase\gettokslistindex*{D}{LRDF}
- Problem
-\or What do to if L
-\or What do to if R
-\or What do to if D
-\or What do to if F
-\fi}\par
-\hrulefill\par\vskip.5ex
-
-\end{document}
-
-
-\endinput
-%%
-%% End of file `etextools-examples.tex'.