\documentclass[a4paper,twoside]{article} \usepackage{easytitle} \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 package \package{easyvector}} \author[E. Bertolazzi]{Enrico Bertolazzi} \address{ Laboratorio di Matematica Applicata e Meccanica Computazionale\\ Dipartimento di Ingegneria Meccanica e Strutturale\\ Universit\`a degli Studi di Trento\\ Mesiano, Trento, Italy} \mailto{enrico.bertolazzi@ing.unitn.it} \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 \newpage \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[\cmda,\cmdb]{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+\cmda+ when in scalar mode, and \verb+\cmdb+ 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} generate \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} produces \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} produces the following output: \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 the command \verb+\newcustomvector+ can be useful. Is is essentially the \verb+\newvector+ command with an extra argument that is a macro for manage the index part. \begin{BOX} \begin{verbatim} \def\myindex[#1,#2,#3]{_{#1_{#2}}^{#3}} \newcustomvector[\mathtt{a},\mathbf{a}]{aaa}\myindex \[ \aaa[1,2,3], \qquad \aaa[3,2,1], \qquad \aaa \] \end{verbatim} produces \def\myindex[#1,#2,#3]{_{#1_{#2}}^{#3}} \newcustomvector[\mathtt{a},\mathbf{a}]{aaa}\myindex \[ \aaa[1,2,3], \qquad \aaa[3,2,1], \qquad \aaa \] \end{BOX} \textbf{Important:} For the old user (version $< 0.6$) the command \verb+\customindex+ is suppressed and the \verb+\newcustomvector+ is used instead. \section{The ``definevectors'' option} This option define the following vectors for you: \begin{BOX} \begin{verbatim} \aa,\bb,...,\zz \AA,\BB,...,\ZZ \Balpha, \Bbeta, ..., \Bomega example . . \usepackage[definevectors]{easyvector} . . . \[ \Balpha[i,j], \quad \Balpha, \quad \BB[i,j], \quad \BB, \] \end{verbatim} \[ \Balpha[i,j], \quad \Balpha, \quad \BB[i,j], \quad \BB, \] \end{BOX} \section{The ``@'' convention} In linear algebra sometimes with the notation $\AA[@,j]$ we denote the vector formed by the $j^{th}$ column of $\AA$. Notice that $\AA$ is in vector format not in scalar format ($\AA[]$). We can use a ``$\bullet$'' as a index in a vector forcing the vector mode by using @ as follows index \begin{BOX} \begin{verbatim} \[ \AA[@,j], \qquad \Balpha[i,j;@] \] \end{verbatim} \[ \AA[@,j], \qquad \Balpha[i,j;@] \] \end{BOX} \end{document}