From 0b1aff326b63ee76fb6332beef1696f753d8e591 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 7 Mar 2009 00:46:50 +0000 Subject: new latex package exp-testopt (6mar09) git-svn-id: svn://tug.org/texlive/trunk@12327 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/exp-testopt/README | 392 ++++++++++++++++++ .../doc/latex/exp-testopt/exp-testopt.pdf | Bin 0 -> 139231 bytes .../doc/latex/exp-testopt/exp-testopt.test | 78 ++++ .../source/latex/exp-testopt/exp-testopt.dtx | 459 +++++++++++++++++++++ .../source/latex/exp-testopt/exp-testopt.ins | 75 ++++ .../tex/latex/exp-testopt/exp-testopt.sty | 101 +++++ Master/tlpkg/bin/tlpkg-ctan-check | 3 +- Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc | 1 + Master/tlpkg/tlpsrc/exp-testopt.tlpsrc | 2 + 9 files changed, 1110 insertions(+), 1 deletion(-) create mode 100644 Master/texmf-dist/doc/latex/exp-testopt/README create mode 100644 Master/texmf-dist/doc/latex/exp-testopt/exp-testopt.pdf create mode 100644 Master/texmf-dist/doc/latex/exp-testopt/exp-testopt.test create mode 100644 Master/texmf-dist/source/latex/exp-testopt/exp-testopt.dtx create mode 100644 Master/texmf-dist/source/latex/exp-testopt/exp-testopt.ins create mode 100644 Master/texmf-dist/tex/latex/exp-testopt/exp-testopt.sty create mode 100644 Master/tlpkg/tlpsrc/exp-testopt.tlpsrc diff --git a/Master/texmf-dist/doc/latex/exp-testopt/README b/Master/texmf-dist/doc/latex/exp-testopt/README new file mode 100644 index 00000000000..c9d7fcc3030 --- /dev/null +++ b/Master/texmf-dist/doc/latex/exp-testopt/README @@ -0,0 +1,392 @@ +[en] + +LaTeX-package 'exp-testopt' - expandable variant of \@testopt + +Author: Paul Ebermann +License: LPPL 1.3b or later, maintained + (see http://www.latex-project.org/lppl/). +Version: 0.3 + +All Documentation (other than this file) is in Esperanto. + +This package is meant for use by other packages. + +This package provides an expandable variant of the LaTeX +kernel command \@testopt, named \@expandable@testopt, and +a more general \@expandable@ifopt, both intended for package +writers. Also we have a variant of \newcommand which +uses these macros to check for optional arguments. + + +This Package needs no other packages for running. + +The typesetting of the documentation needs additionally +class scrartcl (KOMA-script), gmdoc-enhance (from me) +and gmdoc (from Grzegorz `Natror' Murzynowski), +gmdoc's dependencies, and some required LaTeX packages. + +The package comes as .dtx + .ins. +Run "tex exp-testopt.ins" to create the style file (and maybe put +it to texmf/tex/latex/paul/, if your docstrip is configured +accordingly), run (after that and maybe updating your TeX hash) +"latex exp-testopt.dtx" to create the documentation. +(Docstrip also creates an exp-testopt.test in the same directory, + which is to be used by the documentation.) + + Usage +------- + +There are two main commands for package writers: + + \@expandable@ifopt{}{} + \@expandable@testopt{}{} + +Both of them try to check, wether following them is a optional +argument (this is, some stuff enclosed in []). In this case, +they expand to: + + +In the other case, they expand to: + + [] + +So, \@expandable@ifopt is a general branch command, while +\@expandable@testopt is meant as a replacement for \@testopt, +where is "any sequence of commands that 'expects' to +be followed by [." (Quoted from ltdefns.dtx.) + +This replacement has the advantage of being expandable +(if is so), but also has quite some limitations. + + +A third command is: + + \expnewcommand*{}[][]{} + +This works like \newcommand, but when a command with an +optional argument is defined, it uses our expandable check +for the existence of the optional argument. (Without the default +argument it should work exactly the same.) + + Examples +---------- + + +The main usage is in definitions of commands, which are to +accept optional arguments. + + \expnewcommand*{\example}[1][Default]{% + \fbox{#1}% + } + +Thus \example outputs an box with "Default" in it, while +\example[Test] hat "Test" in it. + + +From another package (to be published soon): + + \expnewcommand*\monthName[2][\languagename]{% + \@format@month@name{#1}{\value{#2}}% + } + +This outputs the value of a given LaTeX counter as +a name of the like-numbered month, in the given +language, the default language being the current +babel language. (And here the expansibility is important, +since we don't want the value of the counter when +this is printed, but now, also when this ends up in +the table of contents.) + +When you want more control, you may use \@expandable@ifopt{}{}: + + \def\exampleOne{% + \@expandable@ifopt{% + \exampleOneOpt}{% + \exampleOneNoOpt}% + } + + \def\exampleOneOpt[#1]{#2}{ + % do something with #1 and #2 + } + \def\exampleOneNoOpt#1{% + % do some other thing with #1 + } + +With \@expandable@testopt{}{} you may also +create commands which accept more than one optional argument. + + + Benefits +---------- + +The advantages of \expnewcommand and \@expandable@testopt to +\newcommand and \@testopt are in the expandibility of the created +commands - you can use them in moving arguments (like inside of +\protected@edef, \protected@write and so on), and the accessed variables +then have their current meanings (or the meaning at shipout time, for +write), not the meanings when the thing is finally typeset. + +\newcommand, on the other hand, creates protected commands - you can +use them also in moving arguments, but they are evaluated only at +typesetting time. + +What to use when depends heavily on the use case. + + + Limitations +------------- + +Since we want to be expandable, we really can't check the next +token, but only the next "macro argument". And comparing also +is not so easy when you can't assign something to a macro. + +So, we use as a workaround making a control sequence from the +next argument (trying to neutralize a bit things like control +sequences), and comparing them to a known control sequence. + +This has the following consequences: + +- we cant distinguish between [ and {[} - the second one + is also regarded as a "start of optional argument". + +- the next argument (when it is not simple '[') has to be of a + "friendly" kind - it should not contain braces, and any + "dangerous" token (anything not of category 10, 11, 12) + should come as the first token (only then it is neutralized). + (Often the next argument is only one token, then this is no + problem. Or it will be simple text, also no problem.) + + Otherwise, there will be strange errormessages. + +- multiple space tokens before the [ may irritate our + macros. + + +So, before using this macros, make sure the limitations don't +affect you. + + + +Have fun! + +------------- +[de] + +LaTeX-Paket 'exp-testopt' - Expandierbare Variante von \@testopt. + +Autor: Paul Ebermann (Paul-Ebermann@gmx.de). +Lizenz: LPPL 1.3b oder später, mit Maintenance-Status + "author-maintained". Siehe http://www.latex-project.org/lppl/. +Version 0.3 + +Geschrieben für eigenen Gebrauch +(d.h. für Nutzung in anderen LaTeX-Paketen von Paul Ebermann), aber +vielleicht ist es auch für andere von Nutzen. + +Die Dokumentation (außer dieser Datei) ist nur auf Esperanto. + + +Dieses Paket ist für Verwendung in anderen LaTeX-Paketen gedacht. +Es enthält eine expandierbare Variante des LaTeX-Kernel-Kommandos +\@testopt unter dem Namen \@expandable@testopt, eine +Verallgemeinerung davon als \@expandable@ifopt sowie eine Variante +von \newcommand, welche diese Makros nutzt, um die Existenz +optionaler Argumente festzustellen. + + +Das Paket kommt als .dtx + .ins. +Mit "latex exp-testopt.ins" wird die .sty-Datei erstellt (und +eventuell gleich nach texmf/tex/latex/paul/ installiert, +wenn docstrip entsprechend eingerichtet ist), mit +"latex exp-testopt.dtx" kann (danach und eventuell nach einer +Aktualisierung der TeX-Dateidatenbank) die Dokumentation neu +erstellt werden. +Docstrip erstellt auch eine Datei exp-testopt.test, welche nur +von der Dokumentation verwendet wird (vom Paket nicht verwendet). + + + Anwendung +---------- + +Die beiden Haupt-Kommandos für Package-Autoren: + + \@expandable@ifopt{}{} + \@expandable@testopt{}{} + +Beide versuchen herauszufinden, ob nach ihnen ein optionales +Argument folgt (das ist irgend etwas, was in [...] eingeschlossen +ist). In diesem Fall expandieren diese Makros zu: + + + + +Im anderen Fall expandieren sie zu: + + + [] + +\@expandable@ifopt ist also ein genereller Verzweigungsbefehl, +während \@expandable@testopt (welches dem Paket den Namen gab) +ein Ersatz für \@testopt aus dem LaTeX-Kernes ist: hier sollte + eine beliebige Sequenz von Kommandos sein, welche es +'erwartet', von [ gefolgt zu werden. (Frei übersetzt aus +ltdefns.dtx.) Damit kann man Makros mit optionalen Argumenten +und Defaultwerten für diese bauen. + +Dieser Ersatz hat den Vorteil, expandierbar zu sein (falls + dies ist), hat aber auch einige Beschränkungen (siehe +unten). + +Ein drittes Kommando ist: + + \expnewcommand*{}[][]{} + +Es funktioniert analog zu \newcommand, mit dem Unterschied, +dass (falls gegeben ist) die Überprüfung auf +optionale Argumente mit unserem \@expandable@testopt anstatt +mit \@testopt (bzw. seiner protected-Variante) geschieht. +(Ohne diesen Default-Wert sollten beide Definitionen exakt + identisch sein.) + + Beispiele +----------- + +Die Hauptverwendung wird die Definition von Kommandos mit +optionalen Argumenten sein: + + \expnewcommand*{\example}[1][Default]{% + \fbox{#1}% + } + +Hier gibt \example einen Kasten mit "Default" drin aus, wobei +\example[Test] ein "Test" im Kasten hat. + +Aus einem meiner anderen Packages (wird bald veröffentlicht) +sinngemäß: + + \expnewcommand*\monthName[2][\languagename]{% + \@format@month@name{#1}{\value{#2}}% + } + +Das gibt den Wert eines LaTeX-Zählers in der Form +eines Monatsnamens in der gewählten Sprache aus, wobei +der Default die aktuelle Babel-Sprache ist. +(Hierbei braucht man die Expansibilität wirklich, denn + wir wollen ja den aktuellen Wert des Zählers (und der + Sprache) haben, auch wenn das ganze nachher im + Inhaltsverzeichnis landet, wo eventuell andere Werte + aktuell sind.) + +Mehr Kontrolle bekommt man mit \@expandable@ifopt: + + + \def\exampleOne{% + \@expandable@ifopt{% + \exampleOneOpt}{% + \exampleOneNoOpt}% + } + + \def\exampleOneOpt[#1]#2{ + % mache etwas mit #1 und #2 + } + \def\exampleOneNoOpt#1{% + % mache etwas ganz anderes mit #1 + } + +Mit \@expandable@testopt kann man auch Kommandos basteln, +welche mehr als ein optionales Argument enthalten. + + + + Vorteile +--------- + +Die Vorteile von \expnewcommand sowie \@expandable@testopt +im Vergleich zu \newcommand und \@testopt aus dem Kernel liegen +in der Expandierbarkeit der erstellten Kommandos - man kann sie +innerhalb von bewegten Argumenten nutzen (wie \protexted@edef, +\@protected@write etc.) und die darin verwendeten Variablen +haben dann ihre aktuellen Werte, nicht die Werte, wenn der +Text endlich gesetzt wird. + +\newcommand (mit den optionalen Argumenten) erstellt "geschützte" +Kommandos - man kann sie in bewegten Argumenten verwenden, aber +sie werden erst dann ausgewertet, wenn sie gesetzt werden. + + +Welche der beiden Möglichkeiten besser ist, hängt stark von +der jeweiligen Situation ab. + + + Begrenzungen +-------------- + +Weil wir expandierbare Makros haben wollen, können wir nicht +wirklich (wie es \@testopt macht) das nächste Token überprüfen, +sondern nur das "nächste Makro-Argument". Der Vergleich ist +auch nicht einfach, wenn man keine Zuweisungen/Definitionen +machen darf. + +Als Workaround erstellen wir eine Kontrollsequenz aus dem +nächsten Argument (und versuchen dabei, es etwas unschädlich +zu machen), und vergleichen diese mit einer bekannten +Kontrollsequenz. + +Das hat die folgenden Konsequenzen: + +- Wir können nicht zwischen [ und {[} unterscheiden - auch + das zweite wird als "Anfang eines optionalen Argumentes" + interpretiert. + +- Das nächste Argument (wenn es denn nicht ein einfaches '[' + ist) muss sich friedlich verhalten - es sollte keine + {} enthalten, und andere gefährliche Token (alles, was nicht + Kategorie 10, 11, 12 hat) sollten nur an erster Stelle + auftauchen (da können sie unschädlich gemacht werden). + + (Wenn das nächste Argument nur aus einem Token besteht, + ist das kein Problem, auch nicht, wenn es einfach nur + Text ist.) + + Andernfalls kann es zu merkwürdigen Fehlermeldungen kommen. + +- Falls vor dem '[' mehrere Leerzeichen-Token kommen, kann + das unsere Makros verwirren. + + +Also, bitte vor dem Verwenden dieser Makros aufpassen, dass +die Beschränkungen nicht stören. + + +Viel Spaß! + +---------- +[eo] + +LaTeX-pakaĵo 'exp-testopt' - plibonigoj por gmdoc. +(Se vi ne scias, kio estas gmdoc, legu sube.) + +Aŭtoro: Paŭlo Ebermann (Paul-Ebermann@gmx.de). +Licenzo: LPPL 1.3, 'maintained' + (-> http://www.latex-project.org/lppl/). +Versio 0.3 + +Kreitaj por propra uzo, sed eble iom de ĝi ankaŭ +uzeblas por aliaj. + +La dokumentaro (escepte tiu ĉi dosiero) estas nur en la germana +lingvo. + +La pakaĵo ne bezonas ajnajn aliajn pakaĵojn. +Por la dokumentado bezonatas gmdoc, gmdoc-enhance +kaj scrartcl (KOMA-script). + + +La pakaĵo venas en .dtx + .ins. +Voku "latex exp-testopt.ins" por krei la .sty-dosieron (kaj +eble meti ĝin al texmf/tex/latex/paul/, se via docstrip estis +konfigurita laŭe), voku "latex exp-testopt.dtx" por rekrei +la dokumentaron. + +La dokumentaĵo estas en exp-testopt.pdf. + diff --git a/Master/texmf-dist/doc/latex/exp-testopt/exp-testopt.pdf b/Master/texmf-dist/doc/latex/exp-testopt/exp-testopt.pdf new file mode 100644 index 00000000000..411b0a28f91 Binary files /dev/null and b/Master/texmf-dist/doc/latex/exp-testopt/exp-testopt.pdf differ diff --git a/Master/texmf-dist/doc/latex/exp-testopt/exp-testopt.test b/Master/texmf-dist/doc/latex/exp-testopt/exp-testopt.test new file mode 100644 index 00000000000..6af0f955b38 --- /dev/null +++ b/Master/texmf-dist/doc/latex/exp-testopt/exp-testopt.test @@ -0,0 +1,78 @@ +%% +%% This is file `exp-testopt.test', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% exp-testopt.dtx (with options: `test') +%% +%% IMPORTANT NOTICE: +%% +%% For the copyright see the source file. +%% +%% Any modified versions of this file must be renamed +%% with new filenames distinct from exp-testopt.test. +%% +%% For distribution of the original source see the terms +%% for copying and modification in the file exp-testopt.dtx. +%% +%% This generated file may be distributed as long as the +%% original source files, as listed above, are part of the +%% same distribution. (The sources need not necessarily be +%% in the same archive or directory.) +%% (C) 2008 Paul Ebermann +%% +%% Package exp-testopt - expandible testopt-Variante. +%% +%% Die Datei exp-testopt.dtx sowie die dazugehörige +%% exp-testopt.ins sowie die damit generierte +%% exp-testopt.sty stehen unter der +%% "LaTeX Project Public License" (LPPL, zu finden +%% unter http://www.latex-project.org/lppl/, sowie +%% auch in den meisten TeX-Distributionen in +%% texmf/docs/latex/base/lppl*.txt), Version 1.3b oder +%% später (nach Wahl des Verwenders). +%% +%% Der 'maintenance-status' ist (zur Zeit) 'author-maintained'. +%% +%% Das heißt u.a., die Dateien dürfen frei vertrieben werden, +%% bei Änderungen (durch andere Personen als Paul Ebermann) +%% ist aber der Name der Datei zu ändern. +\makeatletter +\errorcontextlines = 20 + +\def\beispiel{% + \@expandable@testopt\beispielImpl{Default}% +} +\def\beispielImpl[#1]{% + \fbox{#1}% +} +\makeatother + +\expnewcommand*{\ekzemplo}[1][Defa\u ulto]{% + \textbf{(#1)}% +} + +\expnewcommand*{\ekzemploDu}[2][defa\u ulto]{% + \ensuremath{\frac{\mbox{#1}}{\mbox{#2}}}% +} + + \beispiel{egal} \beispiel[bla] + \beispiel$ e=m c^2$ \beispiel[$ e=m c^2$] + + \ekzemplo\ekzemplo[Bla] + \expandafter\ekzemplo\space[bla] + \expandafter\expandafter\expandafter\ekzemplo\expandafter\space\space[dua bla] + \ekzemplo + [nova linio] + \ekzemplo + + [du novaj linioj] + \ekzemplo[blub] + + \ekzemploDu{testo} + \ekzemploDu[bla]{testo} + +\endinput +%% +%% End of file `exp-testopt.test'. diff --git a/Master/texmf-dist/source/latex/exp-testopt/exp-testopt.dtx b/Master/texmf-dist/source/latex/exp-testopt/exp-testopt.dtx new file mode 100644 index 00000000000..6cefe7715ae --- /dev/null +++ b/Master/texmf-dist/source/latex/exp-testopt/exp-testopt.dtx @@ -0,0 +1,459 @@ +% \iffalse meta-comment +% +%% (C) 2008 Paul Ebermann +%% +%% Package exp-testopt - expandible testopt-Variante. +%% +%% Die Datei exp-testopt.dtx sowie die dazugehörige +%% exp-testopt.ins sowie die damit generierte +%% exp-testopt.sty stehen unter der +%% "LaTeX Project Public License" (LPPL, zu finden +%% unter http://www.latex-project.org/lppl/, sowie +%% auch in den meisten TeX-Distributionen in +%% texmf/docs/latex/base/lppl*.txt), Version 1.3b oder +%% später (nach Wahl des Verwenders). +%% +%% Der 'maintenance-status' ist (zur Zeit) 'author-maintained'. +%% +%% Das heißt u.a., die Dateien dürfen frei vertrieben werden, +%% bei Änderungen (durch andere Personen als Paul Ebermann) +%% ist aber der Name der Datei zu ändern. +% +% \fi +% +% \iffalse +% --------------------------------------------- +%\NeedsTeXFormat{LaTeX2e}[2005/12/01]% +% ----------------------------________________----------------- +%\ProvidesPackage{exp-testopt}[2009/03/06 v0.3 (PE)] +% ----------------------------________________----------------- +% \fi +% +% \iffalse +%<*driver> +\PassOptionsToClass{draft}{scrartcl} +\documentclass{scrartcl} +% +% Esperantajn tekstojn oni prefere entajpu per unikodaj literoj. +\usepackage[utf8x]{inputenc} +\usepackage[esperanto]{babel} + +\addto{\extrasesperanto}{% + \renewcommand*{\generalname}{\^Generale}% + \GlossaryPrologue{% + \section{\^San\^goj}% + }% + \GlossaryMin=3\baselineskip + \IndexPrologue{% + \section{Indekso} + Kurzivaj nombroj indikas la lokojn, kie la indeks-ero estas priskribita, + substrekitaj nombroj indikas la lokon de la difino, la aliaj estas uzoj. + } + \IndexMin=5\baselineskip +} + + +\usepackage[svgnames]{xcolor} + +\usepackage{exp-testopt} + +\usepackage[bookmarks=false]{hyperref} +\usepackage[countalllines, withmarginpar]{gmdoc} +\usepackage[inline, visible]{gmdoc-enhance} +\let\pack\textrm% +\renewcommand*{\EOFMark}{} + + + +\newenvironment{kodo-citajho}[1][english]{% + \par + \addtolength{\CodeIndent}{1cm} + \addtolength{\TextIndent}{1cm} + \addtolength{\rightskip}{1cm} + \renewcommand*{\printlinenumber}{% + \leavevmode + \llap{\rlap{% + \hspace*{1cm}% + \LineNumFont$\phantom{999}$\llap{% + $(\thecodelinenum)$}}% + \hskip\leftskip% + % + }% + } +%! \addmargin{5em} + \csname otherlanguage*\endcsname{#1}% + \slshape% + \expandafter\addtomacro\csname ttverbatim@hook\endcsname{\slshape}% + \MakeShortVerb\|\DeleteShortVerb\'% +}{ + \MakeShortVerb\'\DeleteShortVerb\|% + \csname endotherlanguage*\endcsname% + \endaddmargin +} + +\addtomacro\LineNumFont{\normalcolor} + + +\RecordChanges +\begin{document} + % ^ ne taŭgas kiel specialsigno, ĉar ni + % bezonas ĝin por ^^B, ^^M ktp. + \catcode`\^=7% + \MakeShortVerb\' + \DocInput{exp-testopt.dtx} +\end{document} +% +% \fi +% +% \chschange{v0.1}{2009/03/03}{37} +% \chschange{v0.2}{2009/03/03}{90} +% \chschange{v0.3}{2009/03/06}{139} +% \changes{v0.1}{2009/03/03}{Unua versio} +% \changes{v0.2}{2009/03/03}{Preta por publikigo, mi kredas.} +% \changes{v0.3}{2009/03/06}{Post pluraj cimkorektoj nun vere\ +% preta \dots} +% +% \GetFileInfo{exp-testopt.sty} +% +% +% \title{La \pack{exp-testopt}-Pakaĵo -- ekspandebla varianto de \ +% \cs{@testopt}. \thanks{ Tiu dokumento rilatas al \ +% \pack{exp-testopt}~\fileversion, de~\filedate.}} +% \author{Paul Ebermann\thanks{\texttt{Paul-Ebermann@gmx.de}}} +% +% \maketitle +% +% +% \begin{abstract} +% Ekspandebla varianto de '\@testopt' el la \LaTeX-kerno, kaj iom +% pli ĝenerala (ankaŭ ekspandebla) '\@expandable@ifopt', por rekoni +% ekziston de opciaj argumentoj (sen tuj doni defaŭlton). +% Ankaŭ '\newcommand'-varianto, kiu uzas tion. +% \end{abstract} +% +% +% \tableofcontents +% +% \section{Uzanta dokumentaĵo} +% +% Tiu ĉi pakaĵo enhavas unu makroon rekte uzebla de uzantoj, kvankam +% ankaŭ ĝin verŝajne pli ofte uzos pakaĵo-kreantoj. +% Krome ĝi enhavas du utilajn makroojn por pakaĵ-kreantoj +% (ne por uzantoj). +% +% \subsection{Makrooj} +% +% \TextUsage{\expnewcommand}'*'\arg{nomo}\arg[paramnum]\ +% \arg[defaŭlto]\arg{kodo} +% -- +% funkcias simile kiel '\newcommand': Kreas komandon kun \meta{num} parametroj +% (ĝis 9), kaj se \meta{defaŭlto} estas donita, la unua parametro estos +% opcia kun \meta{defaŭlto} kiel defaŭlta valoro. +% Diferenco al '\newcommand' nur ekzistas, se \meta{defaŭlto} estas +% donita -- tiam je voko de la makroo ni uzas ekspandeblan komparon +% por ekscii, ĉu unua parametro estas donita. (Tio havas la avantaĝon +% esti ekspandebla, sed la limigojn menciitajn sube.) +% +% +% \TextUsage{\@expandable@testopt}\marg{ordono}\marg{defaŭlto} +% -- +% vokas \meta{ordono}n kun '[]'-parametro -- se neniu plia estas donata de +% la uzanto, ni uzas \meta{defaŭlto} anstataŭe. +% Pli detale: kontrolas, ĉu la sekva signo +% estas '['. Se jes, iĝas \meta{ordono}, alikaze iĝas +% \meta{ordono}\arg[defaŭlto]. +% (Tio funkcias simile kiel '\@testopt' el la \LaTeX-kerno.) +% +% \TextUsage{\@expandable@ifopt}\marg{jes}\marg{ne} -- +% kontrolas, ĉu la sekva signo estas '['. Se jes, vokas \meta{jes}, alikaze +% \meta{ne}. +% +% \subsection{Limigoj} +% +% Fakte tiuj makrooj ne kontrolas la sekvan simbolon (kio igus ĝin +% ne-ekspandebla pro uzo de '\futurelet', kiel '\@testopt'), +% sed la sekvan makroo-argumenton ('#3', fakte). Krome estas malfacile +% kompari ion, se oni ne povas difini/ŝanĝi ion. +% +% Tio havas la sekvajn konsekvencojn: +% \begin{itemize} +% \item +% Ne eblas distingi '[' de '{[}' per nia algoritmo -- ambaŭ estas traktataj +% kiel \meta{Jes}. +% \item +% La sekva argumento estu de la amika speco: Ĝi estu (se ĝi ne estas +% simple '[') ĉeno el maksimume unu \emph{danĝera} simbolo (kontrolsekvenco +% aŭ el danĝera kategorio) kaj poste simpla teksto (el kategorioj 10, 11, +% 12). +% +% Se ĝi konsistas el nur unu simbolo, tio ne estas problemo. Se ĝi +% konsistas el simpla teksto, tio ankaŭ ne estas problemo. +% +% En aliaj kazoj povas aperi strangaj erarmesaĝoj. +% \item Apero de pluraj spaco-simboloj antaŭ la '[' povas konfuzigi la +% programon, tiam ankaŭ aperos strangaj erarmesaĝoj. +% \end{itemize} +% +% Do, antaŭ la uzo de tiuj makrooj bone pripensu, ĉu la limigoj vin +% ĝenas. +% +% (Krome eblas trompi nian algoritmon per kreado de pliaj makrooj en la +% nomspaco de '\exp-testopt@@'\meta{io}'@'. Ne faru tion, krom se vi certas +% pri la konsekvencoj.) +% +% +% \section{Ekzemplo} +% +% Jen ekzemplo de la uzo por krei komandon '\beispiel' kun opcia +% argumento. +% +% \changes{v0.3}{2009/03/05}{Testo ankaŭ por \cs{expnewcommand}} +% +%<*test> +\makeatletter +\errorcontextlines = 20 + +\def\beispiel{% + \@expandable@testopt\beispielImpl{Default}% +} +\def\beispielImpl[#1]{% + \fbox{#1}% +} +\makeatother + +\expnewcommand*{\ekzemplo}[1][Defa\u ulto]{% + \textbf{(#1)}% +} + +\expnewcommand*{\ekzemploDu}[2][defa\u ulto]{% + \ensuremath{\frac{\mbox{#1}}{\mbox{#2}}}% +} + + \beispiel{egal} \beispiel[bla] + \beispiel$ e=m c^2$ \beispiel[$ e=m c^2$] + + \ekzemplo\ekzemplo[Bla] + \expandafter\ekzemplo\space[bla] + \expandafter\expandafter\expandafter\ekzemplo\expandafter\space\space[dua bla] + \ekzemplo + [nova linio] + \ekzemplo + + [du novaj linioj] + \ekzemplo[blub] + + \ekzemploDu{testo} + \ekzemploDu[bla]{testo} + +% +% +% Kontraŭe al kreado de tia komando per '\newcommand', la komando estas +% tute ekspandebla (nu, krom la enhavo de '\beispielImpl'), anstataŭ +% robustigita per malfruigita ekspandado. Tiel ekzemple eblas uzi valorojn +% de variabloj kun ilia aktuala valoro, ankaŭ se la komando mem estos poste +% skribota en dosieron. (Hmm, iom komplika, ĉu?) +% +% La supra kodo donas jenan rezulton: +% +% \begin{center}\StraightEOL +% \fbox{\ +% \begin{minipage}{0.8\linewidth} \ +% \normalInput{\jobname.test} \ +% \end{minipage}\ +% } +% \end{center} +% +% \StopEventually{\PrintChanges\PrintIndex} +% +% \section{Implementado} +% +% +%<*package> + + +% +% \subsection{Ĉefaj makrooj} +% +% Niaj du ĉefaj makrooj nun aspektas tiom similaj, ke ni povas implementi +% 'testopt' per 'ifopt'. +% +\newcommand*{\@expandable@testopt}[2]{% + \@expandable@ifopt{#1}{#1[#2]}% +} + +% '\@expandable@ifopt' nun faras la laboron. +% +\newcommand{\@expandable@ifopt}[3]{% + \expandafter\ifx% '\ifx' komparas la difinojn de du makrooj, nome \dots + \csname exp-testopt@@\string#3@\endcsname% \dots makronomo kreita el la +% tria argumento (= la signo poste). + \exp@testopt@opt@% \dots kaj tiu antaŭdifinita makroo. + \afterfi{#1#3}% En la jes-kazo, vokas la unuan argumenton +% (kun la tria), \dots + \else% \dots en la ne-kazo la duan. +% +% Sed tiam ni ankoraŭ devos eltrovi, ĉu la tria konsistis el unu aŭ pluraj +% tokenoj, por meti '{...}' ĉirkaŭ ĝin en la dua kazo. (Se ĝi nur estas +% unu tokeno, meti '{...}' povas esti malhelpa, se ĝi fakte ne estas argumento +% al '#2', sed ekzemple io kiel '$', aŭ sekva makroo.) + \@expandable@ifOneToken#3\@expandable@ifOneToken% Tiu +% ĉi makroo provas eltrovi tion. + {\afterfi{#2#3}}% + {\afterfi{#2{#3}}}% + \fi% +}% + + +% La ideo por tia ekspandebla kontrolo de la sekva »signo« estas, ke ni +% kreas el la »signo« makroonomon, kaj komparas la signifon de ĝi kun +% signifo de konata makroo. +% +% \subsection{Komparendaj makrooj} +% +% Por tio ni kreas iujn nomojn, kiuj estas supozeble ne uzata de iu alia, +% kun signifoj, kiuj ankaŭ supozeble ne erare aperas. +% +\def\exp@testopt@opt@{<<<[>>>}% tio estas la nomo, kies valoron ni +% komparas kun aliaj kandidatoj. +\@namedef{exp-testopt@@\string[@}{<<<[>>>}% Tio -- '\exp-testopt@@[@' -- estas +% la makroo, kiu estos trovota en la \emph{jes}-kazo. + + +% Ni ankoraŭ devas eltrovi, ĉu la argumento estas +% nur unu tokeno aŭ pluraj, por povi meti '{...}' +% en la dua kazo. Ni uzas similan trukon por tio. +\long\def\@expandable@ifOneToken#1#2\@expandable@ifOneToken#3#4{% + \expandafter\ifx% + \csname exp-testopt@@\string#2@\endcsname% + \exp@testopt@empty@% + \afterfi{#3}% + \else + \afterfi{#4}% + \fi +} + +\def\exp@testopt@empty@{<<<>>>}% tio +% estas la nomo, kies valoron ni komparas kun aliaj kandidatoj. +\@namedef{exp-testopt@@@}{<<<>>>}% Tio -- +% '\exp-testopt@@@' -- estas la makroo, kiu estos trovota en la kazo, +% ke '#2' estas malplena. + + + +% \subsection{Komando-difinoj} +% +% \changes{v0.2}{2009/03/03}{Aldono de \cs{expnewcommand}.} +% +% Ni volas krei varianton de '\newcommand', kiu uzas +% nian ekspandeblan metodon por opciaj argumentoj, anstataŭ +% la robustan. +% +% Jen la originalo el latex.ltx (ltdefns.dtx, por esti +% preciza, CTAN-versio de 2006-05-21). +% \begin{kodo-citajho} +%<*latex2e> +% Handle the second optional argument. +\long\def\@xargdef#1[#2][#3]#4{% + \@ifdefinable#1{% +% Define the actual command to be:\\ +% |\def\foo{\@protected@testopt\foo\\foo{default}}|\\ +% where |\\foo| is a csname generated from applying |\csname| and +% |\string| to |\foo|, ie the actual name contains a backslash and +% therefore can't clash easily with exisiting command names. +% ``Default'' is the contents of the second optional argument of +% |(re)newcommand|. {\color{red} + \expandafter\def\expandafter#1\expandafter{% + \expandafter + \@protected@testopt + \expandafter + #1% + \csname\string#1\endcsname + {#3}}% +% } Now we define the internal macro ie |\\foo| which is supposed to +% pick up all arguments (optional and mandatory). + \expandafter\@yargdef + \csname\string#1\endcsname + \tw@ + {#2}% + {#4}}} +% +% \end{kodo-citajho} +% +% Kaj ni nun devas ŝanĝi la markitan parton +% por anstataŭe uzi nian metodon. Tio signifas, ke \meta{nomo} nun +% estas difinita kiel +% {\color{Green}'\@expandable@testopt\'\meta{nomo}\marg{defaŭlto}}, +% anstataŭ +% {\color{red}^^A +% '\@protected@testopt'\meta{nomo}'\'\meta{nomo}\marg{defaŭlto}}. +% +% (Kompreneble ni ne redifinas '\@xargdef', sed difinas nian +% propran varianton, por uzi anstataŭe -- ni ja ne volas ŝanĝi +% la bazan funkcion de '\newcommand'.) +\long\def\@exp@xargdef#1[#2][#3]#4{% + \@ifdefinable#1{% { \color{Green} + \expandafter\def\expandafter#1\expandafter{% + \expandafter% + \@expandable@testopt% + \csname\string#1\endcsname% + {#3}}% } + \expandafter\@yargdef% + \csname\string#1\endcsname% + \tw@% + {#2}% + {#4}% + }% +} + + +% Kaj nun kelkaj paralelaj difinoj al '\newcommand', '\new@command' kaj +% '\@newcommand'. +% +% \changes{v0.3}{2009/03/03}{Cim-korekto: \cs{exp@new@command} renomita al \cs{expnew@command}} +% +% '\expnewcommand' estas la ĉefa komando. +\def\expnewcommand{% + \@star@or@long\expnew@command% +} +\def\expnew@command#1{% + \@testopt{\exp@newcommand#1}0% +} +\def\exp@newcommand#1[#2]{% + \@ifnextchar [{\@exp@xargdef#1[#2]}% Ĉi +% tie ni vokas nian varianton anstataŭ '\@xargdef'. +% ^^A ] + {\@argdef#1[#2]}% Tiu estas la originalo. +} + +% +% \subsection{Helpaj makrooj} +% +% '\afterfi'\arg{kodo} -- saltas ĝis post la sekva '\fi', kaj +% ekzekutas \meta{kodo}n tie. +% +% Kopiita el \pk{gmutils}. +% +\@ifundefined{afterfi}{% + \def\afterfi#1#2\fi{% + \fi#1% + }% +}{}% + +% +% +% +% Jam fino :-) +\endinput +% +% (Jes, vere fino.) +% +% \Finale +%\endinput + + +%%% Folgendes ist nur für meinen Editor. +%%% +%%% Local Variables: +%%% mode: docTeX +%%% TeX-master: t +%%% End: diff --git a/Master/texmf-dist/source/latex/exp-testopt/exp-testopt.ins b/Master/texmf-dist/source/latex/exp-testopt/exp-testopt.ins new file mode 100644 index 00000000000..89e9f1d033a --- /dev/null +++ b/Master/texmf-dist/source/latex/exp-testopt/exp-testopt.ins @@ -0,0 +1,75 @@ +%% +%% (C) 2002-2008 Paul Ebermann - Installationsdatei zu exp-testopt.dtx +%% +%% Der vollständige Urheberrechtshinweis befindet sich +%% am Begin von exp-testopt.dtx. +%% +%% Ich gebe keine Garantie irgendeiner Art. +%% + +\input docstrip.tex + +%% +%% La test-dosiero, uzata por la dokumentaĵo (sed nenie alie). +\generate{ + \file{exp-testopt.test}{\from{exp-testopt.dtx}{test}} +} + +\usedir{tex/latex/paul} + +\Msg{**********************************************************} +\Msg{* Ich werde Dateien in \showdirectory{tex/latex/paul} } +\Msg{* installieren. Bitte stellen Sie sicher, } +\Msg{* dass dieses Verzeichnis vorhanden ist. } +\Msg{* } + +%% der folgende Text wird in jeder generierten +%% Datei am Anfang eingefügt. +\preamble + + ,--------------------------------------------------. + | Das ist eine generierte Datei. | + | | + | (c) 2009 Paul Ebermann. | + '--------------------------------------------------' +\endpreamble + + + + +\generate{ + \file{exp-testopt.sty}{\from{exp-testopt.dtx}{package}} +} + + + +%\generate{\file{exp-testopt.cls}{\from{exp-testopt.dtx}{class}}} + +\Msg{#######################} +\Msg{# } +\Msg{# Um die Installation zu beenden, } +\Msg{# müssen Sie die folgenden Dateien } +\Msg{# in Ihrem TeX-Suchbaum unterbringen: } +\Msg{# } +\Msg{# exp-testopt.sty } +%\Msg{# exp-testopt.cls } +\Msg{# } +\Msg{# Um eine Dokumentation zu erzeugen, } +\Msg{# benutzen Sie } +\Msg{# } +\Msg{# latex exp-testopt.dtx } +\Msg{# } +\Msg{# Viel Spaß } +\Msg{# Paul Ebermann } +\Msg{# } +\Msg{#######################} + +\endbatchfile + + +%%% Folgendes ist nur für meinen Editor. +%%% +%%% Local Variables: +%%% mode: latex +%%% TeX-master: t +%%% End: diff --git a/Master/texmf-dist/tex/latex/exp-testopt/exp-testopt.sty b/Master/texmf-dist/tex/latex/exp-testopt/exp-testopt.sty new file mode 100644 index 00000000000..9ab9750c8bb --- /dev/null +++ b/Master/texmf-dist/tex/latex/exp-testopt/exp-testopt.sty @@ -0,0 +1,101 @@ +%% +%% This is file `exp-testopt.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% exp-testopt.dtx (with options: `package') +%% +%% ,--------------------------------------------------. +%% | Das ist eine generierte Datei. | +%% | | +%% | (c) 2009 Paul Ebermann. | +%% '--------------------------------------------------' +%% (C) 2008 Paul Ebermann +%% +%% Package exp-testopt - expandible testopt-Variante. +%% +%% Die Datei exp-testopt.dtx sowie die dazugeh^^c3^^b6rige +%% exp-testopt.ins sowie die damit generierte +%% exp-testopt.sty stehen unter der +%% "LaTeX Project Public License" (LPPL, zu finden +%% unter http://www.latex-project.org/lppl/, sowie +%% auch in den meisten TeX-Distributionen in +%% texmf/docs/latex/base/lppl*.txt), Version 1.3b oder +%% sp^^c3^^a4ter (nach Wahl des Verwenders). +%% +%% Der 'maintenance-status' ist (zur Zeit) 'author-maintained'. +%% +%% Das hei^^c3^^9ft u.a., die Dateien d^^c3^^bcrfen frei vertrieben werden, +%% bei ^^c3^^84nderungen (durch andere Personen als Paul Ebermann) +%% ist aber der Name der Datei zu ^^c3^^a4ndern. +\NeedsTeXFormat{LaTeX2e}[2005/12/01]% +\ProvidesPackage{exp-testopt}[2009/03/06 v0.3 (PE)] + +\newcommand*{\@expandable@testopt}[2]{% + \@expandable@ifopt{#1}{#1[#2]}% +} + +\newcommand{\@expandable@ifopt}[3]{% + \expandafter\ifx% '\ifx' komparas la difinojn de du makrooj, nome \dots + \csname exp-testopt@@\string#3@\endcsname% \dots makronomo kreita el la + \exp@testopt@opt@% \dots kaj tiu anta^^c5^^addifinita makroo. + \afterfi{#1#3}% En la jes-kazo, vokas la unuan argumenton + \else% \dots en la ne-kazo la duan. + \@expandable@ifOneToken#3\@expandable@ifOneToken% Tiu + {\afterfi{#2#3}}% + {\afterfi{#2{#3}}}% + \fi% +}% + +\def\exp@testopt@opt@{<<<[>>>}% tio estas la nomo, kies valoron ni +\@namedef{exp-testopt@@\string[@}{<<<[>>>}% Tio -- '\exp-testopt@@[@' -- estas + +\long\def\@expandable@ifOneToken#1#2\@expandable@ifOneToken#3#4{% + \expandafter\ifx% + \csname exp-testopt@@\string#2@\endcsname% + \exp@testopt@empty@% + \afterfi{#3}% + \else + \afterfi{#4}% + \fi +} + +\def\exp@testopt@empty@{<<<>>>}% tio +\@namedef{exp-testopt@@@}{<<<>>>}% Tio -- + +\long\def\@exp@xargdef#1[#2][#3]#4{% + \@ifdefinable#1{% { \color{Green} + \expandafter\def\expandafter#1\expandafter{% + \expandafter% + \@expandable@testopt% + \csname\string#1\endcsname% + {#3}}% } + \expandafter\@yargdef% + \csname\string#1\endcsname% + \tw@% + {#2}% + {#4}% + }% +} + +\def\expnewcommand{% + \@star@or@long\expnew@command% +} +\def\expnew@command#1{% + \@testopt{\exp@newcommand#1}0% +} +\def\exp@newcommand#1[#2]{% + \@ifnextchar [{\@exp@xargdef#1[#2]}% ^^c4^^88i + {\@argdef#1[#2]}% Tiu estas la originalo. +} + +\@ifundefined{afterfi}{% + \def\afterfi#1#2\fi{% + \fi#1% + }% +}{}% + +\endinput +%% +%% End of file `exp-testopt.sty'. diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index e7407e62c2e..1ac21cb841c 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -90,7 +90,8 @@ my @WorkingTLP = qw( ESIEEcv esdiff esint esint-type1 eskd eskdx eso-pic esvect etaremune etex-pkg ethiop ethiop-t1 etoolbox euenc eukdate eulervm euproposal euro europecv eurosans everypage exam - examdesign examplep exercise expdlist expl3 expressg extarrows exteps + examdesign examplep exercise exp-testopt + expdlist expl3 expressg extarrows exteps extpfeil extract extsizes faktor fancybox fancyhdr fancynum fancyref fancytooltips fancyvrb FAQ-en fbs featpost diff --git a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc index d1641973b12..0dccc230b51 100644 --- a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc @@ -172,6 +172,7 @@ depend examdesign depend examplep depend exceltex depend exercise +depend exp-testopt depend expdlist depend export depend extract diff --git a/Master/tlpkg/tlpsrc/exp-testopt.tlpsrc b/Master/tlpkg/tlpsrc/exp-testopt.tlpsrc new file mode 100644 index 00000000000..7bada38dce0 --- /dev/null +++ b/Master/tlpkg/tlpsrc/exp-testopt.tlpsrc @@ -0,0 +1,2 @@ +name exp-testopt +category Package -- cgit v1.2.3