\documentclass[a4paper]{article} \usepackage[definevectors]{easyvector} \let\package\texttt % so \package{foo} comes out in \tt \let\envname\textsf % so \envname{foo} comes out as \sf \newbox\tempbox \def\BOX{% \setbox\tempbox\hbox\bgroup \begin{minipage}{0.9\textwidth} } \def\endBOX{% \end{minipage} \egroup \par\bigskip \begin{center} \fboxsep=10pt\fbox{\box\tempbox} \end{center} \bigskip\par } \title{The packages \package{easyvector}} \author{Enrico Bertolazzi\\\\ Laboratorio di Matematica Applicata\\ Dipartimento di Ingegneria Civile ed Ambientale\\ Universit\`a degli Studi di Trento\\ Mesiano, Trento, Italy\\\\ \texttt{bertolaz@ing.unitn.it}} \date{} \begin{document} \maketitle \begin{abstract} The \package{easyvector} package is a simple macro package that provides a C-like syntax for writing vectors or matrices. \end{abstract} \tableofcontents \section{Some examples with \package{easyvector}} Load the package in the usual way: \begin{BOX} \begin{verbatim} \documentclass{article} . . \usepackage[spacesep,definevectors]{easyvector} . . \end{verbatim} \end{BOX} The package option \texttt{spacesep} means that the separator for the indices is \verb+\smallspace+ instead of ``$,$''~(comma). The package option \texttt{definevectors} means that the command \verb+\aa+\ldots\verb+\zz+ and \verb+\AA+\ldots\verb+\ZZ+ are predefined as vectors. It also define the commands \verb+\Balpha+, \verb+\Bbeta+ and so on, as bold greek vectors. The latex commands \verb+\aa+, \verb+\AA+, \verb+\gg+, \verb+\l+, \verb+\ss+, \verb+\SS+\, \verb+\tt+ are saved in the commands \verb+\oldxx+ where \verb+xx+ is the name of the old command. \section{Use of the \texttt{\char`\\newvector} command} The general syntax of \verb+\newvector+ command is \begin{verbatim} \newvector[a,b]{cmd} \end{verbatim} or \begin{verbatim} \newvector(a)[cmd] \end{verbatim} In the first case, it creates the new command (macro) \verb+\cmd+ which executes \verb+a+ when in scalar mode, and \verb+b+ when in vector mode. In the second case it creates a new command \verb+\cmd+ which substitutes the letter \verb+\mathit{a}+ when in scalar, mode and \verb+\mathbf{a}+ when in vector mode. Scalar mode is activated when \verb+\cmd+ is immediately followed by~$[$. In scalar mode everything between $[$~and~$]$ (with balancing) is assumed to be indices. For example the commands \begin{BOX} \begin{verbatim} \newvector[\alpha,\beta]{W} \newvector[X,\mathbf{X}]{X} \[ \W = (\W[i,j]), \qquad \X = (\X[i,j;k])\] \end{verbatim} \end{BOX} generate \begin{BOX} \newvector[\alpha,\beta]{W} \newvector[X,\mathbf{X}]{X} \[ \W = (\W[i,j]), \qquad \X = (\X[i,j;k])\] \end{BOX} The structure of the $[\ldots]$ command is the following \begin{verbatim} [i,j,...,k;x,y,...,z] \end{verbatim} where \verb+i,j,...,k+ are subscripts and \verb+x,y,...,z+ are superscripts. The character $,$~is used as a separator between different indices, and the character $;$~separates subscripts and superscripts. There are no limits on the number of indices, and the code is reentrant, as the following example illustrates \begin{BOX} \begin{verbatim} \newvector(a)[av] \newvector(b)[bv] \[ \av = \pmatrix{ \av[1,1] & \av[1,2] \cr \av[2,1] & \av[2,2] \cr}, \qquad \bv = \left\{ \bv[\gamma,\bv[i,j;k];a] \right\} \] \end{verbatim} \end{BOX} produces \begin{BOX} \newvector(a)[av] \newvector(b)[bv] \[ \av = \pmatrix{ \av[1,1] & \av[1,2] \cr \av[2,1] & \av[2,2] \cr}, \qquad \bv = \left\{ \bv[\gamma,\bv[i,j;k];a] \right\} \] \end{BOX} \section{Use of the \texttt! command} In some circumstances it is useful to force vector mode also when using indices. It is possible by using the character~\verb+!+ before~\verb+[+ \begin{BOX} \begin{verbatim} \newvector(z)[zzz] \[ \zzz[1,2,3] \neq \zzz![1,2,3] \] \end{verbatim} \end{BOX} which produces the following output: \begin{BOX} \newvector(z)[zzz] \[ \zzz[1,2,3] \neq \zzz![1,2,3] \] \end{BOX} \section{Use of the \texttt{\char`\\newcustomvector} command} In some circumstances this command can be useful, e.g., \begin{BOX} \begin{verbatim} \def\myindex[#1,#2,#3]{_{#1_{#2}}^{#3}} \newcustomvector[a,a]{aaa}\myindex \[ \aaa[1,2,3] = \aaa[3,2,1] \] \end{verbatim} \end{BOX} which produces \begin{BOX} \def\myindex[#1,#2,#3]{_{#1_{#2}}^{#3}} \newcustomvector[a,a]{aaa}\myindex \[ \aaa[1,2,3] = \aaa[3,2,1] \] \end{BOX} \textbf{Important:} For the old user (version $< 0.6$) the command \verb+\customindex+ is suppressed and the \verb+\newcustomvector+ is used instead. \end{document}