| 1 |
This is the README file for the 'storecmd' package. |
| 2 |
|
| 3 |
VERSION |
| 4 |
|
| 5 |
Version 0.0.1, October 2011. |
| 6 |
|
| 7 |
SUMMARY |
| 8 |
|
| 9 |
This package provides macros for command definition that save the |
| 10 |
name of the command being defined in a file or a macro container. |
| 11 |
Even when the user uses a syntax similar to that of \newcommand, |
| 12 |
some or all of the parameters of the defined command can be delimited, |
| 13 |
as desired by the command author. |
| 14 |
|
| 15 |
It was written in response to a post on comp.text.tex for a macro |
| 16 |
that will define commands and also save the commands being defined |
| 17 |
in a file or a container macro, eg, for spelling exceptions. Three |
| 18 |
macros are provided for this purpose: |
| 19 |
|
| 20 |
\defsavecmd<cmd><param>{<defn>} |
| 21 |
\newsavecmd<cmd><param>{<defn>} |
| 22 |
\renewsavecmd<cmd><param>{<defn>} |
| 23 |
|
| 24 |
Here <cmd> is the command name, <param> is the parameter list, and |
| 25 |
<defn> is the replacement text. In \defsavecmd, the <param> list is |
| 26 |
as in \def; in \newsavecmd and \renewsavecmd, the <param> list is |
| 27 |
as in \newcommand. \defsavecmd will overwrite an existing command; |
| 28 |
both \newsavecmd and \renewsavecmd will not do so. |
| 29 |
|
| 30 |
The commands \defsavecmd, \newsavecmd and \renewsavecmd may be |
| 31 |
prefixed by \globalcmd and/or \protectedcmd to yield global or robust |
| 32 |
definitions, respectively. For example, |
| 33 |
|
| 34 |
\defsavecmd\cmda#1#2{xxx#1#2} |
| 35 |
\globalcmd\defsavecmd\cmdb#1#2{xxx#1#2} |
| 36 |
\globalcmd\newsavecmd\cmdc[2]{xxx#1#2} |
| 37 |
\protectedcmd\globalcmd\renewsavecmd*\cmda[2][zz]{\def\y##1{##1xxx}} |
| 38 |
|
| 39 |
The parameters of \defsavecmd can readily be delimited as in the case |
| 40 |
of \def. The parameters of \newsavecmd and \renewsavecmd can be |
| 41 |
delimited as follows: |
| 42 |
|
| 43 |
\newsavecmd<cmd><param>(<delimiters>){<defn>} |
| 44 |
\renewsavecmd<cmd><param>(<delimiters>){<defn>} |
| 45 |
|
| 46 |
The <delimiters>, given in parenthesis, have the syntax: |
| 47 |
|
| 48 |
1<\delim1> 2<\delim2> ... 9<\delim9> |
| 49 |
|
| 50 |
where <\delim1> is the delimiter for the first parameter, etc. Only the |
| 51 |
parameters with delimiters are to be specified in <delimiters>. |
| 52 |
For example, |
| 53 |
|
| 54 |
\protectedcmd\newsavecmd\cmda[2](1\@nil 2\@mil){xxx#1#2} |
| 55 |
\newsavecmd\cmdb[9][yy](3\@nil 9\@mil){xxx#1#2#3...#9} |
| 56 |
|
| 57 |
When the first argument is optional, then it can't have a delimiter, |
| 58 |
since the delimiter for that parameter is already '[]'. |
| 59 |
|
| 60 |
|
| 61 |
The package options are |
| 62 |
|
| 63 |
neversave - Never save/store the new commands in the container |
| 64 |
file or command. The new commands will still be defined. |
| 65 |
Default: false |
| 66 |
|
| 67 |
storerenew - Allow the storage of a command that has already |
| 68 |
been stored. This is used by \renewsavecmd. |
| 69 |
Default: false. |
| 70 |
|
| 71 |
overwrite - Allow overwrite of an existing container file or |
| 72 |
command. Default: false. |
| 73 |
|
| 74 |
storefile - Container file. Default: cmdnamesfile. |
| 75 |
|
| 76 |
storecmd - Container command. Default: cmdnamesmacro. |
| 77 |
|
| 78 |
verbose - Give extra information in the transcript file. |
| 79 |
Default: true. Turn this off if you don't like |
| 80 |
or need such information. |
| 81 |
|
| 82 |
|
| 83 |
EXAMPLE FILE |
| 84 |
|
| 85 |
\begin{filecontents}{storecmd-example.tex} |
| 86 |
\documentclass{article} |
| 87 |
% Container commands are also accepted as package options, |
| 88 |
% but in this case 'catoptions' must be loaded before |
| 89 |
% \usepackage{storecmd}. |
| 90 |
% Eg, |
| 91 |
% \usepackage{catoptions} |
| 92 |
% \usepackage[storecmd=\mycommands]{storecmd} |
| 93 |
% |
| 94 |
% Uncomment the next line to test what happens when |
| 95 |
% an existing command is being refilled: |
| 96 |
% \def\mycommands{} |
| 97 |
|
| 98 |
\usepackage[ |
| 99 |
storerenew=true,storecmd=mycommands,storefile=mycommands |
| 100 |
]{storecmd} |
| 101 |
|
| 102 |
\defsavecmd\cmda#1#2{xxx#1#2} |
| 103 |
\globalcmd\defsavecmd\cmdb#1#2{xxx#1#2} |
| 104 |
\globalcmd\newsavecmd\cmdc[2]{xxx#1#2} |
| 105 |
\globalcmd\newsavecmd\cmdd[2][yy]{xxx#1#2} |
| 106 |
\protectedcmd\globalcmd\renewsavecmd*\cmda[2][zz]{\def\y##1{##1xxx}} |
| 107 |
\newsavecmd\cmde[2](1\@nil 2\@mil){xxx#1#2} |
| 108 |
\newsavecmd\cmdf[9][yy](2\@nil 3\@mil){xxx#1#2#3...#9} |
| 109 |
|
| 110 |
% Try \show\mycommands or see file 'mycommands.tex'. |
| 111 |
|
| 112 |
\begin{document} |
| 113 |
Blackberry lily. |
| 114 |
\end{document} |
| 115 |
\end{filecontents} |
| 116 |
|
| 117 |
|
| 118 |
LICENSE |
| 119 |
|
| 120 |
Copyright (c) October 2011 Ahmed Musa ([email protected]) |
| 121 |
|
| 122 |
This work (ie, all the files in the storecmd manifest) may be |
| 123 |
distributed and/or modified under the conditions of the LaTeX |
| 124 |
Project Public License (LPPL), either version 1.3 of this license or |
| 125 |
any later version. The latest version of this license is in |
| 126 |
http://www.latex-project.org/lppl.txt and version 1.3 or later |
| 127 |
is part of all distributions of LaTeX version 2005/12/01 or later. |
| 128 |
|
| 129 |
The LPPL maintenance status of this software is 'author-maintained'. |
| 130 |
|
| 131 |
This software is provided 'as it is', without warranty of any |
| 132 |
kind, either expressed or implied, including, but not limited to, |
| 133 |
the implied warranties of merchantability and fitness for a |
| 134 |
particular purpose. |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|