| 1 |
%\iffalse % MetaComment |
| 2 |
%% |
| 3 |
%% + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + |
| 4 |
%% | Copyright(C) 1997-2010 by F. Bosisio | |
| 5 |
%% | | |
| 6 |
%% | This program can be redistributed and/or modified under | |
| 7 |
%% | the terms of the LaTeX Project Public License, either | |
| 8 |
%% | version 1.3 of this license or (at your option) any later | |
| 9 |
%% | version. The latest version of this license is in | |
| 10 |
%% | http://www.latex-project.org/lppl.txt | |
| 11 |
%% | and version 1.3 or later is part of all LaTeX distributions | |
| 12 |
%% | version 2005/12/01 or later. | |
| 13 |
%% | | |
| 14 |
%% | This work has the LPPL maintenance status `maintained'. | |
| 15 |
%% | The Current Maintainer of this work is F. Bosisio. | |
| 16 |
%% | | |
| 17 |
%% | This work consists of files mathcmd.dtx and mathcmd.html | |
| 18 |
%% | and of the derived files mathcmd.sty and mathcmd.pdf. | |
| 19 |
%% | | |
| 20 |
%% | E-mail: [email protected] | |
| 21 |
%% | CTAN location: macros/latex/contrib/bosisio/ | |
| 22 |
%% + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + |
| 23 |
%% |
| 24 |
%% If you make any improvment, find any bug or have |
| 25 |
%% any suggestion, please let me know about it. |
| 26 |
%% |
| 27 |
%<*package,driver> |
| 28 |
%\fi |
| 29 |
% |
| 30 |
\def\FileName{mathcmd} |
| 31 |
%\iffalse % MetaComment |
| 32 |
%</package,driver> |
| 33 |
%<*package> |
| 34 |
%\fi |
| 35 |
\def\fileversion{2.2} |
| 36 |
\def\filedate{1997/12/20} |
| 37 |
\def\docdate{2005/04/09} |
| 38 |
\def\filedescr{Extensions to math environments (FB)} |
| 39 |
% |
| 40 |
%\iffalse % MetaComment |
| 41 |
%</package> |
| 42 |
%<*dtx> |
| 43 |
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 44 |
% This section is the installation driver |
| 45 |
% |
| 46 |
\def\batchfile{\FileName.dtx} |
| 47 |
% |
| 48 |
\input docstrip |
| 49 |
% |
| 50 |
\keepsilent |
| 51 |
% \askforoverwritefalse |
| 52 |
% |
| 53 |
\generateFile{\FileName.sty}{f}{\from{\FileName.dtx}{package}} |
| 54 |
% |
| 55 |
\generateFile{\FileName.drv}{f}{\from{\FileName.dtx}{driver}} |
| 56 |
% |
| 57 |
\Msg{******************************************************} |
| 58 |
\Msg{*} |
| 59 |
\Msg{* To produce the documentation run the} |
| 60 |
\Msg{* file `\FileName.drv' through LaTeX.} |
| 61 |
\Msg{*} |
| 62 |
\Msg{******************************************************} |
| 63 |
% |
| 64 |
\endbatchfile |
| 65 |
% |
| 66 |
% End of the installation driver |
| 67 |
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 68 |
%</dtx> |
| 69 |
% |
| 70 |
% This section is the documentation driver |
| 71 |
% |
| 72 |
%<+driver>\documentclass[12pt,a4paper]{ltxdoc} |
| 73 |
%<+driver> \EnableCrossrefs |
| 74 |
%<+driver> \CodelineIndex |
| 75 |
%<+driver> \RecordChanges |
| 76 |
%<+driver> %\OnlyDescription % Uncomment not to see the implementation |
| 77 |
%<+driver>\begin{document} |
| 78 |
%<+driver> \DocInput{\FileName.dtx} |
| 79 |
%<+driver> \PrintIndex |
| 80 |
%<+driver> \PrintChanges |
| 81 |
%<+driver>\end{document} |
| 82 |
% |
| 83 |
% End of the documentation driver |
| 84 |
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 85 |
%<*package> |
| 86 |
%\fi |
| 87 |
% |
| 88 |
% \changes{v0.1}{20 April 1997}{First release (basic environments)} |
| 89 |
% \changes{v0.2}{3 May 1997}{Added package options} |
| 90 |
% \changes{v1.0}{24 May 1997}{Documentation added} |
| 91 |
% \changes{v2.0}{20 December 1997}{Separated from package ``mathenv''} |
| 92 |
% \changes{v2.1}{5 March 1999}{Added copyright notice and changed addresses} |
| 93 |
% \changes{v2.2}{9 April 2005}{Usage of the double-quote character (") avoided} |
| 94 |
% |
| 95 |
% \MakeShortVerb{\|} |
| 96 |
% |
| 97 |
% \title{Package \texttt{\FileName}\thanks{This is version \fileversion, |
| 98 |
% last revised \filedate; documentation date \docdate}} |
| 99 |
% \author{F. Bosisio\\\normalsize E-mail: \texttt{[email protected]}} |
| 100 |
% \date{\filedate} |
| 101 |
% \maketitle |
| 102 |
% |
| 103 |
% \begin{abstract} |
| 104 |
% Documentation for the package \texttt{\FileName}. |
| 105 |
% \end{abstract} |
| 106 |
% |
| 107 |
% \section{Introduction} |
| 108 |
% This package provides some useful math-commands which are simpler |
| 109 |
% to use and prettier then their standard \LaTeX{} counterpart. |
| 110 |
% |
| 111 |
% In particular the ``|\d|'' command is redefined, so |
| 112 |
% care should be taken, expecially when including this package in an |
| 113 |
% already existent \LaTeX{} file. |
| 114 |
% |
| 115 |
% \noindent |
| 116 |
% The original work of ``|\d|'' (i.e. place a dot under its argument) |
| 117 |
% is now done by the ``|\UnderDot|'' command. |
| 118 |
% |
| 119 |
% \section{The options} |
| 120 |
% At now, six options are available with the \texttt{\FileName} |
| 121 |
% package, which comes out in matched pairs. |
| 122 |
% |
| 123 |
% \noindent |
| 124 |
% The ``|ThreeSubscrSum|'' and ``|TwoSubscrSum|'' options control the |
| 125 |
% placement of subscripts for the ``|\Sum|'' command: the latter |
| 126 |
% (which is the default) puts the index under the simbol toghether |
| 127 |
% with the starting point, while the former puts the index on the |
| 128 |
% lower right corner. |
| 129 |
% |
| 130 |
% \noindent |
| 131 |
% The ``|ProdVettWedge|'' and ``|ProdVettTimes|'' options select |
| 132 |
% which symbol is to be used for the \emph{vector product}: the first |
| 133 |
% one uses a ``|\wedge|'' (default), whilst the second uses a |
| 134 |
% ``|\times|''. |
| 135 |
% |
| 136 |
% \noindent |
| 137 |
% Finally, the ``|VectOpStr|'' and ``|VectOpSymb|'' options controls |
| 138 |
% whether the vector-operator commands ``|\Grad|'', ``|\Div|'' and |
| 139 |
% ``|\Rot|'' should produce a roman string (default) or a |
| 140 |
% ``|\nabla|'' symbol followed by an operator, respectively. |
| 141 |
% |
| 142 |
% \section{Math-mode commands} |
| 143 |
% The \texttt{\FileName} package defines a number of math-mode |
| 144 |
% commands. |
| 145 |
% |
| 146 |
% \subsection{The \texttt{text} command} |
| 147 |
% The ``|\text{|\ldots|}|'' command is defined to be |
| 148 |
% equivalent to ``|\mbox|'' (except when the ``|amstext|'' |
| 149 |
% package is also used, since this package already defines |
| 150 |
% this command in a better way). |
| 151 |
% |
| 152 |
% \noindent |
| 153 |
% It is intended for inserting pieces of text in a formula. |
| 154 |
% |
| 155 |
% \subsection{Commands for doing integrals} |
| 156 |
% The ``|\Int|'' (capitalized) differs from the \LaTeX{} |
| 157 |
% command ``|\int|'' in that it is always printed in |
| 158 |
% |displaystyle| and if it has only a subscript, this is |
| 159 |
% somewhat lowered so that it looks better. |
| 160 |
% \begin{verbatim} |
| 161 |
% \Int_{...}^{...} ... \d{...} |
| 162 |
% \end{verbatim} |
| 163 |
% |
| 164 |
% The ``|\d{|\ldots|}|'' command is for making the |
| 165 |
% differential symbol at the end of integrals: it simply |
| 166 |
% prints a ``|d|'' followed by its argument and preceded by |
| 167 |
% a little space, which seems prettier. |
| 168 |
% |
| 169 |
% \subsection{Commands for making sums} |
| 170 |
% The ``|\Sum{|$\cdots=\cdots,\cdots$|}|'' command works |
| 171 |
% differently, depending on which option between |
| 172 |
% ``|TwoSubscrSum|'' (default) and ``|ThreeSubscrSum|'' has |
| 173 |
% been specified. |
| 174 |
% |
| 175 |
% \noindent |
| 176 |
% In the first case, it expands to |
| 177 |
% ``|\displaystyle\sum_{...=...}^{...}|'', whereas in the |
| 178 |
% second case the second and third argument are treated |
| 179 |
% in the same way as before (i.e. as a subscript and |
| 180 |
% superscript, respectively), but the first argument |
| 181 |
% (the one before the ``='') is placed near |
| 182 |
% the lower-left edge of the ``|\sum|'' symbol and the ``='' |
| 183 |
% is not printed. |
| 184 |
% |
| 185 |
% There is also a ``|\SUM{|\ldots|}|'' command which is useful |
| 186 |
% when only a subscript is desired, irrespectively of the |
| 187 |
% option specified: in fact, is is equivalent to |
| 188 |
% ``|\displaystyle\sum_{|\ldots|}|''. |
| 189 |
% |
| 190 |
% \subsection{Derivatives symbols} |
| 191 |
% The commands ``|\DerTot{|\ldots|}{|\ldots|}|'', |
| 192 |
% ``|\DerPar{|\ldots|}{|\ldots|}|'' and ``|\DerNorm{|\ldots|}|'' |
| 193 |
% generate the symbols of total derivative, partial derivative |
| 194 |
% and normal derivative, respectively. |
| 195 |
% |
| 196 |
% \noindent |
| 197 |
% In other words, they are the same as: |
| 198 |
% \begin{verbatim} |
| 199 |
% \displaystyle\frac{d...}{d...} |
| 200 |
% \displaystyle\frac{\partial ...}{\partial ...} |
| 201 |
% \displaystyle\frac{\partial ...}{\partial n} |
| 202 |
% \end{verbatim} |
| 203 |
% |
| 204 |
% \subsection{Arrow-limits commands} |
| 205 |
% The command ``|\TendsTo|[$\cdots,\cdots$]'' generates a |
| 206 |
% right-arrow with optionally an underscript wich is another |
| 207 |
% smaller right-arrow between the two comma-separeted |
| 208 |
% arguments inside the square brackets. |
| 209 |
% |
| 210 |
% \noindent |
| 211 |
% For example, the command ``|f(x) \TendsTo[x,0] 1|'' generates |
| 212 |
% the following output: |
| 213 |
% $f(x) \mathop{\longrightarrow}\limits_{x \rightarrow 0} 1$. |
| 214 |
% |
| 215 |
% \subsection{Vector-operators commands} |
| 216 |
% Finally, the commands ``|\Grad|'', ``|\Div|'' and |
| 217 |
% ``|\Rot|'' generates the strings ``grad'', ``div'' and ``rot'' |
| 218 |
% in roman type and with small spaces added before and after, |
| 219 |
% if the ``VectOpStr'' option is in effect (default). |
| 220 |
% If, instead, the option ``VectOpSymb'' was specified, they |
| 221 |
% generate ``|\nabla|'', ``|\nabla\cdot|'' and |
| 222 |
% ``|\nabla\ProdVett|'' respectively. |
| 223 |
% |
| 224 |
% The command ``|\ProdVett|'' is intended for making the |
| 225 |
% symbol of vector product, and evaluates to ``|\times|'' |
| 226 |
% with the option ``ProdVettTimes'' and to ``|\wedge|'' with |
| 227 |
% the (default) option ``ProdVettWedge''. |
| 228 |
% |
| 229 |
% \begin{tabular}{lcccc} |
| 230 |
% & & |VectOpStr| & \multicolumn{2}{c}{|VectOpSymb|} \\ |
| 231 |
% & & &|ProdVettWedge|&|ProdVettTimes|\\ |
| 232 |
% |\Grad|& $\Rightarrow$ & $\mathrm{grad}$& $\nabla$ & $\nabla$ \\ |
| 233 |
% |\Div| & $\Rightarrow$ & $\mathrm{div}$& $\nabla\cdot$ & $\nabla\cdot$ \\ |
| 234 |
% |\Rot| & $\Rightarrow$ & $\mathrm{rot}$& $\nabla\wedge$& $\nabla\times$ |
| 235 |
% \end{tabular} |
| 236 |
% |
| 237 |
% |
| 238 |
% \StopEventually{} |
| 239 |
% \newpage |
| 240 |
% \section{Implementation} |
| 241 |
% |
| 242 |
% \begin{macrocode} |
| 243 |
%% |
| 244 |
\NeedsTeXFormat{LaTeX2e}[1995/12/01] |
| 245 |
\ProvidesPackage{\FileName}[\filedate\space v\fileversion\space\filedescr] |
| 246 |
%% |
| 247 |
\newif\if@ThreeSubscrSum |
| 248 |
\DeclareOption{ThreeSubscrSum}{\@ThreeSubscrSumtrue} |
| 249 |
\DeclareOption{TwoSubscrSum}{\@ThreeSubscrSumfalse} |
| 250 |
%% |
| 251 |
\DeclareOption{ProdVettWedge}{\let\ProdVett=\wedge} |
| 252 |
\DeclareOption{ProdVettTimes}{\let\ProdVett=\times} |
| 253 |
%% |
| 254 |
\newif\if@VectOper@Symbol |
| 255 |
\DeclareOption{VectOpStr}{\@VectOper@Symbolfalse} |
| 256 |
\DeclareOption{VectOpSymb}{\@VectOper@Symboltrue} |
| 257 |
%% |
| 258 |
\ExecuteOptions{TwoSubscrSum,ProdVettWedge,VectOpStr} |
| 259 |
% \end{macrocode} |
| 260 |
% |
| 261 |
% The ``|\ProcessOptions*|'' command was used here instead of |
| 262 |
% ``|\ProcessOptions*|'' in order to process the options in the |
| 263 |
% ``|\usepackage|'' order, rather than in the declaration order |
| 264 |
% \begin{macrocode} |
| 265 |
%% |
| 266 |
\ProcessOptions* |
| 267 |
% \end{macrocode} |
| 268 |
% |
| 269 |
% \begin{macro}{\text} |
| 270 |
% The definition of |\text| is deferred at the |\begin{document}|, |
| 271 |
% so that if the \texttt{amstext} package is loaded (even after this |
| 272 |
% package), its definition of text will be used, since it seems |
| 273 |
% better. |
| 274 |
% \begin{macrocode} |
| 275 |
%% |
| 276 |
\AtBeginDocument{\ifx\undefined\text \def\text#1{\ \mbox{#1}\ } \fi} |
| 277 |
% \end{macrocode} |
| 278 |
% \end{macro} |
| 279 |
% |
| 280 |
% \begin{macro}{\Int} |
| 281 |
% The command |\@INT@sub@SUP| has one argument and then a mandatory |
| 282 |
% superscript: il typesets an integral symbol (in |\displaystyle|) |
| 283 |
% with the argument as a lower-bound and the superscript as an |
| 284 |
% upper-bound. |
| 285 |
% \begin{macrocode} |
| 286 |
%% |
| 287 |
\def\@INT@sub@SUP#1^#2{{\displaystyle\int_{#1}^{#2}}} |
| 288 |
% \end{macrocode} |
| 289 |
% The command |\@INT@subONLY| has only an argument, which is used as |
| 290 |
% as a subscript for a |displaystyle| |\int|, but lowered of |0.2ex|. |
| 291 |
% \begin{macrocode} |
| 292 |
\def\@INT@subONLY#1{{\displaystyle\int_{\raisebox{-0.2ex}{$_{#1}$}}}} |
| 293 |
% \end{macrocode} |
| 294 |
% The command |\@INT@sub| must have a subscript and may optionally be |
| 295 |
% followed by a superscript. |
| 296 |
% \begin{macrocode} |
| 297 |
\def\@INT@sub_#1{\@ifnextchar^{\@INT@sub@SUP{#1}}{\@INT@subONLY{#1}}} |
| 298 |
% \end{macrocode} |
| 299 |
% The command |\@INT@SUP@sub| must have a superscript and a subscript, |
| 300 |
% in that order: they are passed to a |displaystyle| |\int| command. |
| 301 |
% \begin{macrocode} |
| 302 |
\def\@INT@SUP@sub^#1_#2{{\displaystyle\int_{#2}^{#1}}} |
| 303 |
% \end{macrocode} |
| 304 |
% The |\Int| command invokes |\@INT@SUP@sub| or |\@INT@sub| or simply |
| 305 |
% expands to |\displaystyle\int| depending on what follows (|^|, |_| |
| 306 |
% or neither of them). |
| 307 |
% \begin{macrocode} |
| 308 |
\newcommand{\Int}{\@ifnextchar^{\@INT@SUP@sub}{\@ifnextchar_{\@INT@sub}{\displaystyle\int}}} |
| 309 |
% \end{macrocode} |
| 310 |
% \end{macro} |
| 311 |
% |
| 312 |
% \begin{macro}{\d} |
| 313 |
% The original |\d| command is saved in |\UnderDot|, then (at the |
| 314 |
% |\begin{document}| to avoid conflicts with other packages) it is |
| 315 |
% redefined as a ``|d|'' preceeded by some space an followed by its |
| 316 |
% argument (it is intended for printing the differential symbol at |
| 317 |
% the end of an integral). |
| 318 |
% \begin{macrocode} |
| 319 |
%% |
| 320 |
\AtBeginDocument{ \let\UnderDot=\d \renewcommand{\d}[1]{\:\:d#1} } |
| 321 |
% \end{macrocode} |
| 322 |
% \end{macro} |
| 323 |
% |
| 324 |
% \begin{macro}{\Sum} |
| 325 |
% The command |\INNER@SUM| is defined differently depending on the |
| 326 |
% selected option. It has 3 or 2 orguments, ended by an exclamation |
| 327 |
% mark and separated by an equal sign and a comma. |
| 328 |
% The two last arguments are passed as a subscrit and as a superscript |
| 329 |
% to a |displaystyle| |\sum|, whereas the first argument (if they are |
| 330 |
% 3) is typeset in |scriptstyle| and lowered so that it occours at the |
| 331 |
% lower right corner of the |sum| symbol. |
| 332 |
% \begin{macrocode} |
| 333 |
%% |
| 334 |
\if@ThreeSubscrSum |
| 335 |
\def\INNER@SUM#1=#2,#3!{{\displaystyle\sum_{#2}^{#3}\raisebox{-0.6ex}{$_{\!#1}$}}} |
| 336 |
\else |
| 337 |
\def\INNER@SUM#1,#2!{{\displaystyle\sum_{#1}^{#2}}} |
| 338 |
\fi |
| 339 |
% \end{macrocode} |
| 340 |
% The |\Sum| command is then simply a call to |\INNER@SUM|, with a |
| 341 |
% question mark added to denote the end of the argument. |
| 342 |
% \begin{macrocode} |
| 343 |
\newcommand{\Sum}[1]{\INNER@SUM#1!} |
| 344 |
% \end{macrocode} |
| 345 |
% \end{macro} |
| 346 |
% |
| 347 |
% \begin{macro}{\SUM} |
| 348 |
% The |\SUM| command has one only argument which is used as a |
| 349 |
% subscript and, again, is always printed in |\displaystyle|. |
| 350 |
% \begin{macrocode} |
| 351 |
\newcommand{\SUM}[1]{{\displaystyle\sum_{#1}}} |
| 352 |
% \end{macrocode} |
| 353 |
% \end{macro} |
| 354 |
% |
| 355 |
% \begin{macro}{\DerPar} |
| 356 |
% The commands ``|\DerPar|'', ``|\DerTot|'' and ``|\DerNorm|'' generate a |
| 357 |
% |displaystyle| |\frac| command, with a ``|\partial|'' or ``|d|'' or |
| 358 |
% ``|\partial n|'' added to its arguments and followed by a little space. |
| 359 |
% \begin{macrocode} |
| 360 |
%% |
| 361 |
\newcommand\DerPar[2]{{\displaystyle\frac{\partial #1}{\partial #2}\:}} |
| 362 |
\newcommand\DerTot[2]{{\displaystyle\frac{d#1}{d#2}\:}} |
| 363 |
\newcommand\DerNorm[1]{{\displaystyle\frac{\partial #1}{\partial n}\:}} |
| 364 |
% \end{macrocode} |
| 365 |
% \end{macro} |
| 366 |
% |
| 367 |
% \begin{macro}{\TendsTo} |
| 368 |
% The command |\@TendeQuando| must be followed by a pair of square |
| 369 |
% brackets, which enclose two arguments separated by a comma. |
| 370 |
% It place a |\rightarrow| command between them and puts the whole |
| 371 |
% under a bigger |\rightarrow|. |
| 372 |
% The |\mathop| allows the |\limits| command, which, in turn, place |
| 373 |
% the subscript \emph{under} the symbol. |
| 374 |
% \begin{macrocode} |
| 375 |
%% |
| 376 |
\def\@TendeQuando[#1,#2]{ \mathop{\longrightarrow}\limits_{#1 \rightarrow #2} } |
| 377 |
% \end{macrocode} |
| 378 |
% The |\TendsTo| command invokes |\@TendeQuando| if followed by |
| 379 |
% a ``['', or |\longrightarrow| otherwise. |
| 380 |
% \begin{macrocode} |
| 381 |
\def\TendsTo{\@ifnextchar[{\@TendeQuando}{\longrightarrow}} |
| 382 |
% \end{macrocode} |
| 383 |
% \end{macro} |
| 384 |
% |
| 385 |
% \begin{macro}{\Grad} |
| 386 |
% The |\Grad|, |\Div| and |\Rot| commands generates a symbol or a |
| 387 |
% roman word, depending on the selected option. |
| 388 |
% \begin{macrocode} |
| 389 |
%% |
| 390 |
\if@VectOper@Symbol |
| 391 |
\newcommand\Grad{\nabla} |
| 392 |
\newcommand\Div{\nabla\cdot} |
| 393 |
\newcommand\Rot{\nabla\ProdVett} |
| 394 |
\else |
| 395 |
\newcommand\Grad{\:\mathrm{grad}\,} |
| 396 |
\newcommand\Div{\:\mathrm{div}\,} |
| 397 |
\newcommand\Rot{\:\mathrm{rot}\,} |
| 398 |
\fi |
| 399 |
% \end{macrocode} |
| 400 |
% \end{macro} |
| 401 |
% |
| 402 |
%\iffalse % MetaComment |
| 403 |
%<*package> |
| 404 |
%\fi |
| 405 |
% |
| 406 |
% \CheckSum{153} |
| 407 |
% \Finale |
| 408 |
% |
| 409 |
\endinput |
| 410 |
|