summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/dowith/domore.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/dowith/domore.sty')
-rw-r--r--Master/texmf-dist/tex/generic/dowith/domore.sty136
1 files changed, 136 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/dowith/domore.sty b/Master/texmf-dist/tex/generic/dowith/domore.sty
new file mode 100644
index 00000000000..4650db60e61
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/dowith/domore.sty
@@ -0,0 +1,136 @@
+ \input plainpkg
+\ProvidesPackage{domore}[2012/11/19 v0.3 dowith extended (UL)]
+%% Copyright (C) 2012 Uwe Lueck,
+%% http://www.contact-ednotes.sty.de.vu
+%% -- author-maintained in the sense of LPPL below --
+%%
+%% This file can be redistributed and/or modified under
+%% the terms of the LaTeX Project Public License; either
+%% version 1.3c of the License, or any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% We did our best to help you, but there is NO WARRANTY.
+%%
+%% Please report bugs, problems, and suggestions via
+%%
+%% http://www.contact-ednotes.sty.de.vu
+%%
+%% == With \LaTeX, extend 'dowith''s \cs{setdo} ==
+%% %% mod. 2012/11/06:
+%% The original 'dowith' offers |\setdo{<do>}|
+%% for defining a one-parameter macro `\do' expanding to <do>.
+%% The present package allows applying a <digit>-parameter macro
+%% (maybe `\do', <digit> being 2, 3, or ...)
+%% to a list of "brace groups" where each brace group
+%% contains <digit> arguments. If \LaTeX\ is present ...
+\ifltx
+%% ... the following extension
+%% \[|\setdo[<digit>]{<do>}]|\]
+%% of the basic 'dowith' version
+%% can be used to define a <digit>-parameter macro `\do'.
+%% You also can equip `\do' with an initial optional argument by
+%% \[|\setdo[<digit>][<default>]{<do>}]|\]
+%% The next two moves allow loading the package
+%% independently of 'dowith' (overriding its definition of `\setdo')
+%% as well as using the package
+%% with a format that has not defined `\do' before.
+%% The first parameter of `\do' may even be \emph{optional.}
+ \let\setdo\relax \let\do\empty
+ \newcommand*{\setdo}[1][1]{\renewcommand\do[#1]}
+\fi
+%%
+%% == Auxiliaries ==
+%% |\@firstsecondoftwo{<balanced-1>}{<balanced-2>}| \
+%% is a variant of \LaTeX's `\@firstofone{<balanced>}' for
+%% \emph{two} arguments. It just removes outer braces
+%% from each of the two arguments (provided it has outer braces),
+%% resulting in \[<balanced-1><balanced-2>\]
+\long\def\@firstsecondoftwo#1#2{#1#2}
+%% % |\@secondfirstoftwo<arg-1><arg-2>| results in <ark-2><ark-1>
+%% % where <ark-1> is ...
+%% % [TODO declare "meta-function removing braces"---in 'dowith' documentation]
+%% % (<arg-1>, <arg-2> must not contain `\par' tokens so far---TODO):
+%% |\@secondfirstoftwo{<balanced-1>}{<balanced-2>}|
+%% \emph{additionally} interchanges the two arguments
+%% (after removing braces):
+\long\def\@secondfirstoftwo#1#2{#2#1}
+%% Our main application is using it as an extended `\expandafter'
+%% before `\fi':
+%% \[`\@secondfirstoftwo{<do>}\fi'\]
+%% will expand to
+%% \[`\fi<do>'\]
+%% This won't work with `\else' in place of `\fi'.
+%%
+%% == Enhanced \cs{DoWith} ==
+%% Here comes a more powerful variant of 'dowith''s `\DoWith'.
+%% Instead of iterating a single "command" <cmd>
+%% on an arglist <args> by
+%% \[`\DoWith{<cmd>}<args>\StopDoing'\]
+%% (cf. `dowith.pdf'), the present `\DoWith' can have a
+%% more complex first argument. If <args> consists
+%% of some brace groups the first of which is {<farg>}
+%% so that <args> is
+%% \[`{<farg>}<rgs>'\]
+%% ---<rgs> being the remaining arglist---
+%% \[|\DoWith{<repeat>}<args>\StopDoing|\]
+%% works like
+%% \[`<repeat>{<farg>}\DoWith{<repeat>}<rgs>\StopDoing'\]
+%% and so on---a recursive explanation. Or if <args> is
+%% \[`{<arg-1>}{<arg-2>}'\dots`{<arg-n>}'\]
+%% ($n$ items), the result is like
+%% \[`<repeat>{<arg-1>}<repeat>{<arg-2>}'\dots`<repeat>{<arg-n>}'\]
+%% The actual definition is:
+\def\DoWith#1#2{%
+ \ifx\StopDoing#2\empty %% not \@empty for Plain 2012/11/05
+ \else\@secondfirstoftwo{#1{#2}\DoWith{#1}}\fi}
+%% In order to \strong{use} the remaining definitions from \strong{'dowith'
+%% together with the present package}, %% \strong 2012/11/06
+%% load `dowith.sty' before `domore.sty'.
+%%
+%% == Applications of \cs{DoWith} ==
+%% `\DoWith' still is somewhat auxiliary. What I have used in practice,
+%% are the following definitions.
+%%
+%% |\DoMore{<repeat>}<args>\StopDoing| with <args> as above
+%% "unpacks" each arglist item so that <repeat> may be a macro
+%% with more than one argument---say, <digit> arguments.
+%% Then <f-arg> or <arg-1>, as well as <arg-2> $\dots$ <arg-n>,
+%% should provide an arglist consisting of <digit> items.
+\def\DoWithMore#1{\DoWith{\@firstsecondoftwo{#1}}}
+%% Now I use metavariable <do> instead of <repeat>.
+%% We consider some "separator" material <sep> to be inserted
+%% between instances of applying <do> to an item of <args>.
+%% We want to get
+%% \[`<do>{<arg-1>}<sep><do>{<arg-2>}<sep>'\dots`<sep><do>{<arg-n>}'\]
+%% This is achieved simply by starting with
+%% \[`<do>{<farg>}'\]
+%% and then proceeding as with
+%% \[`\DoWith{<sep><do>}<rgs>\StopDoing'\]
+%% And that's what |\DoSeparateWith{<do>}{<sep>}<args>\StopDoing| does:
+\def\DoSeparateWith#1#2#3{#1{#3}\DoWith{#2#1}}
+%% |\DoSeparateWithMore{<do>}{<sep>}<args>\StopDoing| combines
+%% the two previous things, inserting separator material <sep>
+%% and unpacking the nested arg\-lists:
+\def\DoSeparateWithMore#1#2{% %% wieder 2012/06/05
+ \DoSeparateWith{\@firstsecondoftwo{#1}}{#2}}
+%% My main application is that <do> is a link macro with arguments
+%% <target> and <text> and that <sep> is \qtdcode{~\string|~}
+%% (or some tie variant) to get a horizontal list of links like
+%% \[\def|{$\vert$}\mbox{<text-1> | <text-2> | \dots | <text-n>}\]
+%%
+%% == Leaving and History ==
+\PopLetterCatAt
+\endinput
+
+VERSION HISTORY
+v0.1 2012/01/17 developed in `texblog.fdf'
+ (using \[re]newcommand*)
+v0.2 2012/08/07 own file `domore.sty', \def's only
+ 2012/08/08 dealing with "more" \setdo
+v0.3 2012/11/05 using `plainpkg'; removing old % code
+ (see stored v0.2); auxiliaries \long
+ 2012/11/06 doc.: more on \setdo (<digit>, opt. arg.),
+ usage with `dowith' \strong
+ 2012/11/18 doc.: adjusted for `catchdq'; reworking for
+ \DoWith; \DoWithMore, \DoSeparateWith
+ 2012/11/19 doc.: \DoSeparateWithMore