diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/mlist/mlist.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/mlist/mlist.dtx | 294 |
1 files changed, 159 insertions, 135 deletions
diff --git a/Master/texmf-dist/source/latex/mlist/mlist.dtx b/Master/texmf-dist/source/latex/mlist/mlist.dtx index 4b12378256e..19ba4116a7a 100644 --- a/Master/texmf-dist/source/latex/mlist/mlist.dtx +++ b/Master/texmf-dist/source/latex/mlist/mlist.dtx @@ -1,29 +1,55 @@ -% \iffalse meta-comment -% -% -% Copyright (C) 2007 by Will Robertson <wspr81@gmail.com> -% -% Distributable under the LaTeX Project Public License, -% version 1.3c or higher (your choice). The latest version of -% this license is at: http://www.latex-project.org/lppl.txt -% -% This work is "maintained" (as per LPPL maintenance status) -% by Will Robertson. -% -% This work consists of the file mlist.dtx -% and the derived files mlist.sty and mlist.pdf. -% -% -%<*internalbatchfile> +% \iffalse +%<*internal> +\iffalse +%</internal> +%<*readme> +_________________ +The MLIST package +v0.5 + +This package defines the commands \newvect, \newmatr, \newfunc, +and \newmset for creating macros to typeset vectors, matrices, +functions, and sets. For example, Logical indexing can then be +used to refer to elements or arguments without hard-coding the +symbols in the document: + + \newvect\myvect{V}[elem=a,b,c] + \myvect{1,2,3} + +produces + + \left( V_a, V_b, V_c \right) + +All aspects of the typeset appearance can be adjusted, and new +`mlists' can be defined to represent other mathematical constructs. + +Consider this package an exploration of separation of form and content +for some mathematical constructions. I hope you find it useful. + +______________ +Change history + +v0.5: Introduced \newmset for defining mathematical sets; + with pre-defined sets \setR, \setC, \setZ, \setN. + +______________ +Will Robertson +wspr 81 [at] gmail [dot] com + +Copyright 2007 +Distributed under the LaTeX Project Public License +%</readme> +%<*internal> +\fi \begingroup -%</internalbatchfile> +%</internal> %<*batchfile> \input docstrip.tex \keepsilent \preamble __________________________________ - Copyright (C) 2006 Will Robertson + Copyright (C) 2007 Will Robertson License information appended. @@ -40,25 +66,27 @@ this license is at: http://www.latex-project.org/lppl.txt This work is "maintained" (as per LPPL maintenance status) by Will Robertson. -This work consists of the file \jobname.dtx - and the derived files \jobname.sty and \jobname.pdf. +This work consists of the file mlist.dtx + and the derived files mlist.pdf, + mlist.sty, + mlist.cfg, and + mlist.ins. \endpostamble \askforoverwritefalse -\generate{\file{\jobname.sty}{\from{\jobname.dtx}{package} - \from{\jobname.dtx}{defaults}}} +\generate{\file{\jobname.sty}{\from{\jobname.dtx}{package}}} +\generate{\file{\jobname.cfg}{\from{\jobname.dtx}{defaults}}} +%</batchfile> +%<batchfile>\endbatchfile +%<*internal> \generate{\file{\jobname.ins}{\from{\jobname.dtx}{batchfile}}} \nopreamble\nopostamble \generate{\file{README.txt}{\from{\jobname.dtx}{readme}}} \generate{\file{dtx-style.sty}{\from{\jobname.dtx}{dtx-style}}} -%</batchfile> -%<batchfile>\endbatchfile -%<*internalbatchfile> \endgroup \immediate\write18{makeindex -s gind.ist -o \jobname.ind \jobname.idx} \immediate\write18{makeindex -s gglo.ist -o \jobname.gls \jobname.glo} -\immediate\write18{mv README.txt README} -%</internalbatchfile> +%</internal> % %<*driver> \documentclass{ltxdoc} @@ -72,37 +100,6 @@ This work consists of the file \jobname.dtx \end{document} %</driver> % -%<*readme> -_________________ -The MLIST package -v0.4 - -This package defines the commands \newvect, \newmatr, and \newfunc for -creating macros to typeset vectors, matrices, and functions. For -example, Logical indexing can then be used to refer to elements or -arguments without hard-coding the symbols in the document: - - \newvect\myvect{V}[elem=a,b,c] - \myvect{1,2,3} - -produces - - \left( V_a, V_b, V_c \right) - -All aspects of the typeset appearance can be adjusted, and new `mlists' -can be defined to represent other mathematical constructs. - -Consider this package an exploration of separation of form and content -for some mathematical constructions. I hope you find it useful. - -______________ -Will Robertson -wspr 81 [at] gmail [dot] com - -Copyright 2007 -Distributed under the LaTeX Project Public License - -%</readme> % % \fi % @@ -110,7 +107,7 @@ Distributed under the LaTeX Project Public License % \CheckSum{0} % \makeatletter % -% \title{Logical markup for lists} +% \title{Logical markup for mathematical lists} % \author{Will Robertson} % \date{\filedate \qquad \fileversion} % @@ -165,7 +162,7 @@ Distributed under the LaTeX Project Public License % \qquad \dist{1,2,3} \] % \end{example} % -% \subsection{Matrix and function notation} +% \subsection{Matrix notation} % % So the basic idea of this package is to separate the formatting and % content of mathematical objects. The above example showed vector @@ -188,6 +185,8 @@ Distributed under the LaTeX Project Public License % throughout an entire document (or collection of documents) without % changing the fundamental markup of the mathematics itself. % +% \subsection{Function and `set' notation} +% % \DescribeMacro{\newfunc} Finally, here's something a little % different. Vector and matrices are both quite similar. But it takes % only a slight stretch to extend the syntax of this package to things @@ -202,17 +201,29 @@ Distributed under the LaTeX Project Public License % papers. To hammer home the point: this can be now done for an entire % document with a simple switch. % -% \subsubsection{Non-specific commands} -% Sometimes you don't always want to define new macros for one-off -% maths expressions. Accompanying the \cmd\newvect, \cmd\newmatr, and -% \cmd\newfunc\ macros are \cmd\vect, \cmd\matr, and \cmd\func, which -% can be used for single cases: +% \DescribeMacro{\newmset} Here's an example to further +% demonstrate the flexibility of the package. +% \begin{example}{} +% \newmset\setT{T} +% \[ \setT \qquad \setT{2} \qquad \setT{2,3} \] +% \end{example} +% The \cmd\setR, \cmd\setC, \cmd\setN, and \cmd\setZ\ `msets' are defined +% by default for real, complex, natural, and integer numbers. % \begin{example}{} -% \[ \vect{V}{a,b,c} \qquad -% \matr{M}{a,b;c,d} \qquad -% \func{f}{x_0;x,t} \] +% \[ \bm{x}\in\setR{2,2} \] % \end{example} % +% \subsection{Non-specific commands} +% Sometimes you don't always want to define new macros for one-off +% maths expressions. Accompanying the \cmd\newvect, \cmd\newmatr, +% \cmd\newfunc, and \cmd\newmset\ macros are \cmd\vect, \cmd\matr, \cmd\func, +% and \cmd\mset, which can be used for single cases: +% \begin{example}{} +% \[ \vect{V}{a,b,c} \quad +% \matr{M}{a,b;c,d} \quad +% \func{f}{x_0;x,t} \quad +% \mset{D}{m,n} \] +% \end{example} % This usage is generally not recommended except in isolated cases. % % \subsection{An example of some actual maths} @@ -231,7 +242,6 @@ Distributed under the LaTeX Project Public License % \[ \frac\partial{\partial t} % \state = \dyn \state \] % \end{example} -% % There's a lot more semantic meaning in that mathematical \TeX\ source than if it were hard-coded without this package. % % \subsection{Elements and indexing}\seclabel{indexing} @@ -272,7 +282,6 @@ Distributed under the LaTeX Project Public License % \[ \V=\V{4,5,6} \] % \[ \V=\V{1,2,3;@1,@2,@3} \] % \end{example} -% % See \tabref{index-syntax} for a more detailed example of the indexing system. % % \begin{table} @@ -294,7 +303,6 @@ Distributed under the LaTeX Project Public License % $\LL$ \quad vs.\quad $\LL{}$ % \quad vs.\quad $\LL{1,2} $ % \end{example} -% % This was shown originally in the function example on page~\pageref{func-example}. % % \subsection{Shorthand indices and empty elements} @@ -304,8 +312,8 @@ Distributed under the LaTeX Project Public License % In this example, the semi-colon separation is shown with the % \cmd\dots\ shorthand `|:|' and the \cmd\cdot\ shorthand `|.|'. % \begin{example}{} -% \newvect\mset{M} -% \[ \mset=\mset{1,2,:,5;a,b,.,d} \] +% \newvect\mm{M} +% \[ \mm=\mm{1,2,:,5;a,b,.,d} \] % \end{example} % % More shorthands will be defined in the future via @@ -352,7 +360,7 @@ Distributed under the LaTeX Project Public License % \emph{instance generator} for the types of lists we're dealing with. % Use \cmd\renewmlist\ if the command is already in use. % -% \cmd\newmlist\cs{<list>}\marg{list options} creates macros +% \cmd\newmlist\cs{<list>}\oarg{list options} creates macros % \cs{<list>} and \cs{new<list>} (and \cs{renew<list>}) that are % analogous to \cmd\vect\ and \cmd\newvect\ seen in % \secref{vect}. \meta{list options} can contain any of those seen so @@ -452,7 +460,7 @@ Distributed under the LaTeX Project Public License % $\RRR + \RRR{1} + \RRR{a,b}$ % \end{example} % -% \pkg{mlist} provides some example commands for this purpose:\par +% \pkg{mlist} provides some example commands for this purpose:\par\nobreak\noindent % \begingroup\ttfamily % \def\mean#1{\string#1 & \expandafter\parse@meaning\meaning#1\@nil} % \def\parse@meaning #1:#2->#3\@nil{\detokenize{#3}\\} @@ -489,7 +497,7 @@ Distributed under the LaTeX Project Public License % may be adjusted with \cmd\mlistsetup\marg{mlist options}. The defaults % are shown in \secref[vref]{defaults}. % -% \subsection{Redefining \cmd\vect, \cmd\matr, \cmd\func} +% \subsection{Redefining \cmd\vect, \cmd\matr, \cmd\func, \cmd\mset} % % This package makes little claim for being imminently usable for most % people \emph{out of the box}. I figure there's just too much @@ -497,13 +505,10 @@ Distributed under the LaTeX Project Public License % % If changes to the mlists provided by default with this package % are required (as they will be if any aspect of their formatting needs -% to be adjusted), simply copy their definitions from \secref[vref]{defaults} +% to be adjusted), simply create a local |mlist.cfg| file with different +% defintions or even just copy them from \secref[vref]{defaults} % in a \cmd\renewmlist. % -% In the future I hope to implement a local \cmd\mlistsetup, but not now. -% -% -% % \section{TODO} % \begin{itemize} % \item changing features of (or adding features to, rather) `newvect' @@ -524,11 +529,11 @@ Distributed under the LaTeX Project Public License % \section{The default definitions} % \seclabel{defaults} % -% This is the code that appears in the package itself to set up the -% default options and mlists. +% This is the code that appears in the default configuration file \pkg{mlist.cfg} to set up the +% default options and mlists. Edit a copy of \pkg{mlist.cfg} in a local location (in a local \texttt{texmf} tree or on a per-document basis) to change these definitions and to create your own mlists. % % \subsection{Global options} -% These are inherited by mlists that do not their own respective +% These are inherited by mlists that do not explicitly define their own respective % options. Geared towards \cmd\vect, essentially. % \begin{macrocode} \mlistsetup{% @@ -569,7 +574,6 @@ Distributed under the LaTeX Project Public License \newmlist\matr[ sep=&, sepsep=\\, - elemcmd=\mlistelem, wrap={\begin{bmatrix}} {\end{bmatrix}}, ] @@ -581,13 +585,36 @@ Distributed under the LaTeX Project Public License % \begin{macrocode} \newmlist\func[ headcmd=\mlisthead, - elemcmd=\mlistelem, wrapcmd=\mlistheadparen, wraponecmd, ] % \end{macrocode} % \end{macro} % +% \begin{macro}{\mset} +% By default, |\mset{N}{2,3}| $\to$ $\mset{N}{2,3}$. +% \begin{macrocode} +\newmlist\mset[ + headcmd=\mathbb, + sep=\times, + wrapcmd=\mlistsup, + wraponecmd, +] +% \end{macrocode} +% \changes{v0.5}{2007/06/06}{Added.} +% \end{macro} +% Sets for real, complex, natural, and integer numbers, respectively: +% \begin{macrocode} +\newmset\setR{R} +\newmset\setC{C} +\newmset\setN{N} +\newmset\setZ{Z} +% \end{macrocode} +% +%\iffalse +%</defaults> +%\fi +% % \section{Prior art} % % With \CTAN\ getting so big these days, it's quite necessary to @@ -681,9 +708,6 @@ Distributed under the LaTeX Project Public License % this package is trying to do. Integration between this package and those three above are possible, % but has not yet been investigated. % -%\iffalse -%</defaults> -%\fi % % \StopEventually{} % @@ -698,13 +722,14 @@ Distributed under the LaTeX Project Public License % % \begin{macrocode} \ProvidesPackage{mlist} - [2007/05/19 v0.4 Typesetting maths lists] + [2007/09/19 v0.5 Typesetting maths lists] % \end{macrocode} % % \PrintChanges % \changes{v0.1}{27/04/2007}{Code tidy up; first decent version.} % \changes{v0.2}{30/04/2007}{More documentation; list indexing not finalised.} % \changes{v0.3}{2007/05/02}{List indexing decided; empty arguments ignored.} +% \changes{v0.4}{2007/05/26}{Tidied things up a little bit.} % % \subsection{User shorthands} % @@ -738,11 +763,11 @@ Distributed under the LaTeX Project Public License \RequirePackage{xkeyval,ifmtarg} % \end{macrocode} % \subsection{Code we need} -% More temporary conditionala and counters and things: +% Conditionals and counters and things: % \begin{macrocode} -\unless\ifdefined\if@tempswb\newif\if@tempswb\fi -\unless\ifdefined\if@tempswc\newif\if@tempswc\fi -\unless\ifdefined\@tempcntc\newcount\@tempcntc\fi +\newif\if@mlist@notfirst@ +\newif\if@mlist@implicit@ +\newcount\mlist@elem@N \def\@gobblenil#1\@nil{} % \end{macrocode} % Some specific things: @@ -785,6 +810,13 @@ Distributed under the LaTeX Project Public License \providecommand\def@co[2]{% \def@c{#1\expandafter}\expandafter{#2}} % \end{macrocode} +% \begin{macro}{\@optarg} +% Macro to simplify optional argument parsing. +% \begin{macrocode} +\newcommand\@optarg[1]{\@ifnextchar[{#1}{#1[]}}%] +% \end{macrocode} +% \changes{v0.4}{2007/05/26}{Implemented to simplify optional arg processing.} +% \end{macro} % Shorthand to test for optional brace arguments: % \begin{macrocode} \newcommand\@ifnextbrace{\expandafter\@ifnextchar\bgroup} @@ -856,12 +888,11 @@ Distributed under the LaTeX Project Public License % \begin{description}[nolistsep] % \item[\cmd\@tempcnta] Number of semicolon list. % \item[\cmd\@tempcntb] Element number of this comma list. -% \item[\cmd\@tempcntc] Combined element number. % \end{description} % \begin{macrocode} \@tempcnta\z@ \@tempcntb\z@ - \@tempcntc\z@ + \mlist@elem@N\z@ % \end{macrocode} % Iterate over every semicolon list. Set \cs{if@tempswa} true only % after every |:| element, for each semicolon list. Maybe we should @@ -902,9 +933,9 @@ Distributed under the LaTeX Project Public License % (Index $3,1$ is the sixth in the list.) % \begin{macrocode} \advance\@tempcntb\@ne - \advance\@tempcntc\@ne + \advance\mlist@elem@N\@ne \def@co{mlist@\the\@tempcnta @\the\@tempcntb}{\@ii}% - \def@co{mlist@@\the\@tempcntc}{\@ii}% + \def@co{mlist@@\the\mlist@elem@N}{\@ii}% \fi \fi}% % \end{macrocode} @@ -990,7 +1021,7 @@ Distributed under the LaTeX Project Public License % And (sub-)iterate over every comma-separated list: % \begin{macrocode} \@tempcntb\z@ - \@tempswbfalse + \@mlist@notfirst@false \@for\@ii:=\@jj\do{% \let\@ii\@ii \advance\@tempcntb\@ne @@ -1004,8 +1035,8 @@ Distributed under the LaTeX Project Public License % \end{macrocode} % When it's not empty: % \begin{macrocode} - {\if@tempswb\mlist@add\mlist@sep\fi - \@tempswbtrue + {\if@mlist@notfirst@\mlist@add\mlist@sep\fi + \@mlist@notfirst@true \ifx\@ii\mlist@colon \mlist@add{\mlist@dots\@gobble}% \else @@ -1017,11 +1048,11 @@ Distributed under the LaTeX Project Public License \fi}% % \end{macrocode} % Parse the index to see if it's an implicit reference of the form -% |@|$n$. swc is true if the index is implicit: (and we assume |@| +% |@|$n$. @mlist@implicit@ is true if the index is implicit: (and we assume |@| % will be only used in an implicit-indexing context. TODO: fix this!) % \begin{macrocode} \mlist@parse@implicit - \if@tempswc + \if@mlist@implicit@ \mlist@add@ifcs{% mlist@\the\@tempcnta @\expandafter\@gobble\@ii }{\@ii}% @@ -1043,7 +1074,9 @@ Distributed under the LaTeX Project Public License % \end{macrocode} % That was the end of semicolon-separated iteration. % \begin{macrocode} - \def\mlist@list{\mlist@wrap{\mlist@symbol}{\mlist@list@elems}}% + \def\mlist@list{% + \mlist@wrap{\mlist@headcmd{\mlist@symbol}} + {\mlist@list@elems}}% % \end{macrocode} % If only have a single element: % \begin{macrocode} @@ -1060,6 +1093,7 @@ Distributed under the LaTeX Project Public License % \changes{v0.4}{2007/05/17}{Eliminated \cmd\global\ no longer % required since I separated the list creation and typesetting.} % \changes{v0.4}{2007/05/19}{Simplified `single index' code.} +% \changes{v0.5}{2007/06/06}{Added \cmd\mlist@headcmd\ command to the \cmd\mlist@symbol inside \cmd\mlist@wrap\ (fixed bug with \cmd\mset)} % \end{macro} % % \begin{macro}{\mlist@add} @@ -1103,20 +1137,20 @@ Distributed under the LaTeX Project Public License % Parses the index to see if it's an implicit reference: |@|$n$. The % idea is to expand out the index, set a conditional if the first % char is an |@|, and then gobble up the whole thing. We do this -% twice for the two common catcodes that |@| could be. +% twice for the two common catcodes that |@| might be. % \begin{macrocode} \def\mlist@parse@implicit{% - \@tempswcfalse + \@mlist@implicit@false \def\@tempb{% \expandafter\@ifnextchar\mlist@ampersat - {\@tempswctrue\@gobblenil} - {\@tempswcfalse\@gobblenil}}% + {\@mlist@implicit@true\@gobblenil} + {\@mlist@implicit@false\@gobblenil}}% \expandafter\@tempb\@ii\@nil - \unless\if@tempswc + \unless\if@mlist@implicit@ \def\@tempb{% \@ifnextchar @ - {\@tempswctrue\@gobblenil} - {\@tempswcfalse\@gobblenil}}% + {\@mlist@implicit@true\@gobblenil} + {\@mlist@implicit@false\@gobblenil}}% \expandafter\@tempb\@ii\@nil \fi} % \end{macrocode} @@ -1146,16 +1180,11 @@ Distributed under the LaTeX Project Public License % \begin{macrocode} \newcommand\newmlist[1]{% \@mlist@warntrue - \@ifnextchar[%] - {\@defmlist@opt{#1}} - {\@defmlist@noopt{#1}}} + \@optarg{\@defmlist@opt{#1}}} \newcommand\renewmlist[1]{% \@mlist@warnfalse - \@ifnextchar[%] - {\@defmlist@opt{#1}} - {\@defmlist@noopt{#1}}} + \@optarg{\@defmlist@opt{#1}}} \def\@defmlist@opt#1[#2]{\@defmlist{#1}{#2}} -\def\@defmlist@noopt#1{\@defmlist{#1}{}} % \end{macrocode} % Processing |#1| = thislist-cmd, |#2| = all-thislist-opts % \begin{macrocode} @@ -1172,11 +1201,9 @@ Distributed under the LaTeX Project Public License \protected\def#1##1{% \@ifnextbrace {\csname\string#1@opt\endcsname{##1}} - {\csname\string#1@noopt\endcsname{##1}}}% + {\csname\string#1@opt\endcsname{##1}{}}}% \def@c{\string#1@opt}##1##2{% \csname\string#1\endcsname{##1}{##2}}% - \def@c{\string#1@noopt}##1{% - \csname\string#1\endcsname{##1}{}}% \def@c{\string#1}##1##2{% \@mlist{symbol=##1,#2,index={##2}}}% % \end{macrocode} @@ -1185,18 +1212,12 @@ Distributed under the LaTeX Project Public License % \begin{macrocode} \def@c{new\expandafter\@gobble\string#1}##1##2{% \@mlist@warntrue - \@ifnextchar[%] - {\csname @new\string#1@opt\endcsname{##1}{##2}} - {\csname @new\string#1@noopt\endcsname{##1}{##2}}}% + \@optarg{\csname @new\string#1@opt\endcsname{##1}{##2}}}% \def@c{renew\expandafter\@gobble\string#1}##1##2{% \@mlist@warnfalse - \@ifnextchar[%] - {\csname @new\string#1@opt\endcsname{##1}{##2}} - {\csname @new\string#1@noopt\endcsname{##1}{##2}}}% + \@optarg{\csname @new\string#1@opt\endcsname{##1}{##2}}}% \def@c{@new\string#1@opt}##1##2[##3]{% \csname @new\string#1\endcsname{##1}{##2}{##3}}% - \def@c{@new\string#1@noopt}##1##2{% - \csname @new\string#1\endcsname{##1}{##2}{}}% \def@c{@new\string#1}##1##2##3{% \if@mlist@warn \ifdefined##1 @@ -1227,6 +1248,10 @@ Distributed under the LaTeX Project Public License % \testtwo{1,2,3} % \end{example} % +% \begin{macrocode} +\InputIfFileExists{mlist.cfg}{} + {\PackageWarning{mlist}{No configuration file (mlist.cfg) found nor loaded}} +% \end{macrocode} % %\iffalse %</package> @@ -1258,7 +1283,7 @@ Distributed under the LaTeX Project Public License {\endlist} \usepackage[svgnames]{xcolor} -\usepackage{amsmath,array,bm,booktabs,calc,enumitem,fancyvrb,graphicx,ifthen,longtable,refstyle,subfig,topcapt,varioref,\jobname} +\usepackage{amsmath,array,bm,booktabs,calc,enumitem,fancyvrb,graphicx,ifthen,longtable,refstyle,subfig,topcapt,varioref,mlist} \usepackage{easyvector,vector,tensind} \usepackage{url} @@ -1317,8 +1342,8 @@ Distributed under the LaTeX Project Public License \end{minipage} \end{list} \par\noindent\hrulefill - \end{minipage} - \smallskip} + \end{minipage}\par + \smallskip\noindent} \newcommand*\setverbwidth[1]{\def\auxwidth{#1}} @@ -1372,8 +1397,7 @@ Distributed under the LaTeX Project Public License % \typeout{* To finish the installation you have to move the following} % \typeout{* file into a directory searched by XeTeX:} % \typeout{*} -% \typeout{* \space\space\space unicode-math.sty} -% \typeout{* \space\space\space unicode-math.tex} +% \typeout{* \space\space\space mlist.sty} % \typeout{*} % \typeout{*************************************************************} % |