The hhtensor package^{∗}

Harald Harders

                   h.harders@tu-bs.de

File Date 2003/10/15, Printed 15th October 2003

Abstract

This package provides commands for vectors, matrices, and tensors with different styles (arrows as the L^{A}TEX default, underlined, and bold).

Contents

1 Load the package 1

2 Usage 1

3 The implementation 2

Copyright

Copyright 2003 Harald Harders.

This program can be redistributed and/or modified under the terms of the LaTeX Project Public License Distributed from CTAN archives in directory macros/latex/base/lppl.txt; either version 1 of the License, or any later version.

1 Load the package

To use this package place

\usepackage[⟨style⟩]{⟨hhtensor⟩}

in the preamble of your document. The ⟨style⟩ is arrow, bold, or uline for arrow style, bold symbols, resp. underlined symbols. Default is arrow.

2 Usage

\vec Vectors are printed as usual using the \vec{⟨symbol⟩} command. Depending on

the style, they are printed α⃗, α, resp. α. \matr Matrices are printed using \matr{⟨symbol⟩}: α⃗, α, resp. α. \tens Tensors are a little bit different. They take two arguments while the first one is the symbol, while the second is the step: \tens{⟨symbol⟩}{⟨step⟩}. This leads

∗This file has version 0.6 last revised 2003/10/15, documentation dated 2003/10/15.

to \begin{matrix}α \\ ∼ \\ 4 \end{matrix}, α, resp. \begin{matrix}α \\ ∼ \\ 4 \end{matrix}.

In the bold style, it is not distinguished between vectors, matrices, and tensors. I would like to use upright symbols but then you cannot use all symbols because there is no full upright bold math alphabet.

\dcdot The \dcdot command produces a double dot for double scalar products, e.g.,

σ⃗ = \begin{matrix}A \\ ∼ \\ 4 \end{matrix} ·· ε⃗.

\trans \trans produces a transponed sign: A⃗^{T} = B⃗.

3 The implementation

Heading of the package:

 1 \NeedsTeXFormat{LaTeX2e}
 2 \ProvidesPackage{hhtensor}[\filedate\space v\fileversion\space
 3 Print numbers]
 4 \message{Package `hhtensor', Version \fileversion\space of \filedate.}

ushort underlines with shorter lines than \underline.

 5 \RequirePackage{ushort}

amsmath for bold symbols.

 6 \RequirePackage{amsmath}

Booleans to decide which version has to be used.

 7 \newif\iftensor@bold
 8 \newif\iftensor@uline

Package options that set the booleans.

 9 \DeclareOption{bold}{\tensor@boldtrue\tensor@ulinefalse}
10 \DeclareOption{uline}{\tensor@boldfalse\tensor@ulinetrue}
11 \DeclareOption{arrow}{\tensor@boldfalse\tensor@ulinefalse}

Default are arrows, as in standard L^{A}TEX.

12 \ExecuteOptions{arrow}
13 \ProcessOptions\relax

\origvec Save the original \vec command.

14 \newcommand\origvec{}
15 \let\origvec=\vec

If bold vectors and tensors are requested, execute this code.

16 \iftensor@bold

\vec Redefine the \vec command.

17 \DeclareRobustCommand*\vec[1]{\ensuremath{\boldsymbol{#1}}}

\matr Defined the \matr command.

18 \DeclareRobustCommand*\matr[1]{\ensuremath{\boldsymbol{#1}}}

\tens Defined the \tens command.

19 \DeclareRobustCommand*\tens[2]{\ensuremath{\boldsymbol{#1}}}

Underlined vectors?

20 \else
21 \iftensor@uline

\vec Vectors underlined.

22  \DeclareRobustCommand*\vec[1]{\ushort{#1}}

\matr Matrices double underlined.

23  \DeclareRobustCommand*\matr[1]{\ushortd{#1}}

\tens Tensors with number of step below.

24  \DeclareRobustCommand*\tens[2]{%
25  \begingroup
26  \setlength{\arraycolsep}{0pt}
27  \begin{array}[t]{c}%
28  #1 \\[-2.05ex]
29  {\scriptstyle \sim} \\[-2.1ex]
30  {\scriptscriptstyle #2}\\[-0.7ex]
31  \end{array}%
32  \endgroup

33 }

Vectors with an arrow. Since this is the default, the \vec command has not to be redefined.

34 \else

\matr Matrix.

35  \DeclareRobustCommand*\matr[1]{\ensuremath{\vec{\vec{#1}}}}

\tens Tensors with number of step below. That does not fit well to the arrow styles, but I don’t know a better solution. Does somebody have one?

36  \DeclareRobustCommand*\tens[2]{%
37  \begingroup
38  \setlength{\arraycolsep}{0pt}
39  \begin{array}[t]{c}%
40  #1 \\[-2.05ex]
41  {\scriptstyle \sim} \\[-2.1ex]
42  {\scriptscriptstyle #2}\\[-0.7ex]
43  \end{array}%
44  \endgroup

45 }

46 \fi
47 \fi

\dcdot Double scalar product.

48 \DeclareRobustCommand*\dcdot{\mathrel{\cdot\mkern 0.0mu \cdot}}%

\trans Transformed sign.

49 \DeclareRobustCommand*\trans{^{\mathrm{T}}}

Change History

0.6 General: Total new implementation 1

Index

Numbers written in italic refer to the page where the corresponding entry is described; numbers underlined refer to the code line of the definition; numbers in roman refer to the code lines where the entry is used.

A

\arraycolsep . . . . 26, 38

B

\begin . . . . . . . . . 27, 39

\boldsymbol . . . . . 17–19

C

\cdot . . . . . . . . . . . . 48

D

\dcdot . . . . . . . . . . 2, \underline{48}

\DeclareOption . . . 9–11

E

\end . . . . . . . . . . . 31, 43

\ExecuteOptions . . . 12

I

\iftensor@bold . . . 7, 16

\iftensor@uline . . 8, 21

M

\mathrel . . . . . . . . . 48 \matr . . . . . 1, \underline{18}, \underline{23}, \underline{35} \mkern . . . . . . . . . . . 48

N

\NeedsTeXFormat . . . . 1

O

\origvec . . . . . . . . . \underline{14}

P

\ProcessOptions . . . 13
\ProvidesPackage . . . 2

R

\RequirePackage . . 5, 6

S

\scriptscriptstyle .

. . . . . . . . . 30, 42

\scriptstyle . . . . 29, 41

\sim . . . . . . . . . . . 29, 41

T

\tens . . . . . 1, \underline{19}, \underline{24}, \underline{36}

\tensor@boldfalse 10, 11
\tensor@boldtrue . . . 9
\tensor@ulinefalse 9, 11
\tensor@ulinetrue . 10

\trans . . . . . . . . . . 2, \underline{49}

U

\ushort . . . . . . . . . . 22 \ushortd . . . . . . . . . 23

V

\vec … 1, 15, \underline{17}, \underline{22}, 35