diff options
author | Karl Berry <karl@freefriends.org> | 2012-12-28 22:46:43 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-12-28 22:46:43 +0000 |
commit | aa3041c0939f2447fc48fd4c3ad830dfe75ef401 (patch) | |
tree | f72a6d6589b2d2763ad34d7755b94dc8878742d1 /Master | |
parent | 87e35eb4054f370617fc566daff3a5a6f527211a (diff) |
concepts (28dec12)
git-svn-id: svn://tug.org/texlive/trunk@28649 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/concepts/concepts.pdf | bin | 339208 -> 326899 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/concepts/concepts.tex | 369 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/concepts/concepts.sty | 275 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/concepts/dry.sty | 32 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/concepts/packagedoc.cls | 353 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/concepts/with.sty | 324 |
6 files changed, 863 insertions, 490 deletions
diff --git a/Master/texmf-dist/doc/latex/concepts/concepts.pdf b/Master/texmf-dist/doc/latex/concepts/concepts.pdf Binary files differindex b6c5c697e51..b4418f5522e 100644 --- a/Master/texmf-dist/doc/latex/concepts/concepts.pdf +++ b/Master/texmf-dist/doc/latex/concepts/concepts.pdf diff --git a/Master/texmf-dist/doc/latex/concepts/concepts.tex b/Master/texmf-dist/doc/latex/concepts/concepts.tex index d8582de46e8..7a26c65024c 100644 --- a/Master/texmf-dist/doc/latex/concepts/concepts.tex +++ b/Master/texmf-dist/doc/latex/concepts/concepts.tex @@ -20,61 +20,17 @@ % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% 'ltxdoc' to typeset the documentation -% -\documentclass[a4paper]{ltxdoc} - -%%% including the 'concepts' package itself -% -\usepackage{concepts}[2012/11/25] - -%%% including other packages we need -% -\usepackage{etextools} -\usepackage{etoolbox} -\usepackage{framed} -\usepackage{color} -\usepackage{marginnote} -\usepackage{listings} -\usepackage{lstautogobble} -\usepackage{textcomp} -\usepackage{ifthen} -\usepackage{atbegshi} -\usepackage{tikz} -\usepackage{amssymb} - -%%% including 'internal' package for setting and running -%%% code examples with a single source -% -\usepackage{dry} +\documentclass[a4paper]{packagedoc} -%%% skip any indentation directly after a code block or macro signature -% -\makeatletter - \newcommand*{\@noindentnext}{\everypar{{\setbox\z@\lastbox}\everypar{}}} - \AfterEndEnvironment{codeframe}{\@noindentnext} - \AfterEndEnvironment{uninterestingcodeframe}{\@noindentnext} - \apptocmd{\marg}{\@noindentnext}{}{} - \apptocmd{\oarg}{\@noindentnext}{}{} - \apptocmd{\parg}{\@noindentnext}{}{} - \pretocmd{\DescribeMacro}{\noindent\\}{}{} -\makeatother - -%%% documentation options -% -\EnableCrossrefs -\CodelineIndex -\RecordChanges +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Setup % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% title and author information -% -\GetFileInfo{concepts.sty} -\title{The \textsf{concepts} package\thanks{% - This document corresponds to \textsf{concepts}~\fileversion, dated \filedate. - Development of this package is organized at \texttt{http://latex-concepts.googlecode.com}. - I am happy to receive feedback.% -}} -\author{Michiel Helvensteijn \\ \texttt{mhelvens+latex@gmail.com}} +\moretexcs{% + NewConcept,ConceptOption,ConceptName,ConceptSymbol,% + ConceptSymbols,ConceptNameAndSymbols,delta,d,product,p,% + prd% +} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Changes % @@ -109,15 +65,17 @@ this information. But I don't want to manually keep track of all that. It's error-prone and it takes time. I'd rather focus on the theory. There are already techniques and packages that help lighten the load: +% \begin{itemize} - \item Rather than use any names or symbols directly in the text, declare - a macro for each one. If you ever need to change one, you'll only - have to do it in one place. You'll also be far less likely to - introduce any typos. - \item There are packages out there to keep track of and output a glossary% - \footnote{It is sometimes called a nomenclature. - The distinction is subtle.}. + \item Rather than use any names or symbols directly in the text, declare + a macro for each one. If you ever need to change one, you'll only + have to do it in one place. You'll also be far less likely to + introduce any typos. + \item There are packages out there to keep track of and output a glossary% + \footnote{It is sometimes called a nomenclature. + The distinction is subtle.}. \end{itemize} + But I'm not aware of any technique or package to ensure I'm not using a name or symbol inconsistently, thereby potentially confusing the reader. And even if there was, using all these techniques at the @@ -133,125 +91,20 @@ cannot generate a glossary yet. In future versions, it will interface with the \textsf{glossaries} package to accomplish this, and more. I'm also planning to implement a rudimentary typesystem, to catch even more -kinds of mistakes in symbol usage. There will also be additional ways of -typesetting concept-related stuff, such as useful sentence fragments. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Usage Prep % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%% formatting the code blocks -% -\setlength{\FrameSep}{0pt} -\setlength{\MacroIndent}{16pt} -\setlength{\MacrocodeTopsep}{2pt} -\newenvironment{codeframe}{% - \definecolor{shadecolor}{rgb}{.9,.9,.9}% - \begin{framed}% - \begin{shaded}% -}{% - \end{shaded}\vspace{-2.8mm}% - \end{framed}% -} - -%%% meta-optional arguments (that means: without explicit []) -% -\makeatletter - \newcommand*{\movarg}[1]{[ \verb|#1| ]\@noindentnext} - \newcommand*{\momarg}[1]{[ \meta{#1} ]\@noindentnext} -\makeatother - -%%% listings language for examples -% -\lstdefinelanguage{latex}{ - language=[LaTeX]tex, - moretexcs={detokenize, - NewConcept,ConceptOption,ConceptName,ConceptSymbol, - ConceptSymbols,ConceptNameAndSymbols, - delta,product,p,d,prd} -} - -\makeatletter - -%%% adding a border around content without putting it in a TeX group (scope) -% -\newcounter{boxcount}[page] -\newcommand{\boxstart}{% - \stepcounter{boxcount}% - \raisebox{1.6ex}{\ensuremath{\vcenter{\hbox{% - \tikz[remember picture, overlay]{\coordinate (start box \arabic{boxcount});}% - }}}}% -} -\newcommand{\boxend}{% - \raisebox{-1.6ex}{\ensuremath{\vcenter{\hbox{% - \tikz[remember picture, overlay]{\coordinate (end box \arabic{boxcount});}% - }}}}% -} -\AtBeginShipout{\AtBeginShipoutUpperLeft{% - \ifthenelse{\value{boxcount} > 0}{% - \tikz[remember picture,overlay]{% - \foreach \boxmarker in {1,...,\arabic{boxcount}}% - \draw[black]% - (start box \boxmarker) +(.07mm,0mm) rectangle% - (end box \boxmarker);% - }% - }{}% -}} - -%%% TeX example environments -% -\newlength{\texexamplespace} -\setlength{\texexamplespace}{1.2mm} -\NewDRYer{latex-example-show}{}{% - \addvspace{\texexamplespace}% - \noindent\begin{minipage}{\textwidth} - \begin{codeframe}% - \renewcommand{\ttdefault}{pcr}% - \vspace{-1mm}% - \lstinputlisting[% - language=latex,basicstyle=\ttfamily\small,% - texcsstyle=*\bfseries,% - upquote=true,% - tabsize=1% - ]{\DRYFilename}% - \vspace{-1mm}% - \end{codeframe}% - \end{minipage}\\[-.45mm] - \boxstart$\ $\DRYContent$\ $\boxend% - \@noindentnext\par\addvspace{\texexamplespace}% -} -\NewDRYer{latex-example}{}{% - \addvspace{\texexamplespace}% - \noindent\begin{minipage}{\textwidth} - \begin{codeframe}% - \renewcommand{\ttdefault}{pcr}% - \vspace{-1mm}% - \lstinputlisting[% - language=latex,basicstyle=\ttfamily\small,% - texcsstyle=*\bfseries,% - upquote=true,% - tabsize=1% - ]{\DRYFilename}% - \vspace{-1mm}% - \end{codeframe}% - \end{minipage}% - \DRYContent% - \@noindentnext\par\addvspace{\texexamplespace}% -} - -\makeatother +kinds of mistakes in symbol usage. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Usage} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -In short: every concept first has to be declared using the |\NewConcept| macro. +Every concept first has to be declared using the |\NewConcept| macro. Afterwards, its name and associated symbols can by typeset using other macros. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\DescribeMacro{\NewConcept} - \marg{concept key} \oarg{options}\\ +\describemacro{\NewConcept}{ + \marg{concept key} \oarg{options} +} Every concept needs a unique \meta{concept key}, by which it will be identified for the rest of the document. This key can also be used to automatically @@ -280,30 +133,28 @@ options. Note that the option names are case-sensitive: of this concept, delimited by curly brackets\\ --- default: |{}| (the empty list) \item[symbolcmd] the `short' command that may be used to typeset a - specific symbol of this concept, given a numeric index + specific symbol \end{description} -\noindent Here are a few examples which will also be used to illustrate the other commands: +Here are a few examples which will also be used to illustrate the other commands: \begin{latex-example} - \NewConcept{swproduct}[ - name = software product, % options 'plural', 'Plural' - Name = Software Product, % are implicitly defined - namecmd = \product, % defines \product - symbols = {p}, % p represents a product - symbolcmd = \p % defines \p - ] +\NewConcept{swproduct}[ + name = software product, % options 'plural', 'Plural' + Name = Software Product, % are implicitly defined + namecmd = \product, % defines \product + symbols = {p}, % p represents a product + symbolcmd = \p % defines \p +] \end{latex-example} - +% \begin{latex-example} - \let\delta\relax % I won't be using the greek letter - \let\d\relax % or the 'dot under a letter' macro - - \NewConcept{delta}[ - namecmd, % defines \delta - symbols = {x, y, z}, % x, y and z represent deltas - symbolcmd = \d % defines \d - ] +\let\delta\relax \let\d\relax % I won't be using these +\NewConcept{delta}[ + namecmd, % defines \delta + symbols = {x, y, z}, % x, y and z represent deltas + symbolcmd = \d % defines \d +] \end{latex-example} There are certain restrictions on new concept declarations. You may @@ -316,20 +167,21 @@ properly in an expansion-only context, e.g. be robust. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\DescribeMacro{\ConceptOption} - \marg{concept key} \marg{option key}\\\nopagebreak +\describemacro{\ConceptOption}{ + \marg{concept key} \marg{option key} +} This command can be used to get back any option value given a specific \meta{concept~key} and \meta{option key}. For example: \begin{latex-example-show} - \ConceptOption{delta}{Plural} +\ConceptOption{delta}{Plural} \end{latex-example-show} - +% \begin{latex-example-show} - \edef\prd{\ConceptOption{swproduct}{namecmd}}% - {\ttfamily\expandafter\detokenize\expandafter{\prd}}% - expands to ``\prd''. +\edef\prd{\ConceptOption{swproduct}{namecmd}}% +{\ttfamily\expandafter\detokenize\expandafter{\prd}}% + expands to ``\prd''. \end{latex-example-show} |\ConceptOption| is `fully expandable', meaning that it can expand at @@ -343,8 +195,9 @@ no further. After that you can expand it further if you wish. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\DescribeMacro{\ConceptName} - \movarg{\textasciicircum} \movarg{*} \marg{concept key}\\\nopagebreak +\describemacro{\ConceptName}{ + \movarg{\textasciicircum} \movarg{*} \marg{concept key} +} With this command you can typeset the name of the concept with \meta{concept key} in any of four forms. The |^| modifier gives you the capitalized version. The |*| @@ -352,25 +205,27 @@ modifier gives you the plural version. The combination gives you both. The order between |^| and |*| doesn't matter. \begin{latex-example-show} - \ConceptName^*{delta} can transform a \ConceptName{swproduct}. +\ConceptName^*{delta} can transform a \ConceptName{swproduct}. \end{latex-example-show} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\noindent\\\marginnote{\meta{namecmd}} - \movarg{\textasciicircum} \movarg{*}\\\nopagebreak +\describemetamacro{namecmd}{ + \movarg{\textasciicircum} \movarg{*} +} This is the `short' version of |\ConceptName|, specific for each concept that was declared with the |namecmd| option. It supports the same modifiers. \begin{latex-example-show} - \delta^* can easily transform a \product. +\delta^* can easily transform a \product. \end{latex-example-show} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\DescribeMacro{\ConceptSymbol} - \marg{concept key} \oarg{symbol index}\\\nopagebreak +\describemacro{\ConceptSymbol}{ + \marg{concept key} \oarg{symbol index} +} This command typesets a specific symbol associated with a a given concept. It is always typeset in math mode. Specify the concept with the \meta{concept key} @@ -381,18 +236,19 @@ concept options. If a concept has only one allocated symbol the index may be omitted. If there is more than one symbol, the index is mandatory. \begin{latex-example-show} - \product^* have symbols like \ConceptSymbol{swproduct}. +\product^* have symbols like \ConceptSymbol{swproduct}. \end{latex-example-show} - +% \begin{latex-example-show} - $\ConceptSymbol{delta}[2] \cdot \ConceptSymbol{delta}[1] = - \ConceptSymbol{delta}[1] \cdot \ConceptSymbol{delta}[2]$ +$\ConceptSymbol{delta}[2] \cdot \ConceptSymbol{delta}[1] = + \ConceptSymbol{delta}[1] \cdot \ConceptSymbol{delta}[2]$ \end{latex-example-show} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\noindent\\\marginnote{\meta{symbolcmd}} - \momarg{symbol index}\\\nopagebreak +\describemetamacro{symbolcmd}{ + \momarg{symbol index} +} This is the `short' version of |\ConceptSymbol|, specific for each concept that was declared with the |symbolcmd| option. The optional index is given directly @@ -401,17 +257,18 @@ allowed to use square brackets. See the list-variation of this short command below. \begin{latex-example-show} - $(\d2 \cdot \d1)(\p) = \d2(\d1(\p)) = \d2(\p') = \p''$ +$(\d2 \cdot \d1)(\p) = \d2(\d1(\p)) = \d2(\p') = \p''$ \end{latex-example-show} -\noindent As you can see, this short construct requires a lot less space than the +As you can see, this short construct requires a lot less space than the full |\ConceptSymbol| command, so its use is recommended for readability. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\DescribeMacro{\ConceptSymbols} +\describemacro{\ConceptSymbols}{ \marg{concept key} \oarg{separator} - \oarg{last separator} \marg{symbol indices}\\\nopagebreak + \oarg{last separator} \marg{symbol indices} +} This command typesets a \meta{separator} separated list of symbols associated with the given concept, optionally with a different \meta{last separator}. Specify @@ -424,19 +281,19 @@ The indices are 1-based and point to a place in the symbol list provided with th concept options. The index-list is mandatory, but can be empty. \begin{latex-example-show} - The symbols \ConceptSymbols{delta}{1,2,3} represent \delta*. +The symbols \ConceptSymbols{delta}{1,2,3} represent \delta*. \end{latex-example-show} - +% \begin{latex-example-show} - $\{\ConceptSymbols{delta}[;]{1,1,1}\}$ contains only \d1. +$\{\ConceptSymbols{delta}[;]{1,1,1}\}$ contains only \d1. \end{latex-example-show} - +% \begin{latex-example-show} - What about \ConceptSymbols{delta}[,][$ and $]{3, 2, 1}? +What about \ConceptSymbols{delta}[,][$ and $]{3, 2, 1}? \end{latex-example-show} - +% \begin{latex-example-show} - xx\ConceptSymbols{delta}{}xx +xx\ConceptSymbols{delta}{}xx \end{latex-example-show} If you need any symbol in the resulting list to have some decoration (like a @@ -446,34 +303,36 @@ accordingly. This currently only works for decorations that would be specified start with the index itself: \begin{latex-example-show} - \ldots such as the symbols in - $(\ConceptSymbols{delta}{1_1, 2'', 3^{\d1(\p)}})$. +\ldots such as the symbols in + $(\ConceptSymbols{delta}{1_1, 2'', 3^{\d1(\p)}})$. \end{latex-example-show} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\noindent\\\marginnote{\meta{symbolcmd}} - \oarg{symbol indices}\\\nopagebreak +\describemetamacro{symbolcmd}{ + \oarg{symbol indices} +} This is the `short' version of |\ConceptSymbols|, specific for each concept that was declared with the |symbolcmd| option. The \meta{symbol indices} list needs to be delimited by square brackets as shown below. \begin{latex-example-show} - $\forall \d[1,2] \in D:\ \d1 \| \d2\ \Rightarrow\ {} - \exists \d[3'] \in D:\ \d1 \prec \d3' \land \d2 \prec \d3'$ +$\forall \d[1,2] \in D:\ \d1 \| \d2\ \Rightarrow\ {} + \exists \d[3'] \in D:\ \d1 \prec \d3' \land \d2 \prec \d3'$ \end{latex-example-show} - +% \begin{latex-example-show} - xx\d[]xx\p[]xx +xx\d[]xx\p[]xx \end{latex-example-show} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\DescribeMacro{\ConceptNameAndSymbols} +\describemacro{\ConceptNameAndSymbols}{ \movarg{\textasciicircum} \marg{concept key} \oarg{separator} \oarg{last separator} - \marg{symbol indices}\\\nopagebreak + \marg{symbol indices} +} This command is the `hybrid' version of |\ConceptName| and |\ConceptSymbols|. It typesets the name of the concept followed by a \meta{separator} separated list @@ -490,15 +349,16 @@ You can still supply the |^| modifier to capitalize the name but the choice between singular and plural form is determined by the number of \meta{symbol indices}. \begin{latex-example-show} - We use \ConceptNameAndSymbols{delta}[,][$ and also $]{1,2,3}. +We use \ConceptNameAndSymbols{delta}[,][$ and also $]{1,2,3}. \end{latex-example-show} For some other neat tricks, read the documentation of |\ConceptSymbols| above. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\noindent\\\marginnote{\meta{namecmd}} - \movarg{\textasciicircum} \oarg{symbol indices}\\\nopagebreak +\describemetamacro{namecmd}{ + \movarg{\textasciicircum} \oarg{symbol indices} +} This is a `short' version of |\ConceptNameAndSymbols|, specific for each concept that was declared with the |namecmd| option. @@ -507,7 +367,7 @@ as shown below. The list is comma-delimited and the last (or only) delimiter is the word `and'. \begin{latex-example-show} - \delta^[1,2] come before \delta[3]. +\delta^[1,2] come before \delta[3]. \end{latex-example-show} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -529,7 +389,6 @@ amount of features we can take advantage of. Secondly, I will program the Here is an incomplete list of the features I am planning to implement: \begin{itemize} \item full integration with the \textsf{glossaries} package - \item commands to \emph{modify} existing concepts \item typesetting a \emph{summary} of the concepts introduced in each chapter / section \item management of \emph{tuples} and \emph{sets} of concept instances \item management of \emph{subconcepts} plus a rudimentary \emph{typesystem} that @@ -537,45 +396,5 @@ Here is an incomplete list of the features I am planning to implement: \end{itemize} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Implementation Prep % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\makeatletter -\renewenvironment{codeframe}{% - \definecolor{shadecolor}{rgb}{.9,.9,.9}% - \begin{shaded}% -}{% - \end{shaded}% -} - -\newenvironment{uninterestingcodeframe}{% - \vspace{-5mm}% - \definecolor{shadecolor}{rgb}{.97,.97,.97}% - \begin{shaded}% - \definecolor{uninterestingcodecolor}{rgb}{.4,.4,.4}% - \let\old@macro@font\macro@font% - \def\macro@font{\color{uninterestingcodecolor}\old@macro@font}% -}{% - \end{shaded}% -} -\makeatother - -\StopEventually{ - \PrintChanges -} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{Implementation} % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -We now show and explain the entire implementation in |concepts.sty|. - -\DocInput{concepts.sty} - -\Finale - -\PrintIndex - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \end{document} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/Master/texmf-dist/tex/latex/concepts/concepts.sty b/Master/texmf-dist/tex/latex/concepts/concepts.sty index 95e1c606d75..7cb1e4a07e1 100644 --- a/Master/texmf-dist/tex/latex/concepts/concepts.sty +++ b/Master/texmf-dist/tex/latex/concepts/concepts.sty @@ -19,7 +19,7 @@ % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \fi %%%% -% \CheckSum{0} +% \CheckSum{265} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -45,11 +45,11 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{concepts}[2012/12/18 0.0.5 +\ProvidesPackage{concepts}[2012/12/25 0.0.5-r1 managing names and symbols of document specific formal concepts] -% \end{macrocode}\end{codeframe} +% \end{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -65,14 +65,14 @@ % % These are the packages we'll need. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \RequirePackage{etextools} \RequirePackage{nth} \RequirePackage{xspace} \RequirePackage{xparse} % 1 \RequirePackage{ltxkeys}[2012/11/17] % 2 \RequirePackage{xstring} -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % We need a very recent version of |ltxkeys| in order to % properly handle list-values. Note that |xparse| needs @@ -90,7 +90,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \begin{macro}{\cnc@d} \marg{identifier} -%%% \begin{macro}{\cnc@g} \marg{identifier}\\\nopagebreak +%%% \begin{macro}{\cnc@g} \marg{identifier}\\\nopagebreak\noindentnext % % This package needs to store and retrieve a lot of data. To make % the rest of the code more readable, we define the following commands. @@ -100,10 +100,10 @@ % to a specific piece of data in |\csname| context. % We can get access to the data itself by using |\cnc@g|. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \newcommand*{\cnc@d}[1]{cnc@data@#1} \newcommand*{\cnc@g}[1]{\csuse{\cnc@d{#1}}} -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % Both take an identifier of one the following shapes: % \begin{itemize} @@ -126,15 +126,15 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% \begin{macro}{\cnc@upper} \marg{string}\\\nopagebreak +%%% \begin{macro}{\cnc@upper} \marg{string}\\\nopagebreak\noindentnext % % We're going to need a command that capitalizes the first % letter of a string which fully expands its argument. So % here it is. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \newcommand*{\cnc@upper}[1]{\ExpandAftercmds\MakeUppercase{#1}} -% \end{macrocode}\end{codeframe} +% \end{macrocode} % %\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -142,7 +142,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \begin{macro}{\cnc@grabnumber} \marg{token sequence containing \#1} -%%% \momarg{number}\\\nopagebreak +%%% \momarg{number}\\\nopagebreak\noindentnext % % This is a command we're going to use for the automatically % defined short symbol macros later. It has one 'real' @@ -151,13 +151,13 @@ % substituted for all occurrences of \#1 in the mandatory % argument which is then `returned'. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \newcommand{\cnc@grabnumber}[1]{% \def\cnc@dowithnum##1{#1}% \futuredef[0123456789]{\cnc@@n}% {\expandafter\cnc@dowithnum\expandafter{\cnc@@n}}% } -% \end{macrocode}\end{codeframe} +% \end{macrocode} % %\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -165,20 +165,20 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \begin{macro}{\cnc@csvlistsize} \marg{csvlist} -%%% \marg{command sequence}\\\nopagebreak +%%% \marg{command sequence}\\\nopagebreak\noindentnext % % This macro takes a comma-separated list of\ldots anything, % and stores its size in the given macro as a simple decimal % string. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \newcounter{cnc@listsize} \newrobustcmd{\cnc@csvlistsize}[2]{% \setcounter{cnc@listsize}{0}% \def\do##1{\stepcounter{cnc@listsize}}\docsvlist{#1}% \edef#2{\arabic{cnc@listsize}}% } -% \end{macrocode}\end{codeframe} +% \end{macrocode} % %\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -192,7 +192,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \begin{macro}{\cnc@conceptname} \marg{plural} \marg{capitalized} -%%% \marg{plural} \marg{concept key}\\\nopagebreak +%%% \marg{plural} \marg{concept key}\\\nopagebreak\noindentnext % % This typesets the name of a specific concept in one of four forms. It % can be capitalized or not; and it can be singular or plural. We define @@ -204,25 +204,25 @@ % the |*| and |^| modifiers and we want to have a simple one-to-one % mapping between their arguments and the arguments of this private macro. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \newcommand{\cnc@conceptname}[4]{% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % We test if \emph{both} the first and third arguments are true, meaning % that the public command has two |*| modifiers. If it does, we give a % package error. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \ifboolexpr{ test{\IfBooleanTF{#1}} and test{\IfBooleanTF{#3}} }{% \PackageError{concepts}% {You used the * modifier twice; once is enough}% {I will pretend you just used one *.}% }{}% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % And then we simply typeset the correct value from our datastore. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \ifboolexpr{ test{\IfBooleanTF{#1}} or test{\IfBooleanTF{#3}} }{% \IfBooleanTF{#2}% {\cnc@g{concept(#4).option(Plural)}}% @@ -232,16 +232,21 @@ {\cnc@g{concept(#4).option(Name)}}% {\cnc@g{concept(#4).option(name)}}% }% -% \end{macrocode}\end{codeframe} -% +% \end{macrocode} +% % We end with an |\xspace| because the public command may need one. +% And first we cancel out any extra spacing (for example, +% when one concept name ends with another). +% +% \changes{0.0.5-r1}{2012/12/25} +% {fixed spacing for when one concept name ends with another} % -% \begin{codeframe}\begin{macrocode} - \xspace% -% \end{macrocode}\end{codeframe} -% \begin{uninterestingcodeframe}\begin{macrocode} +% \begin{macrocode} + \unskip\xspace% +% \end{macrocode} +% \uninteresting\begin{macrocode} } -% \end{macrocode}\end{uninterestingcodeframe} +% \end{macrocode} % %\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -249,7 +254,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \begin{macro}{\cnc@conceptsymbol} \marg{concept key} -%%% \marg{index}\\\nopagebreak +%%% \marg{index}\\\nopagebreak\noindentnext % % This is the private macro which takes a concept key and an index and returns % the corresponding symbol from our data-store. We use it in the public macros @@ -259,31 +264,31 @@ % consists of numerals. The rest of the argument is simply left in % the input stream afterwards. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \newcommand*{\cnc@conceptsymbol}[2]{% \cnc@grabnumber{% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % We check if an actual numerical value was passed. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \ifstrempty{##1}{% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % No, we didn't get a numerical index. If there is only one symbol % allocated to this concept, we don't care and return that symbol. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \edef\cnc@symbolcount{\cnc@g{concept(#1).option(symbols).count}}% \ifnumcomp{\cnc@symbolcount}{=}{1}{% \ensuremath{\cnc@g{concept(#1).option(symbols).index(1)}}% }% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % If there are multiple symbols, the lack of an index is ambiguous and % we report a package error. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} {% \PackageError{concepts}% {You didn't specify a number, but the '#1' @@ -292,29 +297,29 @@ to typeset a specific symbol}% {I will pretend you didn't ask for a symbol here.}% }% -% \end{macrocode}\end{codeframe} -% \begin{uninterestingcodeframe}\begin{macrocode} +% \end{macrocode} +% \uninteresting\begin{macrocode} }% -% \end{macrocode}\end{uninterestingcodeframe} +% \end{macrocode} % % Now follows the `else' branch: we did get a numerical index! % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} {% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % We check whether it is larger than the number of symbols % allocated to the concept. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \edef\cnc@symbolcount{\cnc@g{concept(#1).option(symbols).count}}% \ifnumcomp{##1}{>}{\cnc@symbolcount}{% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % If it is, we report an `index out of bounds' error. We first prepare an % appropriate sentence fragment so the error message becomes more readable. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \edef\cnc@nth{##1\nthSuff0##1\delimiter}% \ExpandNext\IfStrEq{\cnc@symbolcount}{0}{% \edef\cnc@somany{no symbols}% @@ -328,33 +333,33 @@ but\MessageBreak the '#1' concept has \cnc@somany\space allocated}% {I will pretend you didn't ask for a symbol here.}% -% \end{macrocode}\end{codeframe} -% \begin{uninterestingcodeframe}\begin{macrocode} +% \end{macrocode} +% \uninteresting\begin{macrocode} }% -% \end{macrocode}\end{uninterestingcodeframe} +% \end{macrocode} % % But if the number is within bounds, great! We just return the stored symbol. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} {% \ensuremath{\cnc@g{concept(#1).option(symbols).index(##1)}}% }% -% \end{macrocode}\end{codeframe} -% \begin{uninterestingcodeframe}\begin{macrocode} +% \end{macrocode} +% \uninteresting\begin{macrocode} }% -% \end{macrocode}\end{uninterestingcodeframe} +% \end{macrocode} % % Now ends our |\cnc@grabnumber| command, and we supply the second argument % that may contain the numbers. Just in case it's empty, we make sure we % don't grab anything that comes after the second argument by adding a % |\relax|. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} }#2\relax% -% \end{macrocode}\end{codeframe} -% \begin{uninterestingcodeframe}\begin{macrocode} +% \end{macrocode} +% \uninteresting\begin{macrocode} } -% \end{macrocode}\end{uninterestingcodeframe} +% \end{macrocode} % %\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -364,7 +369,7 @@ % \begin{macro}{\cnc@conceptsymbols} \marg{concept key} % \marg{separator} % \marg{last separator} -%%% \oarg{indices}\\\nopagebreak +%%% \oarg{indices}\\\nopagebreak\noindentnext % % This is the private macro which takes a concept key and a % comma-separated list of symbol-indices and returns a @@ -374,11 +379,11 @@ % functionality. The last argument is optional to make it % easier to define our `short' symbol-list command later. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \newcounter{cnc@separatorcount}% \NewDocumentCommand{\cnc@conceptsymbols}{m m m O{1}}{% \def\cnc@result{}% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % We loop through the list of indices and produce the % symbols one-by-one. We use a rather ugly trick to @@ -389,7 +394,7 @@ % the document, but we don't care, since most of this % will be rewritten when we switch to \LaTeX3. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \def\do##1{% \stepcounter{cnc@separatorcount}% \edef\cnc@sepcsname{cnc@separator\arabic{cnc@separatorcount}}% @@ -403,10 +408,10 @@ \edef\cnc@sepcsname{cnc@separator\arabic{cnc@separatorcount}}% \csdef{\cnc@sepcsname}{#3}% \ensuremath{\expandafter\@gobble\cnc@result{}}% -% \end{macrocode}\end{codeframe} -% \begin{uninterestingcodeframe}\begin{macrocode} +% \end{macrocode} +% \uninteresting\begin{macrocode} } -% \end{macrocode}\end{uninterestingcodeframe} +% \end{macrocode} % %\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -419,7 +424,7 @@ % \marg{star}\\\nopagebreak % \marg{separator} % \marg{last separator} -%%% \marg{indices}\\\nopagebreak +%%% \marg{indices}\\\nopagebreak\noindentnext % % This is the private macro which takes a concept key, a few % modifiers, a comma-separated list of symbol-indices and @@ -427,42 +432,42 @@ % concept symbols from our data-store. We use it in the public % macros that offer this functionality. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \newrobustcmd{\cnc@nameandsymbols}[7]{% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % We first check if any |*| modifiers were given and, if so, % generate an error. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \ifboolexpr{ test{\IfBooleanTF{#2}} or test{\IfBooleanTF{#4}} }{% \PackageError{concepts}% {You used the * modifier, but pluralization\MessageBreak will be decided by the size of the index list}% {I will pretend you didn't use the * modifier.}% }{}% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % We then typeset the name of the concept. We check pluralization % and pass along the capitalization. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \cnc@csvlistsize{#7}{\cnc@symbollistsize}% \ifnumcomp{\cnc@symbollistsize}{=}{1}{% \cnc@conceptname{\BooleanFalse}{#3}{\BooleanFalse}{#1}% }{% \cnc@conceptname{\BooleanTrue}{#3}{\BooleanFalse}{#1}% } % <-- intentional space -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % Finally, we print the symbol list. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \cnc@conceptsymbols{#1}{#5}{#6}[#7]% -% \end{macrocode}\end{codeframe} -% \begin{uninterestingcodeframe}\begin{macrocode} +% \end{macrocode} +% \uninteresting\begin{macrocode} } -% \end{macrocode}\end{uninterestingcodeframe} +% \end{macrocode} % %\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -478,43 +483,43 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% \begin{macro}{\NewConcept} \marg{concept key} \oarg{options}\\\nopagebreak +%%% \begin{macro}{\NewConcept} \marg{concept key} \oarg{options}\\\nopagebreak\noindentnext % % The |\NewConcept| macro is defined using |xparse|, since we want the % optional argument after the mandatory one (it's just nicer). % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \NewDocumentCommand{\NewConcept}{m O{}}{% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % Is this concept key already defined? If so, we report a package error. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \xifinlist{#1}{\cnc@g{concepts}}{% \PackageError{concepts}% {The concept key '#1' is already taken}% {I will pretend that this '\protect\newconcept'% didn't happen.}% }% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % Otherwise, we start the actual processing of this new concept. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} {% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % We add the concept to the concepts list in our datastore. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \listcsxadd{\cnc@d{concepts}}{#1}% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % We then check which options were explicitly specified by the user. % This results in a set of toggles in our datastore, which may % be used by other code. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \DeclareRobustCommand*{\cnc@registertoggle}[1]{% \newtoggle{\cnc@d{concept(#1).option(##1).given}}% \togglefalse{\cnc@d{concept(#1).option(##1).given}}% @@ -529,12 +534,12 @@ \cnc@registertoggle{symbols}% \cnc@registertoggle{symbolcmd}% \ltxkeys@setkeys*[cnc@toggle]{#1}{#2}% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % We now register the concept name options |name|, |Name|, % |plural| and |Plural|. This is also where we set their default values. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \ltxkeys@newordkey[cnc]{#1}{name}% [#1]% {\csdef{\cnc@d{concept(#1).option(name)}}{##1}}% @@ -542,12 +547,12 @@ [\cnc@upper{\cnc@g{concept(#1).option(name)}}]% {\csdef{\cnc@d{concept(#1).option(Name)}}{##1}}% \ltxkeys@newordkey[cnc]{#1}{plural}% - [\cnc@g{concept(#1).option(name)}s]% + [\cnc@g{concept(#1).option(name)}\unskip s]% {\csdef{\cnc@d{concept(#1).option(plural)}}{##1}}% \ltxkeys@newordkey[cnc]{#1}{Plural}% [\cnc@upper{\cnc@g{concept(#1).option(plural)}}]% {\csdef{\cnc@d{concept(#1).option(Plural)}}{##1}}% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % We next register the |namecmd| option. Its default value is the % concept key with a |\| in front of it. Unlike most other options, @@ -555,27 +560,27 @@ % user to actually define the macro. The following code also % contains the test. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \expandaftercmds{\ltxkeys@newordkey[cnc]{#1}{namecmd}% [}{\csname#1\endcsname}]{% \iftoggle{\cnc@d{concept(#1).option(namecmd).given}}{% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % We register the option value as given. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \csdef{\cnc@d{concept(#1).option(namecmd)}}{\noexpand##1} -% \end{macrocode}\end{codeframe} +% \end{macrocode} % %%% \vphantom{x}\marginnote{\meta{namecmd}} \movarg{*} \movarg{\textasciicircum} % \movarg{*} -% \oarg{indices}\\\nopagebreak +% \oarg{indices}\\\nopagebreak\noindentnext % % \noindent If the option is processed, we define the concept-specific % name command. We distinguish between two cases: whether an index-list % was provided or not. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \NewDocumentCommand{##1}{t* t^ t* +o}{% \IfValueTF{####4}{% \cnc@nameandsymbols{#1}{####1}{####2}{####3}% @@ -584,21 +589,21 @@ \cnc@conceptname{####1}{####2}{####3}{#1}% }% }% -% \end{macrocode}\end{codeframe} -% \begin{uninterestingcodeframe}\begin{macrocode} +% \end{macrocode} +% \uninteresting\begin{macrocode} }{}% }% -% \end{macrocode}\end{uninterestingcodeframe} +% \end{macrocode} % % We now register the |symbols| option. This option expects a list. % The callback of the following code processes it one symbol at a time. % And we first initialize the symbol counter to 0 in case the list is % empty % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \csdef{\cnc@d{concept(#1).option(symbols).count}}{0}% \ltxkeys@newlistkey[cnc]{#1}{symbols}[]{% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % We check if this particular symbol is already defined. We don't want % a symbol allocated to different concepts. Or allocated twice to the @@ -606,7 +611,7 @@ % counter for this concept, we add the symbol itself and we update % the reverse map we use for checking duplicates. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \ifcsundef{\cnc@d{symbol(\detokenize{##1}).concept}}{% \csedef{\cnc@d{concept(#1)% .option(symbols)% @@ -616,11 +621,11 @@ .index(\ltxkeys@listcount)}}{##1}% \csedef{\cnc@d{symbol(\detokenize{##1}).concept}}{#1}% }% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % If the symbol is already in use we report a package error. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} {% \PackageError{concepts}% {The symbol '\detokenize{##1}' is already allocated @@ -629,26 +634,26 @@ {I will pretend that you did not try to add this symbol.}% }% -% \end{macrocode}\end{codeframe} -% \begin{uninterestingcodeframe}\begin{macrocode} +% \end{macrocode} +% \uninteresting\begin{macrocode} }% -% \end{macrocode}\end{uninterestingcodeframe} +% \end{macrocode} % % We register the |symbolcmd| option. It does not really have a default, % but we give an empty default so we can test for the empty string inside. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \ltxkeys@newordkey[cnc]{#1}{symbolcmd}[]{% \ifblank{##1}{}{% -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % We register the option value as given. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \csdef{\cnc@d{concept(#1).option(symbolcmd)}}{\noexpand##1} -% \end{macrocode}\end{codeframe} +% \end{macrocode} % -%%% \vphantom{x}\marginnote{\meta{symbolcmd}} \momarg{index}\\\nopagebreak +%%% \vphantom{x}\marginnote{\meta{symbolcmd}} \momarg{index}\\\nopagebreak\noindentnext % % \noindent If the option is processed, we now define the concept-specific % `short' command used to typeset one or more of the allocated symbols. It @@ -657,7 +662,7 @@ % we pass control to the |\cnc@conceptsymbols| command, which is still able % to grab a square bracket delimited list of indices. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \newrobustcmd*{##1}{% \cnc@grabnumber{% \IfInteger{########1}{% @@ -667,21 +672,21 @@ }% }% }% -% \end{macrocode}\end{codeframe} -% \begin{uninterestingcodeframe}\begin{macrocode} +% \end{macrocode} +% \uninteresting\begin{macrocode} }% }% -% \end{macrocode}\end{uninterestingcodeframe} +% \end{macrocode} % % Finally, we issue the command to parse and process all options. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \ltxkeys@launchkeys[cnc]{#1}{#2}% -% \end{macrocode}\end{codeframe} -% \begin{uninterestingcodeframe}\begin{macrocode} +% \end{macrocode} +% \uninteresting\begin{macrocode} }% } -% \end{macrocode}\end{uninterestingcodeframe} +% \end{macrocode} % %\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -689,17 +694,17 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \begin{macro}{\ConceptOption} \marg{concept key} -%%% \marg{option key}\\\nopagebreak +%%% \marg{option key}\\\nopagebreak\noindentnext % % The point of this command is that it can retrieve any option value % in an expandable way. That means we can't use |xparse|, but we don't % need it. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \newcommand*{\ConceptOption}[2]{% \cnc@g{concept(#1).option(#2)}% } -% \end{macrocode}\end{codeframe} +% \end{macrocode} % % Unfortunately, as of writing this, not all options are stored in a % fully expandable way yet. But they will be in a later version. @@ -711,16 +716,16 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \begin{macro}{\ConceptName} \movarg{*} \movarg{\textasciicircum} % \movarg{*} -%%% \marg{concept key}\\\nopagebreak +%%% \marg{concept key}\\\nopagebreak\noindentnext % % This implementation simply calls our private macro for retrieving % the name in one of four forms. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \NewDocumentCommand{\ConceptName}{t* t^ t* m}{% \cnc@conceptname{#1}{#2}{#3}{#4}% } -% \end{macrocode}\end{codeframe} +% \end{macrocode} % %\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -728,17 +733,17 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \begin{macro}{\ConceptSymbol} \marg{concept key} -%%% \oarg{index}\\\nopagebreak +%%% \oarg{index}\\\nopagebreak\noindentnext % % This implementation simply calls our private macro for retrieving % the symbol with the given index. The index is optional and % defaults to 1. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \NewDocumentCommand{\ConceptSymbol}{m O{1}}{% \cnc@conceptsymbol{#1}{#2}% } -% \end{macrocode}\end{codeframe} +% \end{macrocode} % %\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -748,13 +753,13 @@ % \begin{macro}{\ConceptSymbols} \marg{concept key} % \oarg{separator} % \oarg{last separator} -%%% \marg{indices}\\\nopagebreak +%%% \marg{indices}\\\nopagebreak\noindentnext % % This implementation simply calls our private macro for retrieving % the symbol list with the given indices. The index-list is mandatory % but can be empty. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \NewDocumentCommand{\ConceptSymbols}{m +O{,} +o m}{% \IfValueTF{#3}{% \cnc@conceptsymbols{#1}{#2}{#3}[#4]% @@ -762,7 +767,7 @@ \cnc@conceptsymbols{#1}{#2}{#2}[#4]% }% } -% \end{macrocode}\end{codeframe} +% \end{macrocode} % %\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -770,18 +775,18 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \begin{macro}{\ConceptNameAndSymbols} \marg{concept key} -%%% \marg{indices}\\\nopagebreak +%%% \marg{indices}\\\nopagebreak\noindentnext % % This implementation simply calls our private macro for typesetting % the concept name and the symbol list with the given indices. The % index-list is mandatory and cannot be empty. % -% \begin{codeframe}\begin{macrocode} +% \begin{macrocode} \NewDocumentCommand{\ConceptNameAndSymbols}{t^ m +O{,} +O{$ and $} m}{% \cnc@nameandsymbols{#2}{\BooleanFalse}{#1}{\BooleanFalse}% {#3}{#4}{#5}% } -% \end{macrocode}\end{codeframe} +% \end{macrocode} % %\end{macro}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/Master/texmf-dist/tex/latex/concepts/dry.sty b/Master/texmf-dist/tex/latex/concepts/dry.sty index 2ff5646046a..fd639991cee 100644 --- a/Master/texmf-dist/tex/latex/concepts/dry.sty +++ b/Master/texmf-dist/tex/latex/concepts/dry.sty @@ -2,7 +2,7 @@ % % % Copyright (c) 2012 - Michiel Helvensteijn (www.mhelvens.net) % % % -% http://latex-concepts.googlecode.com % +% http://latex-with.googlecode.com % % % % This work may be distributed and/or modified under the conditions % % of the LaTeX Project Public License, either version 1.3 of this % @@ -20,14 +20,14 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \fi %%%% % I will 'officially' release this package at some point in the future. For -% now I'm just using it to document the concepts package. Still, it's +% now I'm just using it to document a couple of packages. Still, it's % released under LPPL, so use it as you will. % % -- Michiel Helvensteijn \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{dry} - [2012/12/16 convenience macros for reusing LaTeX code] + [2012/12/19 convenience macros for reusing LaTeX code] \RequirePackage{filecontents} \RequirePackage{xparse} @@ -35,32 +35,22 @@ \RequirePackage{with} \newcommand\minput[1]{% - \input{#1}% - \ifhmode\ifnum\lastnodetype=11% - \unskip% - \fi\fi% + \input{#1}\unskip% } -\NewDocumentCommand{\NewDRYer}{m m +m}{% - \WithUniqueCsname[#1]{% - \csgdef{dry@filebase@##1}{##1}% - \csgdef{dry@filename@##1}{\csuse{dry@filebase@##1}.tmp}% - % - % WARNING: Custom argument specs #2, but cannot end with an optional argument! - \NewDocumentEnvironment{#1}{#2}{% +\NewDocumentCommand{\NewDRYer}{m +m}{% + \with{un} [#1] [#2] {% + \newenvironment{#1}{% \begingroup% - \@tempswafalse\filec@ntents{\csuse{dry@filename@##1}}% + \@tempswafalse\filec@ntents{##1.tmp}% }{% \endfilecontents% \endgroup% }% - % \AfterEndEnvironment{#1}{% - \def\DRYFilename{\csuse{dry@filename@##1}}% - \def\DRYContent{\minput{\csuse{dry@filename@##1}}}% - #3% - \let\DRYFilename\relax% - \let\DRYContent\relax% + \with{xn} [##1.tmp] [\minput{##1.tmp}] {% + ##2% + }% }% }% } diff --git a/Master/texmf-dist/tex/latex/concepts/packagedoc.cls b/Master/texmf-dist/tex/latex/concepts/packagedoc.cls new file mode 100644 index 00000000000..1c261b98362 --- /dev/null +++ b/Master/texmf-dist/tex/latex/concepts/packagedoc.cls @@ -0,0 +1,353 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% Copyright (C) 2012 by Michiel Helvensteijn - www.mhelvens.net % +% % +% 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 % +% and version 1.3 or later is part of all distributions of % +% LaTeX version 2005/12/01 or later. % +% % +% This work has the LPPL maintenance status `author-maintained'. % +% % +% The Current Maintainer of this work is Michiel Helvensteijn. % +% % +% This work consists of the file packagedoc.cls. % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\let\packagename\jobname + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Document Class % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\LoadClassWithOptions{ltxdoc} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Importing The Relevant Package % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\RequirePackage{\packagename} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Importing Other Packages % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\RequirePackage{etoolbox} +\RequirePackage[xcolor]{mdframed} +\RequirePackage{marginnote} +\RequirePackage{listings} +\RequirePackage{textcomp} +\RequirePackage[pdftex,colorlinks=true]{hyperref} +\RequirePackage{dry} +\RequirePackage{needspace} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Documentation Options % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\EnableCrossrefs +\CodelineIndex +\RecordChanges + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% File Info % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\GetFileInfo{\packagename.sty} + +\title{The \textsf{\packagename} package\thanks{% + This document corresponds to \textsf{\packagename}~\fileversion, + dated \filedate.% +}} + +\author{ + Michiel Helvensteijn\\ + \href{mailto:mhelvens+latex@gmail.com}{mhelvens+latex@gmail.com} +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Development Info % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newmdenv[ + leftline = false, + rightline = false +]{bannerframe} + +\apptocmd{\maketitle}{ + \begin{bannerframe} + \small + \begin{center} + Development of this package is organized at + \href{http://latex-\packagename.googlecode.com} + {latex-\packagename.googlecode.com}.\\ + I am happy to receive feedback there! + \end{center} + \end{bannerframe} +}{}{} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Skipping Paragraph Indentation After Specific Stuff % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\let\packagedoc@old@par\par + +\newcommand*{\noindentnext}{% + \def\par{% + \packagedoc@old@par% + \noindent% + \let\par\packagedoc@old@par% + }% +} + +\newcommand*{\noindentafterenv}[1]{ + \AfterEndEnvironment{#1}{\noindentnext} +} + +\newcommand*{\noindentaftercmd}[1]{ + \apptocmd{#1}{\noindentnext}{}{ + \ClassError{packagedoc} + {Could not patch \protect#1\space command.} + {Oops! I tried to auto-skip any indentation after the + \protect#1\space command, but I failed somehow.} + } +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Example Environment Setup % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%% Extra keywords for LaTeX +% +\newcommand{\moretexcs}[1]{ + \lstdefinelanguage{latex}{ + language=[LaTeX]tex, + moretexcs={ExplSyntaxOn,ExplSyntaxOff,lstinputlisting,detokenize,#1} + } +} + +%%% Code formatting +% +\lstdefinestyle{examplecode}{% + language=latex,% + basicstyle=\ttfamily\small,% + texcsstyle=*\bfseries,% + upquote=true% +} + + + +%%% Setting up example code block +% +\definecolor{examplecodelinecolor}{rgb}{0,0,0} +\definecolor{examplecodebackgroundcolor}{rgb}{.9,.9,.9} +\newmdenv[ + linecolor = examplecodelinecolor, + backgroundcolor = examplecodebackgroundcolor, + skipabove = 0px, + skipbelow = 0px, + innertopmargin = -3px, + innerrightmargin = 4px, + innerbottommargin = -3px, + innerleftmargin = 4px +]{examplecodeframe} + +%%% Defining example output block +% +\definecolor{exampleoutputbackgroundcolor}{rgb}{1,1,1} +\newmdenv[ + linecolor = examplecodelinecolor, + backgroundcolor = exampleoutputbackgroundcolor, + skipabove = 0px, + skipbelow = 0px, + innertopmargin = 4px, + innerrightmargin = 4px, + innerbottommargin = 4px, + innerleftmargin = 4px +]{exampleoutputframe} + +%%% Macros for counting lines in file, adapted from +%%% http://andreas.scherbaum.la/blog/archives/ +%%% 670-Read-number-lines-in-a-file-in-LaTeX.html +% +\RequirePackage{ifthen} +\newboolean{packagedoc@restfile} +\newcommand*{\packagedoc@fileline}{} +\newread\packagedoc@file +\newcommand*{\packagedoc@readnextline}[1]{% + \ifthenelse{\boolean{packagedoc@restfile}}{% + \read#1 to \packagedoc@fileline% + \ifeof#1\setboolean{packagedoc@restfile}{false}% + \else\fi% + }{}% +} +\newcommand*{\countlinesinfile}[2]{% + \setboolean{packagedoc@restfile}{true}% + \setcounter{packagedoc@linecount}{0}% + \openin\packagedoc@file=#1% + \whiledo{\boolean{packagedoc@restfile}}{% + \packagedoc@readnextline{\packagedoc@file}% + \ifthenelse{\boolean{packagedoc@restfile}}{% + \stepcounter{packagedoc@linecount}% + }{}% + }% + \closein\packagedoc@file% + \edef#2{\thepackagedoc@linecount}% +} + +\newcounter{packagedoc@linecount} +\newlength{\packagedoc@spacetoreserve} + +%%% DRYer without output +% +\NewDRYer{latex-example}{% + \addvspace{4px}% + {% + \ttfamily\small% + \countlinesinfile{#1}{\countedlines}% + \setlength{\packagedoc@spacetoreserve}{\countedlines\baselineskip}% + \addtolength{\packagedoc@spacetoreserve}{-4px}% + \needspace{\packagedoc@spacetoreserve}% + }% + \begin{examplecodeframe}% + \renewcommand{\ttdefault}{pcr}% + \lstinputlisting[style=examplecode]{#1}% + \end{examplecodeframe}% + #2% + \noindentnext% + \addvspace{4px}% +} + +%%% DRYer WITH output but WITHOUT side-effects +% +\NewDRYer{latex-example-show}{% + \addvspace{4px}% + {% + \ttfamily\small% + \countlinesinfile{#1}{\countedlines}% + \setlength{\packagedoc@spacetoreserve}{\countedlines\baselineskip}% + \addtolength{\packagedoc@spacetoreserve}{\baselineskip}% + \needspace{\packagedoc@spacetoreserve}% + }% + \begin{examplecodeframe}% + \renewcommand{\ttdefault}{pcr}% + \lstinputlisting[style=examplecode]{#1}% + \end{examplecodeframe}\vspace{-4px}% + \begin{exampleoutputframe}% + #2% + \end{exampleoutputframe}% + \noindentnext% + \addvspace{4px}% +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Implementation Code Box Setup % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%% Saving old implementation code block font +% +\AtBeginDocument{\let\old@macro@font\macro@font} + +%%% Setup for 'interesting' implementation code blocks +% +\definecolor{interestingcodebackgroundcolor}{rgb}{.9,.9,.9} +\definecolor{interestingcodelinecolor}{rgb}{0,0,0} +\mdfdefinestyle{interestingcode}{ + linecolor = interestingcodelinecolor, + backgroundcolor = interestingcodebackgroundcolor +} +\newcommand*{\interesting}{% + \def\codestyle{interestingcode}% + \def\codeskipabove{5px}% + \let\macro@font\old@macro@font% +} + +%%% Setup for 'UNinteresting' implementation code blocks +% +\definecolor{uninterestingcodebackgroundcolor}{rgb}{.97,.97,.97} +\definecolor{uninterestingcodelinecolor}{rgb}{.5,.5,.5} +\definecolor{uninterestingcodecolor}{rgb}{.4,.4,.4} +\mdfdefinestyle{uninterestingcode}{ + linecolor = uninterestingcodelinecolor, + backgroundcolor = uninterestingcodebackgroundcolor, +} +\newcommand*{\uninteresting}{% + \def\codestyle{uninterestingcode}% + \def\codeskipabove{-5px}% + \def\macro@font{\color{uninterestingcodecolor}\old@macro@font}% +} + +%%% Actually surround 'macrocode' with the frame +% +\surroundwithmdframed[ + style = \codestyle, + skipabove = \codeskipabove, + skipbelow = 5px, + splittopskip = 10px, + splitbottomskip = 4px, + innertopmargin = 4px, + innerrightmargin = 4px, + innerbottommargin = 4px, + innerleftmargin = 4px +]{macrocode} + +\noindentafterenv{macrocode} + +%%% Start out with 'interesting' code status and +%%% always go back to it after one code block +% +\interesting +\AfterEndEnvironment{macrocode}{\interesting} + +%%% No indentation after macrocode block +% +\noindentafterenv{macrocode} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Argument Specifiers and such % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newcommand*{\movarg}[1]{[ \texttt{#1} ]} +\newcommand*{\momarg}[1]{[ \meta{#1} ]} + +\newcommand{\describemacro}[2]{% + \needspace{3\baselineskip}% + \noindent\\\DescribeMacro{#1} #2\\\noindentnext% +} + +\newcommand{\describemetamacro}[2]{% + \needspace{3\baselineskip}% + \noindent\\\marginnote{\meta{#1}} #2\\\noindentnext% +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Other Stuff % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\noindentafterenv{description} +\noindentafterenv{itemize} +\noindentafterenv{enumerate} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Automatic Implementation Docs % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\AtEndDocument{ + \pagebreak + + \section{Implementation} + + \StopEventually {\PrintChanges} + + We now show and explain the entire implementation from \texttt{\packagename.sty}. + + \DocInput{\packagename.sty} + + \Finale + + \PrintIndex +} diff --git a/Master/texmf-dist/tex/latex/concepts/with.sty b/Master/texmf-dist/tex/latex/concepts/with.sty index 4e94ac02516..49e16dac493 100644 --- a/Master/texmf-dist/tex/latex/concepts/with.sty +++ b/Master/texmf-dist/tex/latex/concepts/with.sty @@ -2,7 +2,7 @@ % % % Copyright (c) 2012 - Michiel Helvensteijn (www.mhelvens.net) % % % -% http://latex-concepts.googlecode.com % +% http://latex-with.googlecode.com % % % % This work may be distributed and/or modified under the conditions % % of the LaTeX Project Public License, either version 1.3 of this % @@ -15,89 +15,295 @@ % % % The Current Maintainer of this work is Michiel Helvensteijn. % % % -% This work consists of the file with.sty. % +% This work consists of the file with.sty and with.tex. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \fi %%%% -% I will 'officially' release this package at some point in the future. For -% now I'm just using it to document the concepts package. Still, it's -% released under LPPL, so use it as you will. +% \CheckSum{0} % -% -- Michiel Helvensteijn +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \subsection{Package Info} % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + +% \begin{macrocode} \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\ProvidesExplPackage{with}{2012/12/16}{0.0.1} - {an inline construct for passing token lists as ##1-type arguments} +\ProvidesExplPackage{with}{2012/12/23}{0.0.1} + {an inline construct for passing token lists as parameters} +% \end{macrocode} -\cs_new_eq:NN \qnv \q_no_value -\cs_new:Nn \with:nn { - \with:nnnnnnnnn {#1}\qnv\qnv\qnv\qnv\qnv\qnv\qnv{#2} -} -\cs_new:Nn \with:nnn { - \with:nnnnnnnnn {#1}{#2}\qnv\qnv\qnv\qnv\qnv\qnv{#3} -} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \subsection{Required Packages} % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + +% \begin{macrocode} +\RequirePackage{xparse} +\RequirePackage{l3regex} +% \end{macrocode} + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \subsection{Package Code} % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + +% \begin{macrocode} +\cs_generate_variant:Nn \cs_generate_variant:Nn {cn} +% \end{macrocode} -\cs_new:Nn \with:nnnn { - \with:nnnnnnnnn {#1}{#2}{#3}\qnv\qnv\qnv\qnv\qnv{#4} -} -\cs_new:Nn \with:nnnnn { - \with:nnnnnnnnn {#1}{#2}{#3}{#4}\qnv\qnv\qnv\qnv{#5} -} -\cs_new:Nn \with:nnnnnn { - \with:nnnnnnnnn {#1}{#2}{#3}{#4}{#5}\qnv\qnv\qnv{#6} +% \begin{macrocode} +\cs_new:Nn \gen_use:nn { + \cs_generate_variant:cn + { #1 : \prg_replicate:nn{\tl_count:n{#2}}{n} } + { #2 } + \use:c{ #1 : #2 } } +% \end{macrocode} -\cs_new:Nn \with:nnnnnnn { - \with:nnnnnnnnn {#1}{#2}{#3}{#4}{#5}{#6}\qnv\qnv{#7} + + +% \begin{macrocode} +\cs_new_protected:Nn \with:n {#1} +\cs_new_protected:Nn \with:nn { + \cs_set:Npn \__with:n ##1 {#2} + \__with:n {#1} } +\cs_new_protected:Nn \with:nnn { + \cs_set:Npn \__with:nn ##1##2 {#3} + \__with:nn {#1}{#2} } +\cs_new_protected:Nn \with:nnnn { + \cs_set:Npn \__with:nnn ##1##2##3 {#4} + \__with:nnn {#1}{#2}{#3} } +\cs_new_protected:Nn \with:nnnnn { + \cs_set:Npn \__with:nnnn ##1##2##3##4 {#5} + \__with:nnnn {#1}{#2}{#3}{#4} } +\cs_new_protected:Nn \with:nnnnnn { + \cs_set:Npn \__with:nnnnn ##1##2##3##4##5 {#6} + \__with:nnnnn {#1}{#2}{#3}{#4}{#5} } +\cs_new_protected:Nn \with:nnnnnnn { + \cs_set:Npn \__with:nnnnnn ##1##2##3##4##5##6 {#7} + \__with:nnnnnn {#1}{#2}{#3}{#4}{#5}{#6} } +\cs_new_protected:Nn \with:nnnnnnnn { + \cs_set:Npn \__with:nnnnnnn ##1##2##3##4##5##6##7 {#8} + \__with:nnnnnnn {#1}{#2}{#3}{#4}{#5}{#6}{#7} } +\cs_new_protected:Nn \with:nnnnnnnnn { + \cs_set:Npn \__with:nnnnnnnn ##1##2##3##4##5##6##7##8 {#9} + \__with:nnnnnnnn {#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8} } +% \end{macrocode} + + + +% \begin{macrocode} +\msg_new:nnnn{with}{invalid-parameter-specs}{ + The~argument~specification~'#1'~is~not~valid. +}{ + The~argument~specification~should~consist~of~between~ + one~and~seven~of~the~letters~'n',~'o',~'f',~'x',~'u'~or~'U'. } +% \end{macrocode} + -\cs_new:Nn \with:nnnnnnnn { - \with:nnnnnnnnn {#1}{#2}{#3}{#4}{#5}{#6}{#7}\qnv{#8} + +% \begin{macrocode} +\msg_new:nnnn{with}{invalid-parameter-number}{ + You~specified~#1~arguments~but~provided~#2. +}{ + Your~argument~specification~is~'#3',~which~means~you~should~ + provide~#1~optional~arguments.~However,~you~provided~only~#2. } +% \end{macrocode} + -\cs_new:Nn \with:nnnnnnnnn { - \cs_set:Nn \with_aux:nnnnnnnn {#9} - \with_aux:nnnnnnnn {#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8} + +% \begin{macrocode} +\tl_new:N \l__with_argspec_tl +\tl_new:c {l__with_p_1_tl} \tl_new:c {l__with_p_2_tl} +\tl_new:c {l__with_p_3_tl} \tl_new:c {l__with_p_4_tl} +\tl_new:c {l__with_p_5_tl} \tl_new:c {l__with_p_6_tl} +\tl_new:c {l__with_p_7_tl} +\tl_new:N \l__with_code_tl +% \end{macrocode} + + + +% \begin{macrocode} +\int_new:N \l__with_arg_int +\cs_new:Nn \__with_param_name: { + l__with_p_ + \int_use:N\l__with_arg_int + _tl } +% \end{macrocode} + + + +% \begin{macrocode} +\tl_new:N \l__with_unique_counter_tl +\tl_new:N \l__with_param_tl +% \end{macrocode} + + +% \begin{macrocode} \cs_generate_variant:Nn \with:nn {xn} -\cs_generate_variant:Nn \with:nnn {xxn} -\cs_generate_variant:Nn \with:nnnn {xxxn} -\cs_generate_variant:Nn \with:nnnnn {xxxxn} -\cs_generate_variant:Nn \with:nnnnnn {xxxxxn} -\cs_generate_variant:Nn \with:nnnnnnn {xxxxxxn} -\cs_generate_variant:Nn \with:nnnnnnnn {xxxxxxxn} -\cs_generate_variant:Nn \with:nnnnnnnnn {xxxxxxxxn} - -\NewDocumentCommand{\With}{+o+o+o+o+o+o+o+o+m}{ - \IfValueTF{#8}{ \with:xxxxxxxxn{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9} }{ - \IfValueTF{#7}{ \with:xxxxxxxn {#1}{#2}{#3}{#4}{#5}{#6}{#7} {#9} }{ - \IfValueTF{#6}{ \with:xxxxxxn {#1}{#2}{#3}{#4}{#5}{#6} {#9} }{ - \IfValueTF{#5}{ \with:xxxxxn {#1}{#2}{#3}{#4}{#5} {#9} }{ - \IfValueTF{#4}{ \with:xxxxn {#1}{#2}{#3}{#4} {#9} }{ - \IfValueTF{#3}{ \with:xxxn {#1}{#2}{#3} {#9} }{ - \IfValueTF{#2}{ \with:xxn {#1}{#2} {#9} }{ - \IfValueTF{#1}{ \with:xn {#1} {#9} } - {#9} +\cs_generate_variant:Nn \with:nnnnnnnnn {oooooooon} +% \end{macrocode} + + + +% \begin{macrocode} +\NewDocumentCommand \with {m +o +o +o +o +o +o +o +m} { +% \end{macrocode} + + + +% \begin{macrocode} + \regex_match:nnF {^[noxfuU]{1,7}$} {#1} + { \msg_critical:nnn{with}{invalid-parameter-specs}{#1} } +% \end{macrocode} + + + +% \begin{macrocode} + \tl_set:Nn \l__with_argspec_tl {#1} + \int_zero:N \l__with_arg_int + \IfValueT{#2} { + \tl_set:cn {l__with_p_1_tl} {#2} \int_incr:N \l__with_arg_int + \IfValueT{#3} { + \tl_set:cn {l__with_p_2_tl} {#3} \int_incr:N \l__with_arg_int + \IfValueT{#4} { + \tl_set:cn {l__with_p_3_tl} {#4} \int_incr:N \l__with_arg_int + \IfValueT{#5} { + \tl_set:cn {l__with_p_4_tl} {#5} \int_incr:N \l__with_arg_int + \IfValueT{#6} { + \tl_set:cn {l__with_p_5_tl} {#6} \int_incr:N \l__with_arg_int + \IfValueT{#7} { + \tl_set:cn {l__with_p_6_tl} {#7} \int_incr:N \l__with_arg_int + \IfValueT{#8} { + \tl_set:cn {l__with_p_7_tl} {#8} \int_incr:N \l__with_arg_int }}}}}}} -} + \tl_set:Nn \l__with_code_tl {#9} +% \end{macrocode} -\int_new:c{g_with_uniquecsname_count} -\cs_new:Nn \with_uniquecsname:n { - \with_uniquecsname:xn {uniquecsname} {#1} -} -\cs_new:Nn \with_uniquecsname:xn { - \int_incr:c {g_with_uniquecsname_count} - \with:xn {#1\int_use:c{g_with_uniquecsname_count}} {#2} -} +% \begin{macrocode} + \int_compare:nNnF {\tl_count:n{#1}} = {\l__with_arg_int} { + \msg_error:nnxxx{with}{invalid-parameter-number} + { \tl_count:n{#1} } + { \int_use:N \l__with_arg_int } + { #1 } + } +% \end{macrocode} + + + +% \begin{macrocode} + \tl_replace_all:Nnn \l__with_argspec_tl {u} {x} + \tl_replace_all:Nnn \l__with_argspec_tl {U} {c} +% \end{macrocode} -\NewDocumentCommand{\WithUniqueCsname}{O{uniquecsname}+m}{ - \with_uniquecsname:xn {#1} {#2} + + +% \begin{macrocode} + \int_zero:N \l__with_arg_int + \tl_map_inline:nn {#1} { + \int_incr:N \l__with_arg_int +% \end{macrocode} + + + +% \begin{macrocode} + \tl_if_in:nnT {uU} {##1} { + \tl_set:Nx \l__with_unique_counter_tl + { g__with_unique_ \use:c{\__with_param_name:} _count_int } + + \int_if_exist:cF {\l__with_unique_counter_tl} + { \int_new:c {\l__with_unique_counter_tl} } + + \int_incr:c {\l__with_unique_counter_tl} + + \tl_put_left:cx {\__with_param_name:} + { g_with_unique_ } + + \tl_put_right:cx {\__with_param_name:} + { _ \int_use:c{\l__with_unique_counter_tl} } + } +% \end{macrocode} + + + +% \uninteresting\begin{macrocode} + } +% \end{macrocode} + + + +% \begin{macrocode} + \with:oooooooon {\l__with_argspec_tl} + {\cs:w l__with_p_1_tl \cs_end:} + {\cs:w l__with_p_2_tl \cs_end:} + {\cs:w l__with_p_3_tl \cs_end:} + {\cs:w l__with_p_4_tl \cs_end:} + {\cs:w l__with_p_5_tl \cs_end:} + {\cs:w l__with_p_6_tl \cs_end:} + {\cs:w l__with_p_7_tl \cs_end:} { + \with:oooooooon {##1o}{##2}{##3}{##4} + {##5}{##6}{##7}{##8} { + \int_case:nnn {\l__with_arg_int} { + {1} { \gen_use:nn{with}{####1} + {####2} {\l__with_code_tl} } + {2} { \gen_use:nn{with}{####1} + {####2}{####3} {\l__with_code_tl} } + {3} { \gen_use:nn{with}{####1} + {####2}{####3}{####4} {\l__with_code_tl} } + {4} { \gen_use:nn{with}{####1} + {####2}{####3}{####4} + {####5} {\l__with_code_tl} } + {5} { \gen_use:nn{with}{####1} + {####2}{####3}{####4} + {####5}{####6} {\l__with_code_tl} } + {6} { \gen_use:nn{with}{####1} + {####2}{####3}{####4} + {####5}{####6}{####7} {\l__with_code_tl} } + {7} { \gen_use:nn{with}{####1} + {####2}{####3}{####4} + {####5}{####6}{####7} + {####8} {\l__with_code_tl} } + }{} + } + } +% \end{macrocode} + + + +% \uninteresting\begin{macrocode} } +% \end{macrocode} + + |