| 1 |
% \iffalse |
| 2 |
%<*internal> |
| 3 |
\iffalse |
| 4 |
%</internal> |
| 5 |
%<*readme> |
| 6 |
_________________ |
| 7 |
The MLIST package |
| 8 |
v0.6a |
| 9 |
|
| 10 |
This package defines the commands \newvect, \newmatr, \newfunc, |
| 11 |
and \newmset for creating macros to typeset vectors, matrices, |
| 12 |
functions, and sets. For example, Logical indexing can then be |
| 13 |
used to refer to elements or arguments without hard-coding the |
| 14 |
symbols in the document: |
| 15 |
|
| 16 |
\newvect\myvect{V}[elem=a,b,c] |
| 17 |
\myvect{1,2,3} |
| 18 |
|
| 19 |
produces |
| 20 |
|
| 21 |
\left( V_a, V_b, V_c \right) |
| 22 |
|
| 23 |
All aspects of the typeset appearance can be adjusted, and new |
| 24 |
`mlists' can be defined to represent other mathematical constructs. |
| 25 |
|
| 26 |
Consider this package an exploration of separation of form and content |
| 27 |
for some mathematical constructions. I hope you find it useful. |
| 28 |
|
| 29 |
________________________ |
| 30 |
History of major changes |
| 31 |
|
| 32 |
v0.6: Added the headhook option to accomodate accents to |
| 33 |
the head symbol. Perhaps a little experimental. |
| 34 |
|
| 35 |
v0.5: Introduced \newmset for defining mathematical sets; |
| 36 |
with pre-defined sets \setR, \setC, \setZ, \setN. |
| 37 |
|
| 38 |
______________ |
| 39 |
Will Robertson |
| 40 |
wspr 81 [at] gmail [dot] com |
| 41 |
|
| 42 |
Copyright 2007-2008 |
| 43 |
Distributed under the LaTeX Project Public License |
| 44 |
%</readme> |
| 45 |
%<*internal> |
| 46 |
\fi |
| 47 |
\begingroup |
| 48 |
%</internal> |
| 49 |
%<*batchfile> |
| 50 |
\input docstrip.tex |
| 51 |
\keepsilent |
| 52 |
\preamble |
| 53 |
|
| 54 |
__________________________________ |
| 55 |
Copyright (C) 2007 Will Robertson |
| 56 |
|
| 57 |
License information appended. |
| 58 |
|
| 59 |
|
| 60 |
\endpreamble |
| 61 |
\postamble |
| 62 |
|
| 63 |
Copyright (C) 2007 by Will Robertson <[email protected]> |
| 64 |
|
| 65 |
Distributable under the LaTeX Project Public License, |
| 66 |
version 1.3c or higher (your choice). The latest version of |
| 67 |
this license is at: http://www.latex-project.org/lppl.txt |
| 68 |
|
| 69 |
This work is "maintained" (as per LPPL maintenance status) |
| 70 |
by Will Robertson. |
| 71 |
|
| 72 |
This work consists of the file mlist.dtx |
| 73 |
and the derived files mlist.pdf, |
| 74 |
mlist.sty, |
| 75 |
mlist.cfg, and |
| 76 |
mlist.ins. |
| 77 |
|
| 78 |
\endpostamble |
| 79 |
\askforoverwritefalse |
| 80 |
\generate{\file{\jobname.sty}{\from{\jobname.dtx}{package}}} |
| 81 |
\generate{\file{\jobname.cfg}{\from{\jobname.dtx}{defaults}}} |
| 82 |
%</batchfile> |
| 83 |
%<batchfile>\endbatchfile |
| 84 |
%<*internal> |
| 85 |
\generate{\file{\jobname.ins}{\from{\jobname.dtx}{batchfile}}} |
| 86 |
\nopreamble\nopostamble |
| 87 |
\generate{\file{README.txt}{\from{\jobname.dtx}{readme}}} |
| 88 |
\generate{\file{dtx-style.sty}{\from{\jobname.dtx}{dtx-style}}} |
| 89 |
\endgroup |
| 90 |
\immediate\write18{makeindex -s gind.ist -o \jobname.ind \jobname.idx} |
| 91 |
\immediate\write18{makeindex -s gglo.ist -o \jobname.gls \jobname.glo} |
| 92 |
%</internal> |
| 93 |
% |
| 94 |
%<*driver> |
| 95 |
\documentclass{ltxdoc} |
| 96 |
\EnableCrossrefs |
| 97 |
\CodelineIndex |
| 98 |
\RecordChanges |
| 99 |
%\OnlyDescription |
| 100 |
\usepackage{dtx-style} |
| 101 |
\begin{document} |
| 102 |
\DocInput{\jobname.dtx} |
| 103 |
\end{document} |
| 104 |
%</driver> |
| 105 |
% |
| 106 |
% |
| 107 |
% \fi |
| 108 |
% |
| 109 |
% \GetFileInfo{\jobname.sty} |
| 110 |
% \CheckSum{0} |
| 111 |
% \makeatletter |
| 112 |
% |
| 113 |
% \title{Logical markup for mathematical lists} |
| 114 |
% \author{Will Robertson} |
| 115 |
% \date{\filedate \qquad \fileversion} |
| 116 |
% |
| 117 |
% \maketitle |
| 118 |
% |
| 119 |
% \tableofcontents |
| 120 |
% \clearpage |
| 121 |
% |
| 122 |
% \section{Introduction} |
| 123 |
% |
| 124 |
% One of \LaTeX's lauded features is its separation of form and |
| 125 |
% content. When writing a document, they say, you can just focus on |
| 126 |
% the words. Well, that may be well and good for prose, but |
| 127 |
% mathematicians have frequently been left out in the cold. A funny |
| 128 |
% situation, considering \LaTeX's main audience. |
| 129 |
% |
| 130 |
% Recently, the \pkg{cool} package appeared, marking the first |
| 131 |
% large-scale format-independent method of writing maths in |
| 132 |
% \LaTeX. Need to change the brackets surrounding the arguments of |
| 133 |
% \cmd\sin\ and \cmd\cos, or switch from $\tan^{-1}$ to $\arctan$ |
| 134 |
% throughout an entire document? No worries. |
| 135 |
% |
| 136 |
% This sort of initiative will allow much easier transfer of |
| 137 |
% mathematics from such software packages as Mathematica and Matlab, |
| 138 |
% if it becomes popular enough. |
| 139 |
% |
| 140 |
% This package, \pkg{\jobname}, provides a method to write various |
| 141 |
% sorts of mathematical lists without having to worry about |
| 142 |
% formatting. When I say `lists', I mean things like |
| 143 |
% $\vect{A}=\vect{A}{1,2,3}$; to me as a mechanical engineer, vectors |
| 144 |
% and matrices; but the package is more general than that, I hope. |
| 145 |
% |
| 146 |
% You can use \pkg{\jobname} straight away with |
| 147 |
% \codeline \cmd\usepackage\texttt{\char`\{\jobname\char`\}}\\ |
| 148 |
% and |
| 149 |
% \codeline |$\vect{A}=\vect{A}{1,2,3}$|\\ |
| 150 |
% to get the example in the previous paragraph, but \emph{please} |
| 151 |
% keep reading to learn its more useful features. |
| 152 |
% |
| 153 |
% \section{Basic Functionality}\seclabel{vect} |
| 154 |
% |
| 155 |
% \subsection{Prototypical example: vector notation} |
| 156 |
% |
| 157 |
% \DescribeMacro{\newvect} |
| 158 |
% This example demonstrates why I wrote this package. The control |
| 159 |
% sequence \cmd\dist\ is defined as a vector with any number of elements. The |
| 160 |
% vector and its elements can be subsequently referred to without |
| 161 |
% hard-coding any of the mathematical symbols or brackets used. |
| 162 |
% \begin{example}{} |
| 163 |
% \newvect\dist{D}[elem={r,\phi,\theta}] |
| 164 |
% \[ \dist \qquad \dist{2} |
| 165 |
% \qquad \dist{1,2,3} \] |
| 166 |
% \end{example} |
| 167 |
% |
| 168 |
% \subsection{Matrix notation} |
| 169 |
% |
| 170 |
% The basic idea of this package is to separate the formatting and |
| 171 |
% content of mathematical objects. The above example showed vector |
| 172 |
% notation, and there are three more `data structures' that are defined |
| 173 |
% `out of the box'. |
| 174 |
% |
| 175 |
% \DescribeMacro{\newmatr} The second example is for matrices, which |
| 176 |
% one might consider quite similar to vectors; but by default the |
| 177 |
% formatting internally uses \pkg{amsmath}'s |{bmatrix}| |
| 178 |
% environment. Note that it's a very good idea to give your maths |
| 179 |
% objects actual \emph{names} rather than shorthands like |\M|---who |
| 180 |
% knows if you'll still be calling it `M' in ten years time? |
| 181 |
% \begin{example}{} |
| 182 |
% \newmatr\massm{M}[elem={m,0;0,m+M}] |
| 183 |
% \[ \massm \qquad \massm{4} |
| 184 |
% \qquad \massm{1,2;3,4} \] |
| 185 |
% \end{example} |
| 186 |
% |
| 187 |
% Again, it is possible then to change the brackets used for matrices |
| 188 |
% throughout an entire document (or collection of documents) without |
| 189 |
% changing the fundamental markup of the mathematics itself. |
| 190 |
% |
| 191 |
% \subsection{Function and `set' notation} |
| 192 |
% |
| 193 |
% \DescribeMacro{\newfunc} Finally, here's something a little |
| 194 |
% different. Vector and matrices are both quite similar. But it takes |
| 195 |
% only a slight stretch to extend the syntax of this package to things |
| 196 |
% completely different---such as functions:\label{func-example} |
| 197 |
% \begin{example}{} |
| 198 |
% \newfunc\traj{T}[elem={x_0;x,t},index={1;2,3}] |
| 199 |
% \[ \traj \qquad \traj{2} \qquad \traj{2,3} \] |
| 200 |
% \end{example} |
| 201 |
% |
| 202 |
% For example, Mathematica users may wish to typeset their arguments |
| 203 |
% with square brackets in their own documents but not for published |
| 204 |
% papers. To hammer home the point: this can be now done for an entire |
| 205 |
% document with a simple switch. |
| 206 |
% |
| 207 |
% \DescribeMacro{\newmset} Here's an example to further |
| 208 |
% demonstrate the flexibility of the package. |
| 209 |
% \begin{example}{} |
| 210 |
% \newmset\setT{T} |
| 211 |
% \[ \setT \qquad \setT{2} \qquad \setT{2,3} \] |
| 212 |
% \end{example} |
| 213 |
% The \cmd\setR, \cmd\setC, \cmd\setN, and \cmd\setZ\ `msets' are defined |
| 214 |
% by default for real, complex, natural, and integer numbers. |
| 215 |
% \begin{example}{} |
| 216 |
% \[ \bm{x}\in\setR{2,2} \] |
| 217 |
% \end{example} |
| 218 |
% |
| 219 |
% \subsection{Non-specific commands} |
| 220 |
% Sometimes you don't always want to define new macros for one-off |
| 221 |
% maths expressions. Accompanying the \cmd\newvect, \cmd\newmatr, |
| 222 |
% \cmd\newfunc, and \cmd\newmset\ macros are \cmd\vect, \cmd\matr, \cmd\func, |
| 223 |
% and \cmd\mset, which can be used for single cases: |
| 224 |
% \begin{example}{} |
| 225 |
% \[ \vect{V}{a,b,c} \quad |
| 226 |
% \matr{M}{a,b;c,d} \quad |
| 227 |
% \func{f}{x_0;x,t} \quad |
| 228 |
% \mset{D}{m,n} \] |
| 229 |
% \end{example} |
| 230 |
% This usage is generally not recommended except in isolated cases. |
| 231 |
% |
| 232 |
% \subsection{An example of some actual maths} |
| 233 |
% |
| 234 |
% Here's a practical example using \cmd\matr\ that I think demonstrates |
| 235 |
% well the advantages of using this package: |
| 236 |
% \begin{example}{} |
| 237 |
% \newmatr\state{x} |
| 238 |
% [elem={x_1;\dot x_1},index={1;2}] |
| 239 |
% \newmatr\dyn{A} |
| 240 |
% [elem={0,1;-K/M,-C/M}, |
| 241 |
% index={1,2;3,4}] |
| 242 |
% \[ \dot{\state{}} = \dyn{}\state{} \] |
| 243 |
% \[ \state{} = \state \] |
| 244 |
% \[ \dyn{} = \dyn \] |
| 245 |
% \[ \frac\partial{\partial t} |
| 246 |
% \state = \dyn \state \] |
| 247 |
% \end{example} |
| 248 |
% There's a lot more semantic meaning in that mathematical \TeX\ source than if it were hard-coded without this package. |
| 249 |
% |
| 250 |
% \subsection{Elements and indexing}\seclabel{indexing} |
| 251 |
% |
| 252 |
% For context for the following explanations, here's our first example again: |
| 253 |
% \begin{example}{} |
| 254 |
% \newvect\dist{D}[elem={r,\phi,\theta}] |
| 255 |
% \[ \dist \qquad \dist{2} \qquad \dist{1,2,3} \] |
| 256 |
% \end{example} |
| 257 |
% \newvect\dist{D}[elem={r,\phi,\theta}] |
| 258 |
% |
| 259 |
% Each command created like \cmd\dist\ takes zero or one arguments, as shown |
| 260 |
% above. Unlike regular \LaTeX\ commands with optional arguments, these still |
| 261 |
% use curly braces, and an empty argument is equivalent (by default) to omitting the argument altogether: |
| 262 |
% \codeline |\dist{}|~$\to~\dist{}$\quad$\equiv$\quad|\dist|~$\to~\dist$ . |
| 263 |
% |
| 264 |
% While numerical indexing is used to extract \opt{elem} items from |
| 265 |
% the list, \emph{any} argument can be used instead that is passed |
| 266 |
% through directly: |
| 267 |
% \codeline |\dist{x^2}|~$\to~\dist{x^2}$ . |
| 268 |
% |
| 269 |
% As we saw for the matrix examples, the input may actually be |
| 270 |
% `two-dimensional'; as well as being comma-separated, elements (and |
| 271 |
% sets of elements) may also be separated by semi-colons: |
| 272 |
% \codeline |\dist{x;y;z}|~$\to~\dist{x;y;z}$ . |
| 273 |
% |
| 274 |
% Input elements can also be specified with semi-colon separators to |
| 275 |
% match up with two-dimensional element indexing. There are two ways |
| 276 |
% to reference these elements: with a linear index from one to the |
| 277 |
% number of elements in |elem|; or with `implicit indexing' that |
| 278 |
% starts from one for every semi-colon list. Implicit indices are |
| 279 |
% prefix with the |@| symbol.\footnote{The implicit indexing syntax |
| 280 |
% will work \emph{even if} \cmd\makeatletter\ is in effect.} An |
| 281 |
% example is useful to show how this works: |
| 282 |
% \begin{example}{} |
| 283 |
% \newvect\V{V}[elem={a,b,c;x,y,z}] |
| 284 |
% \[ \V=\V{1,2,3;4,5,6} \] |
| 285 |
% \[ \V=\V{4,5,6} \] |
| 286 |
% \[ \V=\V{1,2,3;@1,@2,@3} \] |
| 287 |
% \end{example} |
| 288 |
% See \tabref{index-syntax} for a more detailed example of the indexing system. |
| 289 |
% |
| 290 |
% \begin{table} |
| 291 |
% \topcaption{How two-dimension lists elements are indexed. The first row shows the input list via \opt{elem=\{\}}. The second and third rows respectively show the direct index and implicit index required to reference the elements of the list.} |
| 292 |
% \tablabel{index-syntax} |
| 293 |
% \centering |
| 294 |
% \begin{tabular}{@{}l@{\quad\{~}c@{~,~}c@{~,~}c@{~;~}c@{~,~}c@{~;~}c@{~\}}} |
| 295 |
% \toprule |
| 296 |
% List & a & b & c & d & e & f \\ |
| 297 |
% Direct index & 1 & 2 & 3 & 4 & 5 & 6 \\ |
| 298 |
% Implicit index & @1 & @2 & @3 & @1 & @2 & @1 \\ |
| 299 |
% \bottomrule |
| 300 |
% \end{tabular} |
| 301 |
% \end{table} |
| 302 |
% |
| 303 |
% You can also set the default element list when defining a vector. In this case, an empty list argument is not equivalent to omitting one: |
| 304 |
% \begin{example}{} |
| 305 |
% \newvect\LL{L}[elem={i,j,k},index={1,2,3}] |
| 306 |
% $\LL$ \quad vs.\quad $\LL{}$ |
| 307 |
% \quad vs.\quad $\LL{1,2} $ |
| 308 |
% \end{example} |
| 309 |
% This was shown originally in the function example on page~\pageref{func-example}. |
| 310 |
% |
| 311 |
% \subsection{Shorthand indices and empty elements} |
| 312 |
% |
| 313 |
% Shorthands are defined to allow things that |
| 314 |
% \emph{aren't} elements into the list. |
| 315 |
% In this example, the semi-colon separation is shown with the |
| 316 |
% \cmd\dots\ shorthand `|:|' and the \cmd\cdot\ shorthand `|.|'. |
| 317 |
% \begin{example}{} |
| 318 |
% \newvect\mm{M} |
| 319 |
% \[ \mm=\mm{1,2,:,5;a,b,.,d} \] |
| 320 |
% \end{example} |
| 321 |
% |
| 322 |
% More shorthands will be defined in the future via |
| 323 |
% an extensible mechanism that does not yet exist. |
| 324 |
% |
| 325 |
% Empty arguments are ignored (where `empty' $\equiv$ empty or whitespace). |
| 326 |
% \begin{example}{} |
| 327 |
% \newvect\nset{N} |
| 328 |
% \[ \nset=\nset{1,,,3, ,5;;,2,;} \] |
| 329 |
% \end{example} |
| 330 |
% |
| 331 |
% \subsection{\cmd\dots} |
| 332 |
% |
| 333 |
% Finally, some macros are defined in order to be able to typeset |
| 334 |
% unknown ranges ($1,2,\dots,N$) without hard-coding the symbol of the |
| 335 |
% maximum element. Similarly, it is also useful to denote a |
| 336 |
% `mid-range' element somewhere inside the ellipses. Note the equivalence in defining the mid and last elements and indexing them. |
| 337 |
% \begin{example}{} |
| 338 |
% \newvect\W{W}[elem={i,j,k,:,w}] |
| 339 |
% \newvect\Y{Y}[elem={i,j,k,:,p,:,y}] |
| 340 |
% \[ \W=\W{1,2,:,\LAST-1,\LAST} \] |
| 341 |
% \[ \Y=\Y{1,2,:,\MID,:,\LAST} \] |
| 342 |
% \end{example} |
| 343 |
% |
| 344 |
% \noindent The \cmd\MID\ and \cmd\LAST\ control sequences are `implicit' for two dimensional lists: |
| 345 |
% |
| 346 |
% \begin{example}{} |
| 347 |
% \newvect\X{X}[% |
| 348 |
% elem={i,j,k,:,m,:,w;ii,jj,kk,:,mm,:,ww}] |
| 349 |
% \[ \X{1,:,\MID,:,\LAST;@1,:,\MID,:,\LAST} \] |
| 350 |
% \[ \X{1,2,3;4,5,6} \] |
| 351 |
% \end{example} |
| 352 |
% |
| 353 |
% Finally, note well above that any |{:,X}| pairs for mid/last element definitions do \emph{not} add to the direct index numbering. |
| 354 |
% |
| 355 |
% |
| 356 |
% \section{Generalisation} |
| 357 |
% |
| 358 |
% \DescribeMacro{\newmlist} |
| 359 |
% \DescribeMacro{\renewmlist} |
| 360 |
% The \cmd\newvect\ command that has been |
| 361 |
% often shown previously is an example of a macro created with |
| 362 |
% \cmd\newmlist, which can be considered something like an |
| 363 |
% \emph{instance generator} for the types of lists we're dealing with. |
| 364 |
% Use \cmd\renewmlist\ if the command is already in use. |
| 365 |
% |
| 366 |
% \cmd\newmlist\cs{<list>}\oarg{list options} creates macros |
| 367 |
% \cs{<list>} and \cs{new<list>} (and \cs{renew<list>}) that are |
| 368 |
% analogous to \cmd\vect\ and \cmd\newvect\ seen in |
| 369 |
% \secref{vect}. \meta{list options} can contain any of those seen so |
| 370 |
% far in previous \cmd\newvect\ macros, plus more to be introduced |
| 371 |
% soon. |
| 372 |
% |
| 373 |
% In the examples to follow, \cmd\vect\ and \cmd\newvect\ are often |
| 374 |
% still used to demonstrate various options, overriding the defaults. |
| 375 |
% |
| 376 |
% \subsection{Head and element formatting} |
| 377 |
% |
| 378 |
% The \opt{headcmd} and \opt{elemcmd} options are used to alter the |
| 379 |
% formatting of the vector symbol and its elements. They are passed |
| 380 |
% \emph{macros} that take, respectively, one and two arguments that |
| 381 |
% define the formatting. |
| 382 |
% |
| 383 |
% For \cmd\vect, |headcmd=\mathbf| and |elemcmd=\mlistsub|, where |
| 384 |
% \codeline \cmd\mlistsub |{#1}{#2}|~$\to$~|#1_{#2}|.\\ |
| 385 |
% \cmd \mlistsup, the |
| 386 |
% analogous command for creating superscripts, is defined by the |
| 387 |
% package in case you need it. |
| 388 |
% |
| 389 |
% In this example, the vector symbol is formatted with an arrow accent, |
| 390 |
% and the elements are exactly as specified in \opt{elem}. |
| 391 |
% \begin{example}{} |
| 392 |
% \newvect\A{A}[% |
| 393 |
% headcmd=\vec, |
| 394 |
% elemcmd=\mlistelem, |
| 395 |
% elem={a,b,c,d}] |
| 396 |
% |
| 397 |
% \[\A \qquad \A{1,2,3,4} \qquad \A{3} \] |
| 398 |
% \end{example} |
| 399 |
% |
| 400 |
% The \cmd\mlistelem\ command (with its friend, \cmd\mlisthead) is defined as follows: |
| 401 |
% \codeline\cmd\mlistelem|{#1}{#2}|~$\to$~|#2| |
| 402 |
% \codeline\cmd\mlisthead|{#1}|~$\to$~|#1| |
| 403 |
% |
| 404 |
% In \secref{indexing}, we saw that list indexing doesn't \emph{have} |
| 405 |
% to be numerical. In this example, the use of \cmd\@alph\ allows |
| 406 |
% alphabetic subscripts but non-numeric indices will produce errors: |
| 407 |
% \begin{example}{} |
| 408 |
% \makeatletter |
| 409 |
% \newcommand\subalph[2]{#1_{\@alph{#2}}} |
| 410 |
% \makeatother |
| 411 |
% \newvect\A{A}[% |
| 412 |
% elemcmd=\subalph] |
| 413 |
% |
| 414 |
% \[ \A{1,2,3,4} \qquad \A{3} \] |
| 415 |
% \end{example} |
| 416 |
% |
| 417 |
% \subsection{Head prefixing} |
| 418 |
% |
| 419 |
% Applying (things like) accents to \pkg{mlist}s will often give the wrong result: |
| 420 |
% \begin{example}{} |
| 421 |
% \newfunc\A{A} |
| 422 |
% $\A{1}$ \qquad $\bar{\A{1}}$ |
| 423 |
% \end{example} |
| 424 |
% |
| 425 |
% The solution for this involves defining a prefix for the head element with the |headhook| option: |
| 426 |
% \begin{example}{} |
| 427 |
% \newfunc\A{A} |
| 428 |
% \newcommand\baraccent[1]{% |
| 429 |
% {\mlistsetup{headhook=\bar}#1}} |
| 430 |
% $\A{1}$ \qquad $\baraccent{\A{1}}$ |
| 431 |
% \end{example} |
| 432 |
% |
| 433 |
% This method can also be used to apply \emph{post}fix elements as well: |
| 434 |
% \begin{example}{} |
| 435 |
% \newfunc\A{A} |
| 436 |
% \newcommand\postprime[1]{#1'} |
| 437 |
% \newcommand\primeaccent[1]{% |
| 438 |
% {\mlistsetup{headhook=\postprime}#1}} |
| 439 |
% $\A{1}$ \qquad $\A{1}'$ \qquad $\primeaccent{\A{1}}$ |
| 440 |
% \end{example} |
| 441 |
% |
| 442 |
% The user interface for these features is rather rough and needs more thought; it might be better if \cmd\mlistsetup\ did not need to be called in the accent definition. |
| 443 |
% |
| 444 |
% For these reasons the |headhook| feature should be considered a little experimental and possibly subject to change in the future. It should certainly be accompanied by a variety of `\cmd\baraccent'--like commands, unless \cmd\bar\ can be patched to recognise such situations automatically (this seems unlikely). |
| 445 |
% |
| 446 |
% \subsection{Delimiter formatting} |
| 447 |
% |
| 448 |
% The \opt{wrap} and \opt{wrapone} options are used to change the way |
| 449 |
% elements are displayed together. Each take two |
| 450 |
% arguments to define the opening and closing material. |
| 451 |
% |
| 452 |
% By default, if there is more than one element, it is surrounded by |
| 453 |
% square brackets: |wrap=[]|. A single element is typeset naked: |
| 454 |
% |wrapone={}{}|. If \opt{wrapone} is called with no `|=|' argument, it |
| 455 |
% takes the same value as \opt{wrap}. |
| 456 |
% |
| 457 |
% In this example, the brackets around the sets are changed to |
| 458 |
% parentheses, including single elements. The behaviour for a single |
| 459 |
% element is then changed to use angle brackets: |
| 460 |
% \begin{example}{firstline=2} |
| 461 |
% \parskip1ex |
| 462 |
% \newvect\Q{Q} |
| 463 |
% $\Q + \Q{1} + \Q{a,b}$ |
| 464 |
% |
| 465 |
% \newvect\QQ{Q}[wrap=(),wrapone] |
| 466 |
% $\QQ + \QQ{1} + \QQ{a,b}$ |
| 467 |
% |
| 468 |
% \newvect\QQQ{Q}[wrapone={\left<}{\right>}] |
| 469 |
% $\QQQ + \QQQ{1} + \QQQ{a,b}$ |
| 470 |
% \end{example} |
| 471 |
% |
| 472 |
% Rather than defining the open/close material around a set of |
| 473 |
% elements, it can often be necessary to define a macro that defines |
| 474 |
% the formatting of the set. The \opt{wrapcmd} and \opt{wraponecmd} |
| 475 |
% options are used for this purpose, and take as argument a single |
| 476 |
% macro that accepts two arguments: the list head and the |
| 477 |
% list elements, respectively. |
| 478 |
% |
| 479 |
% \begin{example}{firstline=2} |
| 480 |
% \parskip1ex |
| 481 |
% \newvect\R{R} |
| 482 |
% $\R + \R{1} + \R{a,b}$ |
| 483 |
% |
| 484 |
% \newcommand\mywrap[2]{\langle{\color{red}#2}\rangle_{#1}} |
| 485 |
% \newvect\RR{R}[wrapcmd=\mywrap,wraponecmd] |
| 486 |
% $\RR + \RR{1} + \RR{a,b}$ |
| 487 |
% |
| 488 |
% \newcommand\mywrapone[2]{\{{\color{green}#2}\}^{#1}} |
| 489 |
% \newvect\RRR{R}[ |
| 490 |
% wrapcmd=\mywrap, |
| 491 |
% wraponecmd=\mywrapone] |
| 492 |
% $\RRR + \RRR{1} + \RRR{a,b}$ |
| 493 |
% \end{example} |
| 494 |
% |
| 495 |
% \pkg{mlist} provides some example commands for this purpose:\par\nobreak\noindent |
| 496 |
% \begingroup\ttfamily |
| 497 |
% \def\mean#1{\string#1 & \expandafter\parse@meaning\meaning#1\@nil} |
| 498 |
% \def\parse@meaning #1:#2->#3\@nil{\detokenize{#3}\\} |
| 499 |
% \begin{tabular}{l@{$~\to~$}l} |
| 500 |
% \mean\mlistnowrap |
| 501 |
% \mean\mlistparen |
| 502 |
% \mean\mlistbrack |
| 503 |
% \mean\mlistbrace |
| 504 |
% \mean\mlistangle |
| 505 |
% \mean\mlistheadparen |
| 506 |
% \mean\mlistheadbrack |
| 507 |
% \mean\mlistheadbrace |
| 508 |
% \mean\mlistheadangle |
| 509 |
% \end{tabular} |
| 510 |
% \endgroup |
| 511 |
% |
| 512 |
% \subsection{Separator formatting} |
| 513 |
% |
| 514 |
% The \opt{sep} and \opt{sepsep} options take one argument that is inserted between items in comma and semi-colon lists, respectively. For example, in the \cmd\matr\ list these are defined with |[sep=&, sepsep=\\]|. |
| 515 |
% |
| 516 |
% Here's another example: |
| 517 |
% \begin{example}{} |
| 518 |
% \newvect\mysum{S}[ |
| 519 |
% sep=+, |
| 520 |
% wrap={}{}, |
| 521 |
% dots=\cdots] |
| 522 |
% $\mysum{a,b,c,d,:,p,q,r,s,:,x,y,z}$ |
| 523 |
% \end{example} |
| 524 |
% |
| 525 |
% \subsection{Global options definition} |
| 526 |
% |
| 527 |
% \DescribeMacro{\mlistsetup} If options aren't specified in |
| 528 |
% \cmd\newmlist\ they are inherited from the global defaults, which |
| 529 |
% may be adjusted with \cmd\mlistsetup\marg{mlist options}. The defaults |
| 530 |
% are shown in \secref[vref]{defaults}. |
| 531 |
% |
| 532 |
% \subsection{Redefining \cmd\vect, \cmd\matr, \cmd\func, \cmd\mset} |
| 533 |
% |
| 534 |
% This package makes little claim for being imminently usable for most |
| 535 |
% people \emph{out of the box}. I figure there's just too much |
| 536 |
% variety; people need to define their own `mlists' with \cmd\newmlist. |
| 537 |
% |
| 538 |
% If changes to the mlists provided by default with this package |
| 539 |
% are required (as they will be if any aspect of their formatting needs |
| 540 |
% to be adjusted), simply create a local |mlist.cfg| file with different |
| 541 |
% defintions or even just copy them from \secref[vref]{defaults} |
| 542 |
% in a \cmd\renewmlist. |
| 543 |
% |
| 544 |
% \section{TODO} |
| 545 |
% \begin{itemize} |
| 546 |
% \item changing features of (or adding features to, rather) `newvect' |
| 547 |
% constructions, rather than overwriting them. |
| 548 |
% \item generalise escaping strings like |:|$\to$|\dots|, etc. |
| 549 |
% \item accents and appended/prepended material migrating inside the |
| 550 |
% head (and/or each element) argument. |
| 551 |
% \item optional arguments for \cmd\MID\ and \cmd\LAST\ (for explicit indexing). |
| 552 |
% \item coercing one type of list into another |
| 553 |
% (and retrieving non-wrapped lists as a special case) |
| 554 |
% \item use ltx3! |
| 555 |
% \end{itemize} |
| 556 |
% |
| 557 |
%\iffalse |
| 558 |
%<*defaults> |
| 559 |
%\fi |
| 560 |
% |
| 561 |
% \section{The default definitions} |
| 562 |
% \seclabel{defaults} |
| 563 |
% |
| 564 |
% This is the code that appears in the default configuration file \pkg{mlist.cfg} to set up the |
| 565 |
% 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. |
| 566 |
% |
| 567 |
% \subsection{Global options} |
| 568 |
% These are inherited by mlists that do not explicitly define their own respective |
| 569 |
% options. Geared towards \cmd\vect, essentially. |
| 570 |
% \begin{macrocode} |
| 571 |
\mlistsetup{% |
| 572 |
sep={,}, |
| 573 |
sepsep={;}, |
| 574 |
wrapcmd=\mlistparen, |
| 575 |
wrapone={}{}, |
| 576 |
dots=\dots, |
| 577 |
dot={\,\cdot\,}, |
| 578 |
elemcmd=\mlistelem, |
| 579 |
headcmd=\mathbf, |
| 580 |
index={}, |
| 581 |
headhook={}, |
| 582 |
} |
| 583 |
% \end{macrocode} |
| 584 |
% |
| 585 |
% \subsection{Provided mlists} |
| 586 |
% |
| 587 |
% Redefine these with \cmd\renewmlist\ to effect your own formatting |
| 588 |
% of these mlists. Note that these assume certain global defaults (see |
| 589 |
% above), so some aspects of their formatting can be changed with |
| 590 |
% \cmd\mlistsetup. |
| 591 |
% |
| 592 |
% \begin{macro}{\vect} |
| 593 |
% By default |\vect{V}=\vect{V}{a,b,c}| $\to$ $\vect{V}=\vect{V}{a,b,c}$. |
| 594 |
% \begin{macrocode} |
| 595 |
\newmlist\vect[ |
| 596 |
wrapcmd=\mlistparen, |
| 597 |
wraponecmd=\mlistnowrap, |
| 598 |
elemcmd=\mlistsub, |
| 599 |
headcmd=\mathbf, |
| 600 |
] |
| 601 |
% \end{macrocode} |
| 602 |
% \end{macro} |
| 603 |
% |
| 604 |
% \begin{macro}{\matr} |
| 605 |
% By default |\matr{M}=\matr{M}{a,b;c,d}| $\to$ $\matr{M}=\matr{M}{a,b;c,d}$. |
| 606 |
% \begin{macrocode} |
| 607 |
\newmlist\matr[ |
| 608 |
sep=&, |
| 609 |
sepsep=\\, |
| 610 |
wrap={\begin{bmatrix}} |
| 611 |
{\end{bmatrix}}, |
| 612 |
] |
| 613 |
% \end{macrocode} |
| 614 |
% \end{macro} |
| 615 |
% |
| 616 |
% \begin{macro}{\func} |
| 617 |
% By default, |\func{f}=\func{f}{x,y,z}| $\to$ $\func{f}=\func{f}{x,y,z}$. |
| 618 |
% \begin{macrocode} |
| 619 |
\newmlist\func[ |
| 620 |
headcmd=\mlisthead, |
| 621 |
wrapcmd=\mlistheadparen, |
| 622 |
wraponecmd, |
| 623 |
] |
| 624 |
% \end{macrocode} |
| 625 |
% \end{macro} |
| 626 |
% |
| 627 |
% \begin{macro}{\mset} |
| 628 |
% By default, |\mset{N}{2,3}| $\to$ $\mset{N}{2,3}$. |
| 629 |
% \begin{macrocode} |
| 630 |
\newmlist\mset[ |
| 631 |
headcmd=\mathbb, |
| 632 |
sep=\times, |
| 633 |
wrapcmd=\mlistsup, |
| 634 |
wraponecmd, |
| 635 |
] |
| 636 |
% \end{macrocode} |
| 637 |
% \changes{v0.5}{2007/06/06}{Added.} |
| 638 |
% \end{macro} |
| 639 |
% Sets for real, complex, natural, and integer numbers, respectively: |
| 640 |
% \begin{macrocode} |
| 641 |
\newmset\setR{R} |
| 642 |
\newmset\setC{C} |
| 643 |
\newmset\setN{N} |
| 644 |
\newmset\setZ{Z} |
| 645 |
% \end{macrocode} |
| 646 |
% |
| 647 |
%\iffalse |
| 648 |
%</defaults> |
| 649 |
%\fi |
| 650 |
% |
| 651 |
% \section{Prior art} |
| 652 |
% |
| 653 |
% With \CTAN\ getting so big these days, it's quite necessary to |
| 654 |
% undertake extensive literature reviews before writing your own |
| 655 |
% package. I've been burned before, spending a couple of days playing |
| 656 |
% with ideas and then realising that someone's already done what I wanted. |
| 657 |
% This time I looked before I jumped. |
| 658 |
% |
| 659 |
% \paragraph{easyvector} |
| 660 |
% The most similar package to this one (that I could find) is |
| 661 |
% \pkg{easyvector}. |
| 662 |
% \note{\url|http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=easyvector|} |
| 663 |
% Superficially, there are a number of similarities, but it didn't |
| 664 |
% quite do what I wanted. Here's an example demonstrating the creation |
| 665 |
% of new vector macros: |
| 666 |
% \begin{example}{} |
| 667 |
% \newvector[Z,\mathbf{Z}]{X} |
| 668 |
% \[ \X = (\X[i,j;k]) \qquad |
| 669 |
% \X[1,2,3] \neq \X![1,2,3] \] |
| 670 |
% \end{example} |
| 671 |
% |
| 672 |
% Note that each macro refers only to a single vector element. This is a package |
| 673 |
% to simplify input (and abstract formatting) of vectors with complex notation. |
| 674 |
% \pkg{easyvector} also allows you to customise the form of the |
| 675 |
% vectors it produces, but this is rather inflexible without a good |
| 676 |
% deal of work. |
| 677 |
% \begin{example}{} |
| 678 |
% \def\myindex[#1,#2,#3]{_{#1_{#2}}^{#3}} |
| 679 |
% \newcustomvector[\mathtt{b},\mathbf{b}]{bb}\myindex |
| 680 |
% \[ \bb \qquad \bb[1,2,3] \qquad \bb[3,2,1] \] |
| 681 |
% \end{example} |
| 682 |
% |
| 683 |
% Note also that the main symbol (`$\mathtt{b}$', here) is not |
| 684 |
% available even in this case, so prepended sub-/superscripts are not possible. |
| 685 |
% |
| 686 |
% Has the interesting option to reference matrix row/column sub-vectors: (careful to ensure \cmd\makeatother\ manually) |
| 687 |
% \makeatother |
| 688 |
% \begin{example}{} |
| 689 |
% \newvector(W)[wvec] |
| 690 |
% \[ \wvec = (\wvec[@,j]) \qquad \wvec[a,b;@] \] |
| 691 |
% \end{example} |
| 692 |
% \makeatletter |
| 693 |
% |
| 694 |
% I like this idea of `shorthand' symbols. |
| 695 |
% |
| 696 |
% \paragraph{\pkg{vector}} |
| 697 |
% The package \pkg{vector} |
| 698 |
% \note{\url|http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=vector|} |
| 699 |
% provides a few commands for setting vector and matrix symbols, shown in \tabref{vectorpkg}. |
| 700 |
% Just a few basic macros to simplify input, but not really to separate form and content. |
| 701 |
% |
| 702 |
% \pkg{vector} provided the inspiration to add |\dots| ideas to this package. It also highlights that |
| 703 |
% something specific should be done with accents in general and provide a content macro for unit vectors. |
| 704 |
% |
| 705 |
% \begin{table} |
| 706 |
% \centering |
| 707 |
% \begin{tabular}{@{}ccccccc@{}} |
| 708 |
% \toprule |
| 709 |
% |\bvec| & |\buvec| & |\svec| & |\suvec| & |\uvec| & |\uuvec| & |\irvec| \\ |
| 710 |
% \bvec{a} & \buvec{a} & \svec{a} & \suvec{a} & \uvec{a} & \uuvec{a} & \irvec{a} \\ |
| 711 |
% \bottomrule |
| 712 |
% \end{tabular} |
| 713 |
% \caption{Commands defined by the \pkg{vector} package. |
| 714 |
% \cmd\uvec\ and \cmd\uuvec\ can be configured to produce an under-tilde instead. |
| 715 |
% \cmd\irvec\ takes an optional argument for `$n$' and can be configured (globally) to begin from a different index.} |
| 716 |
% \label{tab:vectorpkg} |
| 717 |
% \end{table} |
| 718 |
% |
| 719 |
% \paragraph{hhtensor} |
| 720 |
% The hhtensor package |
| 721 |
% \note{\url|http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=hhtensor|} |
| 722 |
% provides a few content-based macros with global options to specify their appearance. |
| 723 |
% \cmd\vec, \cmd\matr\, and \cmd\tens\ are provided for vectors, matrices, and tensors, with |
| 724 |
% mathematical symbols \cmd\dcdot\ to denote double scalar products, and \cmd\trans\ for printing |
| 725 |
% an upright superscript `T' to denote the transpose operator. |
| 726 |
% |
| 727 |
% This package was the inspiration for pre-defined macros for specific meanings. |
| 728 |
% While I approve of defining the transpose symbol, it's outside the scope of \pkg\jobname. |
| 729 |
% |
| 730 |
% \paragraph{Other tensor packages} |
| 731 |
% There are three main packages for typesetting tensors. |
| 732 |
% These start to stray from the interest of \pkg\jobname. |
| 733 |
% The relevant packages are |
| 734 |
% \pkg{tensind}, |
| 735 |
% \note{\url|http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=tensind|} |
| 736 |
% \pkg{tensor}, |
| 737 |
% \note{\url|http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=tensor|} |
| 738 |
% and \pkg{mattens}. |
| 739 |
% \note{\url|http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=mattens|} |
| 740 |
% Each focuses on typesetting various forms of tensor notation, which differ from what |
| 741 |
% this package is trying to do. Integration between this package and those three above are possible, |
| 742 |
% but has not yet been investigated. |
| 743 |
% |
| 744 |
% |
| 745 |
% \StopEventually{} |
| 746 |
% |
| 747 |
% \clearpage |
| 748 |
% \part{\pkg{\jobname} implementation} |
| 749 |
%\iffalse |
| 750 |
%<*package> |
| 751 |
%\fi |
| 752 |
% |
| 753 |
% \section{Setup code} |
| 754 |
% This is the package. |
| 755 |
% |
| 756 |
% \begin{macrocode} |
| 757 |
\ProvidesPackage{mlist} |
| 758 |
[2008/08/15 v0.6a Typesetting maths lists] |
| 759 |
% \end{macrocode} |
| 760 |
% |
| 761 |
% \PrintChanges |
| 762 |
% \changes{v0.1}{27/04/2007}{Code tidy up; first decent version.} |
| 763 |
% \changes{v0.2}{30/04/2007}{More documentation; list indexing not finalised.} |
| 764 |
% \changes{v0.3}{2007/05/02}{List indexing decided; empty arguments ignored.} |
| 765 |
% \changes{v0.4}{2007/05/26}{Tidied things up a little bit.} |
| 766 |
% |
| 767 |
% \subsection{User shorthands} |
| 768 |
% |
| 769 |
% For |headcmd|: |
| 770 |
% \begin{macrocode} |
| 771 |
\let\mlisthead\@firstofone |
| 772 |
% \end{macrocode} |
| 773 |
% For |elemcmd|: |
| 774 |
% \begin{macrocode} |
| 775 |
\let\mlistelem\@secondoftwo |
| 776 |
\newcommand\mlistsub [2]{#1_{#2}} |
| 777 |
\newcommand\mlistsup [2]{#1^{#2}} |
| 778 |
% \end{macrocode} |
| 779 |
% For |wrapcmd|: |
| 780 |
% \begin{macrocode} |
| 781 |
\let\mlistnowrap\@secondoftwo |
| 782 |
\newcommand\mlistparen[2]{\left(#2\right)} |
| 783 |
\newcommand\mlistbrack[2]{\left[#2\right]} |
| 784 |
\newcommand\mlistbrace[2]{\left\{#2\right\}} |
| 785 |
\newcommand\mlistangle[2]{\left<#2\right>} |
| 786 |
\newcommand\mlistheadparen[2]{#1\left(#2\right)} |
| 787 |
\newcommand\mlistheadbrack[2]{#1\left[#2\right]} |
| 788 |
\newcommand\mlistheadbrace[2]{#1\left\{#2\right\}} |
| 789 |
\newcommand\mlistheadangle[2]{#1\left<#2\right>} |
| 790 |
% \end{macrocode} |
| 791 |
% |
| 792 |
% |
| 793 |
% |
| 794 |
% \subsection{Packages} |
| 795 |
% \begin{macrocode} |
| 796 |
\RequirePackage{xkeyval,ifmtarg} |
| 797 |
% \end{macrocode} |
| 798 |
% \subsection{Code we need} |
| 799 |
% Conditionals and counters and things: |
| 800 |
% \begin{macrocode} |
| 801 |
\newif\if@mlist@notfirst@ |
| 802 |
\newif\if@mlist@implicit@ |
| 803 |
\newcount\mlist@elem@N |
| 804 |
\def\@gobblenil#1\@nil{} |
| 805 |
% \end{macrocode} |
| 806 |
% Some specific things: |
| 807 |
% \begin{macrocode} |
| 808 |
\newif\if@mlist@warn |
| 809 |
% \end{macrocode} |
| 810 |
% Semi-colon delimited iteration (adapted from ltx2e). |
| 811 |
% \begin{macrocode} |
| 812 |
\long\def\@sfor#1:=#2\do#3{% |
| 813 |
\expandafter\def\expandafter\@sfortmp\expandafter{#2}% |
| 814 |
\ifx\@sfortmp\@empty\else |
| 815 |
\expandafter\@sforloop#2;\@nil;\@nil\@@#1{#3}% |
| 816 |
\fi} |
| 817 |
\long\def\@sforloop#1;#2;#3\@@#4#5{% |
| 818 |
\def#4{#1}% |
| 819 |
\ifx #4\@nnil \else |
| 820 |
#5% |
| 821 |
\def#4{#2}% |
| 822 |
\ifx #4\@nnil \else |
| 823 |
#5% |
| 824 |
\@siforloop #3\@@#4{#5}% |
| 825 |
\fi |
| 826 |
\fi} |
| 827 |
\long\def\@siforloop#1;#2\@@#3#4{% |
| 828 |
\def#3{#1}% |
| 829 |
\ifx #3\@nnil |
| 830 |
\expandafter\@fornoop |
| 831 |
\else |
| 832 |
#4\relax\expandafter\@siforloop |
| 833 |
\fi |
| 834 |
#2\@@#3{#4}} |
| 835 |
% \end{macrocode} |
| 836 |
% |
| 837 |
% ltx3-inspired syntax. \cmd\def@c\ still needs arguments to be supplied to it. |
| 838 |
% \begin{macrocode} |
| 839 |
\providecommand\let@cc[2]{% |
| 840 |
\expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname} |
| 841 |
\providecommand\def@c[1]{% |
| 842 |
\expandafter\def\csname#1\endcsname} |
| 843 |
\providecommand\def@co[2]{% |
| 844 |
\def@c{#1\expandafter}\expandafter{#2}} |
| 845 |
% \end{macrocode} |
| 846 |
% \begin{macro}{\mlist@optarg} |
| 847 |
% Macro to simplify optional argument parsing. |
| 848 |
% \begin{macrocode} |
| 849 |
\newcommand\mlist@optarg[1]{\@ifnextchar[{#1}{#1[]}}%] |
| 850 |
% \end{macrocode} |
| 851 |
% \changes{v0.4}{2007/05/26}{Implemented to simplify optional arg processing.} |
| 852 |
% \changes{v0.6a}{2008/08/15}{Renamed to avoid clashing with \pkg{breqn}'s command of the same name.} |
| 853 |
% \end{macro} |
| 854 |
% Shorthand to test for optional brace arguments: |
| 855 |
% \begin{macrocode} |
| 856 |
\newcommand\@ifnextbrace{\expandafter\@ifnextchar\bgroup} |
| 857 |
% \end{macrocode} |
| 858 |
% Shorthand string definitions for ifx tests: |
| 859 |
% \begin{macrocode} |
| 860 |
\def\mlist@colon{:} |
| 861 |
\def\mlist@period{.} |
| 862 |
% \end{macrocode} |
| 863 |
% This is for checking for |@| with an `other' catcode: |
| 864 |
% \begin{macrocode} |
| 865 |
\makeatother |
| 866 |
\expandafter\def\csname mlist@ampersat\endcsname{@} |
| 867 |
\makeatletter |
| 868 |
% \end{macrocode} |
| 869 |
% (`Ampersat' is a name for |@| I find amusing. That symbol doesn't seem to |
| 870 |
% have a definitive official name.) |
| 871 |
% |
| 872 |
% \section{keyval options} |
| 873 |
% |
| 874 |
% \begin{macro}{\mlistsetup} |
| 875 |
% \darg{keyval options} |
| 876 |
% User command to set global defaults for mlists. |
| 877 |
% \begin{macrocode} |
| 878 |
\newcommand\mlistsetup[1]{\setkeys[mlist]{sym}{#1}} |
| 879 |
% \end{macrocode} |
| 880 |
% \end{macro} |
| 881 |
% |
| 882 |
% \pkg{xkeyval} makes it easy for us to define a whole slew of options |
| 883 |
% that simply save their argument to a macro. |
| 884 |
% \begin{macrocode} |
| 885 |
\define@cmdkeys[mlist]{sym}[mlist@]{% |
| 886 |
symbol,index,sep,sepsep,elem, |
| 887 |
elemcmd,headcmd,dot,dots,headhook} |
| 888 |
% \end{macrocode} |
| 889 |
% |
| 890 |
% \subsection{Wrapping} |
| 891 |
% The wrapcmd options also just save their argument, but wraponecmd |
| 892 |
% takes wrapcmd as a default: |
| 893 |
% \begin{macrocode} |
| 894 |
\define@key[mlist]{sym}{wrapcmd}{\let\mlist@wrap#1} |
| 895 |
\define@key[mlist]{sym}{wraponecmd}[\mlist@wrap]{\let\mlist@wrapone#1} |
| 896 |
% \end{macrocode} |
| 897 |
% The wrap and wrapone options need a bit more logic in them: |
| 898 |
% \begin{macrocode} |
| 899 |
\define@key[mlist]{sym}{wrap}{% |
| 900 |
\def\mlist@wrap##1##2{\@firstoftwo#1##2\@secondoftwo#1}} |
| 901 |
\define@key[mlist]{sym}{wrapone}[]{% |
| 902 |
\ifx\relax#1\relax |
| 903 |
\let\mlist@wrapone\mlist@wrap |
| 904 |
\else |
| 905 |
\def\mlist@wrapone##1##2{\@firstoftwo#1##2\@secondoftwo#1}% |
| 906 |
\fi} |
| 907 |
% \end{macrocode} |
| 908 |
% |
| 909 |
% \subsection{Element definition} |
| 910 |
% |
| 911 |
% Takes as input a two dimension list with comma-separated elements |
| 912 |
% and semicolon-separated lists of elements: |
| 913 |
% \codeline |#1| $\to$ |{1,2,3;4,5;6}| . |
| 914 |
% |
| 915 |
% Elements could be numerical or arbitrary \TeX\ code. |
| 916 |
% \begin{macrocode} |
| 917 |
\define@key[mlist]{sym}{elem}{% |
| 918 |
% \end{macrocode} |
| 919 |
% It would be easier for all involved if I used specific counters for |
| 920 |
% the following. For now, they're generic and harder to comprehend in |
| 921 |
% six months: |
| 922 |
% \begin{description}[nolistsep] |
| 923 |
% \item[\cmd\@tempcnta] Number of semicolon list. |
| 924 |
% \item[\cmd\@tempcntb] Element number of this comma list. |
| 925 |
% \end{description} |
| 926 |
% \begin{macrocode} |
| 927 |
\@tempcnta\z@ |
| 928 |
\@tempcntb\z@ |
| 929 |
\mlist@elem@N\z@ |
| 930 |
% \end{macrocode} |
| 931 |
% Iterate over every semicolon list. Set \cs{if@tempswa} true only |
| 932 |
% after every |:| element, for each semicolon list. Maybe we should |
| 933 |
% use a counter for this, instead? |
| 934 |
% \begin{macrocode} |
| 935 |
\@sfor\@jj:=#1\do{% |
| 936 |
\advance\@tempcnta\@ne |
| 937 |
\@tempcntb\z@ |
| 938 |
\@tempswafalse |
| 939 |
% \end{macrocode} |
| 940 |
% Iterate over every comma list: |
| 941 |
% \begin{macrocode} |
| 942 |
\@for\@ii:=\@jj\do{% |
| 943 |
% \end{macrocode} |
| 944 |
% If the element is |:|, set the switch for the next comma-iteration. |
| 945 |
% \begin{macrocode} |
| 946 |
\ifx\@ii\mlist@colon |
| 947 |
\@tempswatrue |
| 948 |
\else |
| 949 |
% \end{macrocode} |
| 950 |
% If the previous element was |:|, save the `last' element: (TODO: add |
| 951 |
% error check for too many |:|). If we've already defined the `last' |
| 952 |
% element and run into |:| again, that means we actually wanted `mid' |
| 953 |
% so make the redefinition. This should only happen once anyway so it |
| 954 |
% can occur every time \cs{if@tempswa} is true. |
| 955 |
% \begin{macrocode} |
| 956 |
\if@tempswa |
| 957 |
\let@cc{mlist@\the\@tempcnta @mid}{mlist@\the\@tempcnta @last}% |
| 958 |
\def\@tempa{\def@c{mlist@\the\@tempcnta @last}}% |
| 959 |
\expandafter\@tempa\expandafter{\@ii}% |
| 960 |
\else |
| 961 |
% \end{macrocode} |
| 962 |
% Otherwise, bump up the counters and define the elements. There are |
| 963 |
% two definitions we used for the element indexing. As an example, if |
| 964 |
% we're up to index $(3,1)$ of a list like $\{a,b,c;d,e;f\}$ then we define |
| 965 |
% \codeline |\mlist@3@1| $\to$ elem $f$ , and |
| 966 |
% \codeline |\mlist@@6| $\to$ elem $f$ . \\ |
| 967 |
% (Index $3,1$ is the sixth in the list.) |
| 968 |
% \begin{macrocode} |
| 969 |
\advance\@tempcntb\@ne |
| 970 |
\advance\mlist@elem@N\@ne |
| 971 |
\def@co{mlist@\the\@tempcnta @\the\@tempcntb}{\@ii}% |
| 972 |
\def@co{mlist@@\the\mlist@elem@N}{\@ii}% |
| 973 |
\fi |
| 974 |
\fi}% |
| 975 |
% \end{macrocode} |
| 976 |
% If swa is true, we are in an element after a |:|, so turn it off. |
| 977 |
% TODO: I guess no more regular elements can turn up anyway so this is |
| 978 |
% probably overkill! |
| 979 |
% \begin{macrocode} |
| 980 |
\if@tempswa\@tempswafalse\fi}} |
| 981 |
% \end{macrocode} |
| 982 |
% \changes{v0.3}{2007/05/09}{Tidied up the \cmd\MID/\cmd\LAST\ element |
| 983 |
% stuff a bit.} |
| 984 |
% |
| 985 |
% \subsection{Shorthand definitions} |
| 986 |
% |
| 987 |
% Currently defunct: |
| 988 |
% \begin{macrocode} |
| 989 |
\define@key[mlist]{sym}{shorthand}{% |
| 990 |
\mlist@def@shorthand#1% |
| 991 |
\def@c{mlist@@\@tempa\expandafter}\expandafter{\@tempb}} |
| 992 |
% \end{macrocode} |
| 993 |
% |
| 994 |
% \begin{macrocode} |
| 995 |
\def\mlist@def@shorthand#1#{% |
| 996 |
\def\@tempa{\string#1} |
| 997 |
\def\@tempb} |
| 998 |
% \end{macrocode} |
| 999 |
% |
| 1000 |
% \section{List indexing} |
| 1001 |
% |
| 1002 |
% How do I want indexing to work? Originally, the input was a one |
| 1003 |
% dimensional list with the output directly following the indexing: |
| 1004 |
% \begin{verbatim} |
| 1005 |
% A = {a1,a2,a3,a4} |
| 1006 |
% A{1,2;3,4} == {a1,a2;a3,a4} |
| 1007 |
% \end{verbatim} |
| 1008 |
% I tried a couple of other things, but went back to this idea plus the |
| 1009 |
% implicit indexing. |
| 1010 |
% |
| 1011 |
% \begin{macro}{\@mlist} |
| 1012 |
% \darg{keyval options} |
| 1013 |
% This is the \cmd\setkeys\ wrapper, which |
| 1014 |
% sets macros for us in various ways depending on how it has been |
| 1015 |
% called and then moves on to do the actual list indexing, |
| 1016 |
% extraction, and typesetting. |
| 1017 |
% \begin{macrocode} |
| 1018 |
\newcommand\@mlist[1]{% |
| 1019 |
\begingroup |
| 1020 |
\let\mlist@list@elems\@empty |
| 1021 |
\@tempcnta\@ne |
| 1022 |
\mlist@count |
| 1023 |
% \end{macrocode} |
| 1024 |
% The \cmd\setkeys\ code to extract our mlist is flanked by some scary |
| 1025 |
% code to protect ourselves inside things like |{array}| |
| 1026 |
% environments. Thanks Morten. |
| 1027 |
% \begin{macrocode} |
| 1028 |
\iffalse{\fi\ifnum0=`}\fi |
| 1029 |
\setkeys[mlist]{sym}{#1}% |
| 1030 |
\ifnum0=`{\fi\iffalse}\fi |
| 1031 |
% \end{macrocode} |
| 1032 |
% These macros only exist inside an mlist index: |
| 1033 |
% \begin{macrocode} |
| 1034 |
\def\MID{\csname mlist@\the\@tempcnta @mid\endcsname}% |
| 1035 |
\def\LAST{\csname mlist@\the\@tempcnta @last\endcsname}% |
| 1036 |
% \end{macrocode} |
| 1037 |
% If there are no optional arguments, typeset the plain vector symbol. |
| 1038 |
% \begin{macrocode} |
| 1039 |
\ifx\@empty\mlist@index\relax |
| 1040 |
\def\mlist@list{\mlist@headcmd{\mlist@headhook\mlist@symbol}}% |
| 1041 |
\else |
| 1042 |
% \end{macrocode} |
| 1043 |
% Otherwise, iterate over every semicolon-separated list. |
| 1044 |
% \begin{macrocode} |
| 1045 |
\@tempcnta\z@ |
| 1046 |
\@tempswafalse |
| 1047 |
\@sfor\@jj:=\mlist@index\do{% |
| 1048 |
\let\@jj\@jj |
| 1049 |
\advance\@tempcnta\@ne |
| 1050 |
\mlist@count |
| 1051 |
\expandafter\@ifmtarg\expandafter{\@jj}{}% ignore if empty |
| 1052 |
{\if@tempswa\mlist@add\mlist@sepsep\fi |
| 1053 |
\@tempswatrue}% |
| 1054 |
% \end{macrocode} |
| 1055 |
% And (sub-)iterate over every comma-separated list: |
| 1056 |
% \begin{macrocode} |
| 1057 |
\@tempcntb\z@ |
| 1058 |
\@mlist@notfirst@false |
| 1059 |
\@for\@ii:=\@jj\do{% |
| 1060 |
\let\@ii\@ii |
| 1061 |
\advance\@tempcntb\@ne |
| 1062 |
% \end{macrocode} |
| 1063 |
% Now grab the symbol we're up to. |
| 1064 |
% When it's empty: |
| 1065 |
% \begin{macrocode} |
| 1066 |
\expandafter\@ifmtarg\expandafter{\@ii}% |
| 1067 |
{\advance\@tempcntb\m@ne |
| 1068 |
\mlist@add{\@gobble}} |
| 1069 |
% \end{macrocode} |
| 1070 |
% When it's not empty: |
| 1071 |
% \begin{macrocode} |
| 1072 |
{\if@mlist@notfirst@\mlist@add\mlist@sep\fi |
| 1073 |
\@mlist@notfirst@true |
| 1074 |
\ifx\@ii\mlist@colon |
| 1075 |
\mlist@add{\mlist@dots\@gobble}% |
| 1076 |
\else |
| 1077 |
\ifx\@ii\mlist@period |
| 1078 |
\mlist@add{\mlist@dot\@gobble}% |
| 1079 |
\else |
| 1080 |
\mlist@add{\mlist@elemcmd{\mlist@headhook\mlist@symbol}}% |
| 1081 |
\fi |
| 1082 |
\fi}% |
| 1083 |
% \end{macrocode} |
| 1084 |
% Parse the index to see if it's an implicit reference of the form |
| 1085 |
% |@|$n$. @mlist@implicit@ is true if the index is implicit: (and we assume |@| |
| 1086 |
% will be only used in an implicit-indexing context. TODO: fix this!) |
| 1087 |
% \begin{macrocode} |
| 1088 |
\mlist@parse@implicit |
| 1089 |
\if@mlist@implicit@ |
| 1090 |
\mlist@add@ifcs{% |
| 1091 |
mlist@\the\@tempcnta @\expandafter\@gobble\@ii |
| 1092 |
}{\@ii}% |
| 1093 |
\else |
| 1094 |
% \end{macrocode} |
| 1095 |
% Because \cmd\@ii, \cmd\@jj\ can contain any possible index that |
| 1096 |
% might be passed through the macro, we use eTeX's \cmd\detokenize\ to |
| 1097 |
% prevent expansion of any weird argument that might be given. |
| 1098 |
% \begin{macrocode} |
| 1099 |
\mlist@add@ifcs{% |
| 1100 |
mlist@@\expandafter\detokenize\expandafter{\@ii}% |
| 1101 |
}{\@ii}% |
| 1102 |
\fi |
| 1103 |
}% |
| 1104 |
% \end{macrocode} |
| 1105 |
% That was the end of comma-separated iteration. |
| 1106 |
% \begin{macrocode} |
| 1107 |
}% |
| 1108 |
% \end{macrocode} |
| 1109 |
% That was the end of semicolon-separated iteration. |
| 1110 |
% \begin{macrocode} |
| 1111 |
\def\mlist@list{% |
| 1112 |
\mlist@wrap{\mlist@headcmd{\mlist@headhook\mlist@symbol}} |
| 1113 |
{\mlist@list@elems}}% |
| 1114 |
% \end{macrocode} |
| 1115 |
% If only have a single element: |
| 1116 |
% \begin{macrocode} |
| 1117 |
\ifnum\@tempcnta=\@ne |
| 1118 |
\ifnum\@tempcntb=\@ne |
| 1119 |
\let\mlist@wrap\mlist@wrapone |
| 1120 |
\fi |
| 1121 |
\fi |
| 1122 |
\fi |
| 1123 |
\mlist@list |
| 1124 |
\endgroup} |
| 1125 |
% \end{macrocode} |
| 1126 |
% TODO: move \cmd\mlist@list\ after the endgroup? |
| 1127 |
% \changes{v0.4}{2007/05/17}{Eliminated \cmd\global\ no longer |
| 1128 |
% required since I separated the list creation and typesetting.} |
| 1129 |
% \changes{v0.4}{2007/05/19}{Simplified `single index' code.} |
| 1130 |
% \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)} |
| 1131 |
% \changes{v0.6}{2008/04/02}{Added \cmd\mlist@headhook.} |
| 1132 |
% \end{macro} |
| 1133 |
% |
| 1134 |
% \begin{macro}{\mlist@add} |
| 1135 |
% Used in the above to build up the \cmd\mlist@list\ list. |
| 1136 |
% \begin{macrocode} |
| 1137 |
\newcommand\mlist@add[1]{% |
| 1138 |
\expandafter\gdef |
| 1139 |
\expandafter\mlist@list@elems |
| 1140 |
\expandafter{\mlist@list@elems#1}} |
| 1141 |
% \end{macrocode} |
| 1142 |
% \end{macro} |
| 1143 |
% |
| 1144 |
% \begin{macro}{\mlist@count} |
| 1145 |
% This macro is used to increment the counter used in |
| 1146 |
% \cmd\MID/\cmd\LAST\ during the actual typesetting of the indexed |
| 1147 |
% elements. |
| 1148 |
% \begin{macrocode} |
| 1149 |
\def\mlist@count{% |
| 1150 |
\expandafter\mlist@add |
| 1151 |
\expandafter{% |
| 1152 |
\expandafter\@tempcnta\the\@tempcnta\relax}} |
| 1153 |
% \end{macrocode} |
| 1154 |
% \end{macro} |
| 1155 |
% |
| 1156 |
% \begin{macro}{\mlist@add@ifcs} |
| 1157 |
% Pretty specific macro to save some repetition. Uses |
| 1158 |
% \cmd\mlist@add\ to add the first argument as a csname if it |
| 1159 |
% exists, otherwise adds the literal second argument. |
| 1160 |
% \begin{macrocode} |
| 1161 |
\newcommand\mlist@add@ifcs[2]{% |
| 1162 |
\ifcsname#1\endcsname |
| 1163 |
\expandafter\@firstoftwo |
| 1164 |
\else |
| 1165 |
\expandafter\@secondoftwo |
| 1166 |
\fi{\expandafter\mlist@add\expandafter{\expandafter{\csname#1\endcsname}}} |
| 1167 |
{\expandafter\mlist@add\expandafter{\expandafter{#2}}}} |
| 1168 |
% \end{macrocode} |
| 1169 |
% \end{macro} |
| 1170 |
% |
| 1171 |
% \begin{macro}{\mlist@parse@implicit} |
| 1172 |
% Parses the index to see if it's an implicit reference: |@|$n$. The |
| 1173 |
% idea is to expand out the index, set a conditional if the first |
| 1174 |
% char is an |@|, and then gobble up the whole thing. We do this |
| 1175 |
% twice for the two common catcodes that |@| might be. |
| 1176 |
% \begin{macrocode} |
| 1177 |
\def\mlist@parse@implicit{% |
| 1178 |
\@mlist@implicit@false |
| 1179 |
\def\@tempb{% |
| 1180 |
\expandafter\@ifnextchar\mlist@ampersat |
| 1181 |
{\@mlist@implicit@true\@gobblenil} |
| 1182 |
{\@mlist@implicit@false\@gobblenil}}% |
| 1183 |
\expandafter\@tempb\@ii\@nil |
| 1184 |
\unless\if@mlist@implicit@ |
| 1185 |
\def\@tempb{% |
| 1186 |
\@ifnextchar @ |
| 1187 |
{\@mlist@implicit@true\@gobblenil} |
| 1188 |
{\@mlist@implicit@false\@gobblenil}}% |
| 1189 |
\expandafter\@tempb\@ii\@nil |
| 1190 |
\fi} |
| 1191 |
% \end{macrocode} |
| 1192 |
% \changes{v0.3}{2007/05/09}{Added second check to \cmd\@ifnextchar |
| 1193 |
% |@| for catcode letter.} |
| 1194 |
% \end{macro} |
| 1195 |
% |
| 1196 |
% \section{List creation} |
| 1197 |
% |
| 1198 |
% This is the idea behind the user level macros of the package: |
| 1199 |
% \begin{verbatim} |
| 1200 |
% \newmlist\vect{all-vect-opts} |
| 1201 |
% \vect{v}{ind} == \@mlist{symbol={v},all-vect-opts,index={ind}} |
| 1202 |
% |
| 1203 |
% \newvect\vv{v}[this-v-options] |
| 1204 |
% \vv[ind] == \@mlist{symbol={v},all-vect-opts,this-v-options,index={ind}} |
| 1205 |
% \end{verbatim} |
| 1206 |
% |
| 1207 |
% \begin{macro}{\newmlist} |
| 1208 |
% \begin{macro}{\renewmlist} |
| 1209 |
% \darg{control sequence} |
| 1210 |
% \oarg{keyval options} |
| 1211 |
% Things get pretty hairy because I have to do all the optional |
| 1212 |
% argument processing manually. I'd be better off using the |
| 1213 |
% \pkg{suffix} package, but the code works for now. \ltx3 will make |
| 1214 |
% things much easier. |
| 1215 |
% \begin{macrocode} |
| 1216 |
\newcommand\newmlist[1]{% |
| 1217 |
\@mlist@warntrue |
| 1218 |
\mlist@optarg{\@defmlist@opt{#1}}} |
| 1219 |
\newcommand\renewmlist[1]{% |
| 1220 |
\@mlist@warnfalse |
| 1221 |
\mlist@optarg{\@defmlist@opt{#1}}} |
| 1222 |
\def\@defmlist@opt#1[#2]{\@defmlist{#1}{#2}} |
| 1223 |
% \end{macrocode} |
| 1224 |
% Processing |#1| = thislist-cmd, |#2| = all-thislist-opts |
| 1225 |
% \begin{macrocode} |
| 1226 |
\newcommand\@defmlist[2]{% |
| 1227 |
\if@mlist@warn |
| 1228 |
\ifdefined#1 |
| 1229 |
\PackageError{mlist}{Command \string#1 already defined} |
| 1230 |
{\string#1 will be overwritten}% |
| 1231 |
\fi |
| 1232 |
\fi |
| 1233 |
% \end{macrocode} |
| 1234 |
% Plain usage: (e.g., |\vect{a}{1,2,3}|) |
| 1235 |
% \begin{macrocode} |
| 1236 |
\protected\def#1##1{% |
| 1237 |
\@ifnextbrace |
| 1238 |
{\csname\string#1@opt\endcsname{##1}} |
| 1239 |
{\csname\string#1@opt\endcsname{##1}{}}}% |
| 1240 |
\def@c{\string#1@opt}##1##2{% |
| 1241 |
\csname\string#1\endcsname{##1}{##2}}% |
| 1242 |
\def@c{\string#1}##1##2{% |
| 1243 |
\@mlist{symbol=##1,#2,index={##2}}}% |
| 1244 |
% \end{macrocode} |
| 1245 |
% mlist macro definitions: (e.g., |\newvect{A}[...]|) |
| 1246 |
% Processing |##1| = this-sym-cmd, |##2| = symbol, |##3| = this-sym-options |
| 1247 |
% \begin{macrocode} |
| 1248 |
\def@c{new\expandafter\@gobble\string#1}##1##2{% |
| 1249 |
\@mlist@warntrue |
| 1250 |
\mlist@optarg{\csname @new\string#1@opt\endcsname{##1}{##2}}}% |
| 1251 |
\def@c{renew\expandafter\@gobble\string#1}##1##2{% |
| 1252 |
\@mlist@warnfalse |
| 1253 |
\mlist@optarg{\csname @new\string#1@opt\endcsname{##1}{##2}}}% |
| 1254 |
\def@c{@new\string#1@opt}##1##2[##3]{% |
| 1255 |
\csname @new\string#1\endcsname{##1}{##2}{##3}}% |
| 1256 |
\def@c{@new\string#1}##1##2##3{% |
| 1257 |
\if@mlist@warn |
| 1258 |
\ifdefined##1 |
| 1259 |
\PackageError{mlist}{Command \string##1 already defined} |
| 1260 |
{You cannot overwrite previous definition of \string##1}% |
| 1261 |
\fi |
| 1262 |
\fi |
| 1263 |
\protected\def##1{% |
| 1264 |
\@ifnextbrace |
| 1265 |
{\csname @new\string##1@opt\endcsname} |
| 1266 |
{\@mlist{symbol=##2,#2,##3}}}% |
| 1267 |
\def@c{@new\string##1@opt}####1{% |
| 1268 |
\@mlist{symbol=##2,#2,##3,index={####1}}}}% |
| 1269 |
} |
| 1270 |
% \end{macrocode} |
| 1271 |
% \end{macro} |
| 1272 |
% \end{macro} |
| 1273 |
% |
| 1274 |
% \begin{example}{firstline=2} |
| 1275 |
% \raggedright\ttfamily\slshape |
| 1276 |
% \def\@mlist#1{MLIST: #1\par} |
| 1277 |
% \newmlist\testlist[opt1=one] |
| 1278 |
% \newtestlist\testone{S} |
| 1279 |
% \testone |
| 1280 |
% \testone{1,2,3} |
| 1281 |
% \newtestlist\testtwo{T}[opt2=two] |
| 1282 |
% \testtwo |
| 1283 |
% \testtwo{1,2,3} |
| 1284 |
% \end{example} |
| 1285 |
% |
| 1286 |
% \begin{macrocode} |
| 1287 |
\InputIfFileExists{mlist.cfg}{} |
| 1288 |
{\PackageWarning{mlist}{No configuration file (mlist.cfg) found nor loaded}} |
| 1289 |
% \end{macrocode} |
| 1290 |
% |
| 1291 |
%\iffalse |
| 1292 |
%</package> |
| 1293 |
%\fi |
| 1294 |
% |
| 1295 |
% |
| 1296 |
%\iffalse |
| 1297 |
%<*dtx-style> |
| 1298 |
% \begin{macrocode} |
| 1299 |
\ProvidesPackage{dtx-style} |
| 1300 |
|
| 1301 |
\errorcontextlines=999 |
| 1302 |
|
| 1303 |
\def\@dotsep{1000} |
| 1304 |
\setcounter{tocdepth}{2} |
| 1305 |
\setlength\columnseprule{0.1pt} |
| 1306 |
\renewcommand\tableofcontents{\relax |
| 1307 |
\begin{multicols}{2}[\section*{\contentsname}]\small |
| 1308 |
\@starttoc{toc}\relax |
| 1309 |
\end{multicols}} |
| 1310 |
|
| 1311 |
\setcounter{IndexColumns}{2} |
| 1312 |
\renewenvironment{theglossary} |
| 1313 |
{\small\list{}{} |
| 1314 |
\item\relax |
| 1315 |
\glossary@prologue\GlossaryParms |
| 1316 |
\let\item\@idxitem \ignorespaces |
| 1317 |
\def\pfill{\hspace*{\fill}}} |
| 1318 |
{\endlist} |
| 1319 |
|
| 1320 |
\usepackage[svgnames]{xcolor} |
| 1321 |
\usepackage{amsmath,array,bm,booktabs,calc,enumitem,fancyvrb,graphicx,ifthen,longtable,refstyle,subfig,topcapt,varioref,mlist} |
| 1322 |
|
| 1323 |
\usepackage{easyvector,vector,tensind} |
| 1324 |
\usepackage{url} |
| 1325 |
|
| 1326 |
\usepackage[sc,osf]{mathpazo} |
| 1327 |
|
| 1328 |
\linespread{1.069} % A bit more space between lines |
| 1329 |
\frenchspacing % Remove ugly extra space after punctuation |
| 1330 |
|
| 1331 |
\definecolor{niceblue}{rgb}{0.2,0.4,0.8} |
| 1332 |
\newenvironment{example}[1] |
| 1333 |
{\VerbatimEnvironment |
| 1334 |
\def\Options{#1}% |
| 1335 |
\begin{VerbatimOut}[gobble=2]{\examplefilename}} |
| 1336 |
{\end{VerbatimOut}\relax |
| 1337 |
\typesetexample} |
| 1338 |
|
| 1339 |
\fvset{formatcom=\color{niceblue}} |
| 1340 |
\DefineShortVerb{\|} |
| 1341 |
|
| 1342 |
\def\theCodelineNo{\textcolor{niceblue}{\sffamily\tiny\arabic{CodelineNo}}} |
| 1343 |
|
| 1344 |
\let\examplesize\normalsize |
| 1345 |
\let\auxwidth\relax |
| 1346 |
|
| 1347 |
\newlength\examplewidth\newlength\verbatimwidth |
| 1348 |
\newlength\exoutdent \newlength\exverbgap |
| 1349 |
\setlength\exverbgap{1em} |
| 1350 |
\setlength\exoutdent{-0.15\textwidth} |
| 1351 |
\newsavebox\verbatimbox |
| 1352 |
\edef\examplefilename{\jobname.example} |
| 1353 |
|
| 1354 |
\newcommand\typesetexample{\relax |
| 1355 |
\smallskip |
| 1356 |
\noindent |
| 1357 |
\begin{minipage}{\linewidth} |
| 1358 |
\color{niceblue} |
| 1359 |
\hrulefill\par |
| 1360 |
\edef\@tempa{[gobble=0,fontsize=\noexpand\small,\Options]}% |
| 1361 |
\begin{lrbox}{\verbatimbox}\relax |
| 1362 |
\expandafter\BVerbatimInput\@tempa{\examplefilename}% |
| 1363 |
\end{lrbox} |
| 1364 |
\begin{list}{}{\setlength\itemindent{0pt} |
| 1365 |
\setlength\leftmargin\exoutdent |
| 1366 |
\setlength\rightmargin{0pt}}\item |
| 1367 |
\ifx\auxwidth\relax |
| 1368 |
\setlength\verbatimwidth{\wd\verbatimbox}% |
| 1369 |
\else |
| 1370 |
\setlength\verbatimwidth{\auxwidth}% |
| 1371 |
\fi |
| 1372 |
\begin{minipage}[c]{\textwidth-\exoutdent-\verbatimwidth-\exverbgap} |
| 1373 |
\catcode`\%=14\centering\linespread{1.6}\input\examplefilename\relax |
| 1374 |
\end{minipage}\hfill |
| 1375 |
\begin{minipage}[c]{\verbatimwidth} |
| 1376 |
\usebox\verbatimbox |
| 1377 |
\end{minipage} |
| 1378 |
\end{list} |
| 1379 |
\par\noindent\hrulefill |
| 1380 |
\end{minipage}\par |
| 1381 |
\smallskip\noindent} |
| 1382 |
|
| 1383 |
\newcommand*\setverbwidth[1]{\def\auxwidth{#1}} |
| 1384 |
|
| 1385 |
\newcommand*\name[1]{{#1}} |
| 1386 |
\newcommand*\pkg[1]{\textsf{#1}} |
| 1387 |
\newcommand*\feat[1]{\texttt{#1}} |
| 1388 |
\newcommand*\opt[1]{\texttt{#1}} |
| 1389 |
|
| 1390 |
\newcommand*\ltx[1]{% |
| 1391 |
\ifx3#1\relax |
| 1392 |
\textsc{ltx3}% |
| 1393 |
\else |
| 1394 |
\LaTeXe |
| 1395 |
\fi} |
| 1396 |
|
| 1397 |
\newcommand*\note[1]{\unskip\footnote{#1}} |
| 1398 |
|
| 1399 |
\let\latin\textit |
| 1400 |
\def\eg{\latin{e.g.}} |
| 1401 |
\def\Eg{\latin{E.g.}} |
| 1402 |
\def\ie{\latin{i.e.}} |
| 1403 |
\def\etc{\@ifnextchar.{\latin{etc}}{\latin{etc.}\@}} |
| 1404 |
|
| 1405 |
\def\STIX{\textsc{stix}} |
| 1406 |
\def\MacOSX{Mac~OS~X} |
| 1407 |
\def\ascii{\textsc{ascii}} |
| 1408 |
\def\OMEGA{Omega} |
| 1409 |
\def\CTAN{\textsc{ctan}} |
| 1410 |
|
| 1411 |
\newcounter{argument} |
| 1412 |
\g@addto@macro\endmacro{\setcounter{argument}{0}} |
| 1413 |
\newcommand*\darg[1]{% |
| 1414 |
\stepcounter{argument}% |
| 1415 |
{\ttfamily\char`\#\theargument~:~}#1\par\noindent\ignorespaces} |
| 1416 |
\newcommand*\doarg[1]{% |
| 1417 |
\stepcounter{argument}% |
| 1418 |
{\ttfamily\makebox[0pt][r]{[}\char`\#\theargument]:~}#1\par\noindent\ignorespaces} |
| 1419 |
|
| 1420 |
\def\codeline{\par\hspace{\parindent}}% two \indents in total |
| 1421 |
|
| 1422 |
\newcommand\unichar[2]{\textsc{\MakeLowercase{u+#1: #2}}} |
| 1423 |
|
| 1424 |
\setlength\parindent{2em} |
| 1425 |
|
| 1426 |
% \end{macrocode} |
| 1427 |
%</dtx-style> |
| 1428 |
%\fi |
| 1429 |
% |
| 1430 |
% \typeout{*************************************************************} |
| 1431 |
% \typeout{*} |
| 1432 |
% \typeout{* To finish the installation you have to move the following} |
| 1433 |
% \typeout{* file into a directory searched by XeTeX:} |
| 1434 |
% \typeout{*} |
| 1435 |
% \typeout{* \space\space\space mlist.sty} |
| 1436 |
% \typeout{*} |
| 1437 |
% \typeout{*************************************************************} |
| 1438 |
% |
| 1439 |
\endinput |