%\iffalse % MetaComment
%%
%% + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
%% |            Copyright(C) 1997-2010 by F. Bosisio             |
%% |                                                             |
%% | This program can be redistributed and/or modified under	 |
%% | the terms of the LaTeX Project Public License, either       |
%% | version 1.3 of this license or (at your option) any later   |
%% | version. The latest version of this license is in           |
%% |   http://www.latex-project.org/lppl.txt                     |
%% | and version 1.3 or later is part of all LaTeX distributions |
%% | version 2005/12/01 or later.                                |
%% |                                                             |
%% | This work has the LPPL maintenance status `maintained'.     |
%% | The Current Maintainer of this work is F. Bosisio.          |
%% |                                                             |
%% | This work consists of files mathcmd.dtx and mathcmd.html    |
%% | and of the derived files mathcmd.sty and mathcmd.pdf.       |
%% |                                                             |
%% | E-mail:   fbosisio@bigfoot.com                              |
%% | CTAN location: macros/latex/contrib/bosisio/                |
%% + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
%%
%%      If you make any improvment, find any bug or have
%%      any suggestion, please let me know about it.
%%
%<*package,driver>
%\fi
%
\def\FileName{mathcmd}
%\iffalse % MetaComment
%</package,driver>
%<*package>
%\fi
\def\fileversion{2.2}
\def\filedate{1997/12/20}
\def\docdate{2005/04/09}
\def\filedescr{Extensions to math environments (FB)}
%
%\iffalse % MetaComment
%</package>
%<*dtx>
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%		This section is the installation driver
%
\def\batchfile{\FileName.dtx}
%
\input docstrip
%
\keepsilent
% \askforoverwritefalse
%
\generateFile{\FileName.sty}{f}{\from{\FileName.dtx}{package}}
%
\generateFile{\FileName.drv}{f}{\from{\FileName.dtx}{driver}}
%
\Msg{******************************************************}
\Msg{*}
\Msg{* To produce the documentation run the}
\Msg{* file `\FileName.drv' through LaTeX.}
\Msg{*}
\Msg{******************************************************}
%
\endbatchfile
%
%		End of the installation driver
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%</dtx>
%
%		This section is the documentation driver
%
%<+driver>\documentclass[12pt,a4paper]{ltxdoc}
%<+driver>  \EnableCrossrefs
%<+driver>  \CodelineIndex
%<+driver>  \RecordChanges
%<+driver>  %\OnlyDescription   % Uncomment not to see the implementation
%<+driver>\begin{document}
%<+driver>  \DocInput{\FileName.dtx}
%<+driver>  \PrintIndex
%<+driver>  \PrintChanges
%<+driver>\end{document}
%
%		End of the documentation driver
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%<*package>
%\fi
%
% \changes{v0.1}{20 April 1997}{First release (basic environments)}
% \changes{v0.2}{3 May 1997}{Added package options}
% \changes{v1.0}{24 May 1997}{Documentation added}
% \changes{v2.0}{20 December 1997}{Separated from package ``mathenv''}
% \changes{v2.1}{5 March 1999}{Added copyright notice and changed addresses}
% \changes{v2.2}{9 April 2005}{Usage of the double-quote character (") avoided}
%
% \MakeShortVerb{\|}
%
% \title{Package \texttt{\FileName}\thanks{This is version \fileversion,
% last revised \filedate; documentation date \docdate}}
% \author{F. Bosisio\\\normalsize E-mail: \texttt{fbosisio@bigfoot.com}}
% \date{\filedate}
% \maketitle
%
% \begin{abstract}
%	Documentation for the package \texttt{\FileName}.
% \end{abstract}
%
% \section{Introduction}
%	This package provides some useful math-commands which are simpler
%	to use and prettier then their standard \LaTeX{} counterpart.
%
%	In particular the ``|\d|'' command is redefined, so
%	care should be taken, expecially when including this package in an
%	already existent \LaTeX{} file.
%
%	\noindent
%	The original work of ``|\d|'' (i.e. place a dot under its argument)
%	is now done by the ``|\UnderDot|'' command.
%
% \section{The options}
%	At now, six options are available with the \texttt{\FileName}
%	package, which comes out in matched pairs.
%
%	\noindent
%	The ``|ThreeSubscrSum|'' and ``|TwoSubscrSum|'' options control the
%	placement of subscripts for the ``|\Sum|'' command: the latter
%	(which is the default) puts the index under the simbol toghether
%	with the starting point, while the former puts the index on the
%	lower right corner.
%
%	\noindent
%	The ``|ProdVettWedge|'' and ``|ProdVettTimes|'' options select
%	which symbol is to be used for the \emph{vector product}: the first
%	one uses a ``|\wedge|'' (default), whilst the second uses a
%	``|\times|''.
%
%	\noindent
%	Finally, the ``|VectOpStr|'' and ``|VectOpSymb|'' options controls
%	whether the vector-operator commands ``|\Grad|'', ``|\Div|'' and
%	``|\Rot|'' should produce a roman string (default) or a
%	``|\nabla|'' symbol followed by an operator, respectively.
%
% \section{Math-mode commands}
%	The \texttt{\FileName} package defines a number of math-mode
%	commands.
%
%	\subsection{The \texttt{text} command}
%		The ``|\text{|\ldots|}|'' command is defined to be
%		equivalent to ``|\mbox|'' (except when the ``|amstext|''
%		package is also used, since this package already defines
%		this command in a better way).
%
%		\noindent
%		It is intended for inserting pieces of text in a formula.
%
%	\subsection{Commands for doing integrals}
%		The ``|\Int|'' (capitalized) differs from the \LaTeX{}
%		command ``|\int|'' in that it is always printed in
%		|displaystyle| and if it has only a subscript, this is
%		somewhat lowered so that it looks better.
%		\begin{verbatim}
%		   \Int_{...}^{...}	  ...	   \d{...}
%		\end{verbatim}
%
%		The ``|\d{|\ldots|}|'' command is for making the
%		differential symbol at the end of integrals: it simply
%		prints a ``|d|'' followed by its argument and preceded by
%		a little space, which seems prettier.
%
%	\subsection{Commands for making sums}
%		The ``|\Sum{|$\cdots=\cdots,\cdots$|}|'' command works
%		differently, depending on which option between
%		``|TwoSubscrSum|'' (default) and ``|ThreeSubscrSum|'' has
%		been specified.
%
%		\noindent
%		In the first case, it expands to
%		``|\displaystyle\sum_{...=...}^{...}|'', whereas in the
%		second case the second and third argument are treated
%		in the same way as before (i.e. as a subscript and
%		superscript, respectively), but the first argument
%		(the one before the ``='') is placed near
%		the lower-left edge of the ``|\sum|'' symbol and the ``=''
%		is not printed.
%
%		There is also a ``|\SUM{|\ldots|}|'' command which is useful
%		when only a subscript is desired, irrespectively of the
%		option specified: in fact, is is equivalent to
%		``|\displaystyle\sum_{|\ldots|}|''.
%
%	\subsection{Derivatives symbols}
%		The commands ``|\DerTot{|\ldots|}{|\ldots|}|'',
%		``|\DerPar{|\ldots|}{|\ldots|}|'' and ``|\DerNorm{|\ldots|}|''
%		generate the symbols of total derivative, partial derivative
%		and normal derivative, respectively.
%
%		\noindent
%		In other words, they are the same as:
%		\begin{verbatim}
%		   \displaystyle\frac{d...}{d...}
%		   \displaystyle\frac{\partial ...}{\partial ...}
%		   \displaystyle\frac{\partial ...}{\partial n}
%		\end{verbatim}
%
%	\subsection{Arrow-limits commands}
%		The command ``|\TendsTo|[$\cdots,\cdots$]'' generates a
%		right-arrow with optionally an underscript wich is another
%		smaller right-arrow between the two comma-separeted
%		arguments inside the square brackets.
%
%		\noindent
%		For example, the command ``|f(x) \TendsTo[x,0] 1|'' generates
%		the following output:
%		$f(x) \mathop{\longrightarrow}\limits_{x \rightarrow 0} 1$.
%
%	\subsection{Vector-operators commands}
%		Finally, the commands ``|\Grad|'', ``|\Div|'' and
%		``|\Rot|'' generates the strings ``grad'', ``div'' and ``rot''
%		in roman type and with small spaces added before and after,
%		if the ``VectOpStr'' option is in effect (default).
%		If, instead, the option ``VectOpSymb'' was specified, they
%		generate ``|\nabla|'', ``|\nabla\cdot|'' and
%		``|\nabla\ProdVett|'' respectively.
%
%		The command ``|\ProdVett|'' is intended for making the
%		symbol of vector product, and evaluates to ``|\times|''
%		with the option ``ProdVettTimes'' and to ``|\wedge|'' with
%		the (default) option ``ProdVettWedge''.
%
%		\begin{tabular}{lcccc}
%			&	&  |VectOpStr|	& \multicolumn{2}{c}{|VectOpSymb|}	\\
%			&		&		&|ProdVettWedge|&|ProdVettTimes|\\
%		 |\Grad|& $\Rightarrow$ & $\mathrm{grad}$& $\nabla$	& $\nabla$	\\
%		 |\Div|	& $\Rightarrow$ & $\mathrm{div}$& $\nabla\cdot$	& $\nabla\cdot$	\\
%		 |\Rot|	& $\Rightarrow$	& $\mathrm{rot}$& $\nabla\wedge$& $\nabla\times$
%		\end{tabular}
%
%
% \StopEventually{}
% \newpage
% \section{Implementation}
%
%    \begin{macrocode}
%%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{\FileName}[\filedate\space v\fileversion\space\filedescr]
%%
\newif\if@ThreeSubscrSum
\DeclareOption{ThreeSubscrSum}{\@ThreeSubscrSumtrue}
\DeclareOption{TwoSubscrSum}{\@ThreeSubscrSumfalse}
%%
\DeclareOption{ProdVettWedge}{\let\ProdVett=\wedge}
\DeclareOption{ProdVettTimes}{\let\ProdVett=\times}
%%
\newif\if@VectOper@Symbol
\DeclareOption{VectOpStr}{\@VectOper@Symbolfalse}
\DeclareOption{VectOpSymb}{\@VectOper@Symboltrue}
%%
\ExecuteOptions{TwoSubscrSum,ProdVettWedge,VectOpStr}
%    \end{macrocode}
%
%    The ``|\ProcessOptions*|'' command was used here instead of
%    ``|\ProcessOptions*|'' in order to process the options in the
%    ``|\usepackage|'' order, rather than in the declaration order
%    \begin{macrocode}
%%
\ProcessOptions*
%    \end{macrocode}
%
% \begin{macro}{\text}
%	The definition of |\text| is deferred at the |\begin{document}|,
%	so that if the \texttt{amstext} package is loaded (even after this
%	package), its definition of text will be used, since it seems
%	better.
%    \begin{macrocode}
%%
\AtBeginDocument{\ifx\undefined\text \def\text#1{\ \mbox{#1}\ } \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Int}
%	The command |\@INT@sub@SUP| has one argument and then a mandatory
%	superscript: il typesets an integral symbol (in |\displaystyle|)
%	with the argument as a lower-bound and the superscript as an
%	upper-bound.
%    \begin{macrocode}
%%
\def\@INT@sub@SUP#1^#2{{\displaystyle\int_{#1}^{#2}}}
%    \end{macrocode}
%	The command |\@INT@subONLY| has only an argument, which is used as
%	as a subscript for a |displaystyle| |\int|, but lowered of |0.2ex|.
%    \begin{macrocode}
\def\@INT@subONLY#1{{\displaystyle\int_{\raisebox{-0.2ex}{$_{#1}$}}}}
%    \end{macrocode}
%	The command |\@INT@sub| must have a subscript and may optionally be
%	followed by a superscript.
%    \begin{macrocode}
\def\@INT@sub_#1{\@ifnextchar^{\@INT@sub@SUP{#1}}{\@INT@subONLY{#1}}}
%    \end{macrocode}
%	The command |\@INT@SUP@sub| must have a superscript and a subscript,
%	in that order: they are passed to a |displaystyle| |\int| command.
%    \begin{macrocode}
\def\@INT@SUP@sub^#1_#2{{\displaystyle\int_{#2}^{#1}}}
%    \end{macrocode}
%	The |\Int| command invokes |\@INT@SUP@sub| or |\@INT@sub| or simply
%	expands to |\displaystyle\int| depending on what follows (|^|, |_|
%	or neither of them).
%    \begin{macrocode}
\newcommand{\Int}{\@ifnextchar^{\@INT@SUP@sub}{\@ifnextchar_{\@INT@sub}{\displaystyle\int}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\d}
%	The original |\d| command is saved in |\UnderDot|, then (at the
%	|\begin{document}| to avoid conflicts with other packages) it is
%	redefined as a ``|d|'' preceeded by some space an followed by its
%	argument (it is intended for printing the differential symbol at
%	the end of an integral).
%    \begin{macrocode}
%%
\AtBeginDocument{ \let\UnderDot=\d \renewcommand{\d}[1]{\:\:d#1} }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Sum}
%	The command |\INNER@SUM| is defined differently depending on the
%	selected option. It has 3 or 2 orguments, ended by an exclamation
%	mark and separated by an equal sign and a comma.
%	The two last arguments are passed as a subscrit and as a superscript
%	to a |displaystyle| |\sum|, whereas the first argument (if they are
%	3) is typeset in |scriptstyle| and lowered so that it occours at the
%	lower right corner of the |sum| symbol.
%    \begin{macrocode}
%%
\if@ThreeSubscrSum
  \def\INNER@SUM#1=#2,#3!{{\displaystyle\sum_{#2}^{#3}\raisebox{-0.6ex}{$_{\!#1}$}}}
\else
  \def\INNER@SUM#1,#2!{{\displaystyle\sum_{#1}^{#2}}}
\fi
%    \end{macrocode}
%	The |\Sum| command is then simply a call to |\INNER@SUM|, with a
%	question mark added to denote the end of the argument.
%    \begin{macrocode}
\newcommand{\Sum}[1]{\INNER@SUM#1!}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\SUM}
%	The |\SUM| command has one only argument which is used as a
%	subscript and, again, is always printed in |\displaystyle|.
%    \begin{macrocode}
\newcommand{\SUM}[1]{{\displaystyle\sum_{#1}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\DerPar}
%	The commands ``|\DerPar|'', ``|\DerTot|'' and ``|\DerNorm|'' generate a
%	|displaystyle| |\frac| command, with a ``|\partial|'' or ``|d|'' or
%	``|\partial n|'' added to its arguments and followed by a little space.
%    \begin{macrocode}
%%
\newcommand\DerPar[2]{{\displaystyle\frac{\partial #1}{\partial #2}\:}}
\newcommand\DerTot[2]{{\displaystyle\frac{d#1}{d#2}\:}}
\newcommand\DerNorm[1]{{\displaystyle\frac{\partial #1}{\partial n}\:}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\TendsTo}
%	The command |\@TendeQuando| must be followed by a pair of square
%	brackets, which enclose two arguments separated by a comma.
%	It place a |\rightarrow| command between them and puts the whole
%	under a bigger |\rightarrow|.
%	The |\mathop| allows the |\limits| command, which, in turn, place
%	the subscript \emph{under} the symbol.
%    \begin{macrocode}
%%
\def\@TendeQuando[#1,#2]{ \mathop{\longrightarrow}\limits_{#1 \rightarrow #2} }
%    \end{macrocode}
%	The |\TendsTo| command invokes |\@TendeQuando| if followed by
%	a ``['', or |\longrightarrow| otherwise.
%    \begin{macrocode}
\def\TendsTo{\@ifnextchar[{\@TendeQuando}{\longrightarrow}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Grad}
%	The |\Grad|, |\Div| and |\Rot| commands generates a symbol or a
%	roman word, depending on the selected option.
%    \begin{macrocode}
%%
\if@VectOper@Symbol
  \newcommand\Grad{\nabla}
  \newcommand\Div{\nabla\cdot}
  \newcommand\Rot{\nabla\ProdVett}
\else
  \newcommand\Grad{\:\mathrm{grad}\,}
  \newcommand\Div{\:\mathrm{div}\,}
  \newcommand\Rot{\:\mathrm{rot}\,}
\fi
%    \end{macrocode}
% \end{macro}
%
%\iffalse % MetaComment
%<*package>
%\fi
%
% \CheckSum{153}
% \Finale
%
\endinput