            The package easyvector

Enrico Bertolazzi Laboratorio di Matematica Applicata e Meccanica Computazionale Dipartimento di Ingegneria Meccanica e Strutturale Università degli Studi di Trento Mesiano, Trento, Italy

                  mailto:enrico.bertolazzi@ing.unitn.it

Abstract—The easyvector package is a simple macro package that provides a C-like syntax for writing vectors or matrices.

Contents

1 Some examples with easyvector 2 2 Use of the \newvector command 2 3 Use of the ! command 3 4 Use of the \newcustomvector command 3 5 The “definevectors” option 4 6 The “@” convention 4

1 Some examples with easyvector

Load the package in the usual way:

      \documentclass{article}
      .
      .
      \usepackage[spacesep,definevectors]{easyvector}
      .
      .

The package option spacesep means that the separator for the indices is \smallspace instead of “,” (comma).

The package option definevectors means that the command \aa… \zz and \AA… \ZZ are predefined as vectors. It also define the commands \Balpha, \Bbeta and so on, as bold greek vectors. The latex commands \aa, \AA, \gg, \l, \ss, \SS \tt are saved in the commands \oldxx where xx is the name of the old command.

2 Use of the \newvector command

The general syntax of \newvector command is

    \newvector[\cmda,\cmdb]{cmd}

or

    \newvector(a)[cmd]

In the first case, it creates the new command (macro) \cmd which executes \cmda when in scalar mode, and \cmdb when in vector mode. In the second case it creates a new command \cmd which substitutes the letter \mathit{a} when in scalar, mode and \mathbf{a} when in vector mode. Scalar mode is activated when \cmd is immediately followed by [. In scalar mode everything between [ and ] (with balancing) is assumed to be indices. For example the commands

   \newvector[\alpha,\beta]{W}
   \newvector[X,\mathbf{X}]{X}
   \[ \W = (\W[i,j]), \qquad \X = (\X[i,j;k])\]

generate

β = (α_{i,j}), X = (X_{i,j}^{k})

The structure of the […] command is the following

[i,j,...,k;x,y,...,z]

where i,j,...,k are subscripts and 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

\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\}
\]

produces

a = ( \begin{matrix}a_{1,1} & a_{1,2} \\ a_{2,1} & a_{2,2} \end{matrix} ) , b = \{b_{γ,b_{i,j}^{k}}^{a}\}

3 Use of the ! command

In some circumstances it is useful to force vector mode also when using indices. It is possible by using the character ! before [

\newvector(z)[zzz]
\[ \zzz[1,2,3] \neq \zzz![1,2,3] \]

produces the following output:

z_{1,2,3} ≠ z_{1,2,3}

4 Use of the \newcustomvector command

In some circumstances the command \newcustomvector can be useful. Is is essentially the \newvector command with an extra argument that is a macro for manage the index part.

\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 \]

produces

a_{1_{2}}^{3},  a_{3_{2}}^{1},  a

Important: For the old user (version < 0.6) the command \customindex is suppressed and the \newcustomvector is used instead.

5 The “definevectors” option

This option define the following vectors for you:

\aa,\bb,...,\zz    \AA,\BB,...,\ZZ
\Balpha, \Bbeta, ..., \Bomega
example
.
.
\usepackage[definevectors]{easyvector}
.
.
.
\[ \Balpha[i,j], \quad \Balpha,
   \quad \BB[i,j], \quad \BB, \]

α_{i,j}, α, B_{i,j}, B,

6 The “@” convention

In linear algebra sometimes with the notation A_{•,j} we denote the vector formed by the j^{th} column of A. Notice that A is in vector format not in scalar format (A). We can use a “•” as a index in a vector forcing the vector mode by using @ as follows index

\[ \AA[@,j], \qquad \Balpha[i,j;@] \]

A_{•,j}, α_{i,j}^{•}