summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/mattens/mattens.dtx
blob: 6833a44460e1f4045bf5133bc282bd3c6369de34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
% \iffalse  meta-comment
%
% mattens.dtx
% Copyright (C) 2001--2009 Danie Els
%
% -------------------------------------------------------------------
%                     The mattens package
%                 for vector/tensor typesetting
% -------------------------------------------------------------------
% This work may be distributed and/or modified under the conditions
% of the LaTeX Project Public License, either version 1.3c 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.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status 'maintained'.
%
% This Current Maintainer of this work is Danie Els (dnjels@sun.ac.za)
%
% This package consists of the files: mattens.dtx
%                                     mattens.ins
%              and the derived files: mattens.sty
% -------------------------------------------------------------------
%
% \fi
%
% \iffalse
%<*driver>
\documentclass[a4paper]{ltxdoc}
    \makeatletter
    \newcommand{\DeclareSBox}[2]{%
        \@ifdefinable{#1}{%
            \edef\tempa{\expandafter\@gobble\string#1}%
            \edef\tempa{\csname MTbox@\tempa\endcsname}%
            \expandafter\newbox\tempa
            \global\sbox{\tempa}{#2}%
            \protected@xdef#1{\noexpand\usebox{\tempa}}}}
\usepackage{amsmath}
\usepackage{amsfonts}
    \DeclareMathSymbol{\square}{\mathord}{AMSa}{"03}
    \newcommand*{\m}{\raisebox{.1ex}{$\scriptscriptstyle\square$}}
    \DeclareMathAlphabet{\mathsfsl}{OT1}{cmss}{m}{sl}
\usepackage{color}
      % Declare the following saved box before
      % the accents and bm packages are loaded
    \DeclareSBox{\AccentBox}{$\dot{\overline{f}}^a_b$}
\usepackage{array}
\usepackage{accents}
    \newcommand{\dotr}[1]{\accentset{\phantom{r}{\displaystyle.}r}{#1}}
\usepackage{mattens}
\usepackage{bm}
    \bmdefine{\bO}{\mathit{\Omega}}

    \newcommand*{\pkg}[1]{\textsf{#1}}
    \newcommand*{\opt}[1]{\textsf{#1}}
    \newcommand*{\MT}{\pkg{mattens}}
    \newcommand*{\Hass}{Hassenpflug}
    \newcommand*{\myemph}[1]{\emph{#1}}
    \newenvironment{Decl}%
         {\par\small\addvspace{2.3ex plus 1ex}%
          \vskip -\parskip
          \noindent\hspace{\leftmargini}%
          \begin{tabular}{|l|}\hline\ignorespaces}%
         {\\\hline\end{tabular}\nobreak\par\nobreak
          \vspace{2.3ex}\vskip -\parskip}
    \newenvironment{Indent}[1]{%
        \begin{list}{}{%
            \setlength{\topsep}{0pt}%
            \setlength{\leftmargin}{#1}%
            \setlength{\listparindent}{\parindent}%
            \setlength{\itemindent}{\parindent}%
            \setlength{\parsep}{\parskip}}%
            \item[]
        }{\end{list}}
    \newenvironment{sample}{%
        \begin{quote}\small\begin{tabbing}%
                \hskip12pc\=\kill}%
        {\end{tabbing}\end{quote}}
    \newcommand*{\sphline}{%     horizontal table line with spaces
        \noalign{\vskip3pt}\hline\noalign{\vskip3pt}}
    \newcommand*{\tdot}{\ensuremath{\cdot}}
    \newcommand*{\trnsp}{\ensuremath{\mathsf{T}}}
    \newcommand*{\norm}[1]{\ensuremath{\lVert{#1}\rVert}}
    \newcommand*{\SB}[1]{\ensuremath{\left[\, #1\right]}}

    \MakeShortVerb{\|}
    \EnableCrossrefs
   %\DisableCrossrefs      % Say \DisableCrossrefs if index is ready
    \CodelineIndex
    \RecordChanges         % Gather update information
   %\OnlyDescription       % comment out for implementation details
    \setlength\hfuzz{15pt} % dont make so many
    \hbadness=7000         % over and under full box warnings
    \makeatother
\begin{document}
   \DocInput{mattens.dtx}
\end{document}
%</driver>
%
% \fi
%
% \CheckSum{584}
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
%
% \DoNotIndex{\,, \@empty, \@gobble, \@ifnextchar, \@ifstar,
%             \@ifundefined, \@firstofone}
% \DoNotIndex{\addtolength}
% \DoNotIndex{\begingroup, \boldsymbol, \box}
% \DoNotIndex{\copy, \csname, \CurrentOption}
% \DoNotIndex{\DeclareOption, \DeclareRobustCommand, \def, \dp}
% \DoNotIndex{\edef, \else, \endcsname, \endgroup, \ensuremath,
%             \expandafter}
% \DoNotIndex{\fi}
% \DoNotIndex{\global}
% \DoNotIndex{\hskip, \ht}
% \DoNotIndex{\ifdim, \ifx}
% \DoNotIndex{\leavevmode, \left, \let, \lVert}
% \DoNotIndex{\m@th, \mathpalette, \mathsf, \mathstrut, \mskip}
% \DoNotIndex{\NeedsTeXFormat, \newbox, \newcommand, \newif, \newlength,
%             \newmuskip, \newsavebox, \null}
% \DoNotIndex{\overline}
% \DoNotIndex{\PackageError, \PackageWarning, \ProcessOptions, \protect,
%             \protected@xdef, \providecommand, \ProvidesPackage}
% \DoNotIndex{\relax, \renewcommand, \RequirePackage, \right, \rlap,
%             \rVert}
% \DoNotIndex{\sbox, \setbox, \setlength, \space, \string}
% \DoNotIndex{\the}
% \DoNotIndex{\underline, \usebox, \wd, \widetilde}
% \DoNotIndex{\z@}
%
% \changes{1.0}{2001 Dec 9}{Initial version}
% \changes{1.1}{2004 Jan 15}{Doc: Updated}
% \changes{1.3}{2009 Sep 1}{Doc: Updated}
%
%
% \GetFileInfo{mattens.sty}
%
%
% \title{The \MT\ package\thanks{This file has version number
%                               \fileversion, last revised
%                               \filedate.}}
% \author{Danie Els}
% \date{\filedate}
% \maketitle
%
% \begin{abstract}
% \noindent The \MT\ package contains the definitions to typeset vectors and
% tensors such as $\aS{e}_i$, $\bS[\dot]{x}^r$, $\bSb{E}^s_r$, etc., for the
% representation of common vectors and tensors such as forces, velocities,
% moments of inertia, etc. These symbols (and variants thereof) are found on
% the black boards of engineering schools and in many journals and books,
% particularly those concerned with dynamics and kinematics.
%
% This package adheres to the well defined and documented notation of
% Hassenpflug.\footnote{^^A
%         Hassenpflug, W.C.,
%         Matrix Tensor Notation Part I. Rectilinear Orthogonal Coordinates.
%         \emph{Comput. Math.\ Applic.,} vol.\ 26, no.\ 3, 1993, pp.\ 55--93.}^^A
%     \textsuperscript{,}^^A
%     \footnote{
%         Hassenpflug, W.C.,
%         Matrix Tensor Notation Part II. Skew and Curved Coordinates.
%         \emph{Comput. Math. Appl.}, vol.\ 29, no.\ 11, 1993, pp. 1--103.}
%
% \medskip
% \noindent\slshape{\bfseries Keywords:} vector, matrix, tensor, notation.
% \end{abstract}
%
% \clearpage
% {\parskip0pt\tableofcontents}
%
% \clearpage
% \section{Background}
%
% A browse through journals and handbooks, in particular those concerned with
% dynamics, reveals an amazing array of private notations for vectors and
% tensors. Every author has his or her own notation, making it very difficult
% to comprehend what is going on in complex multi reference axes environments.
%
% This package is based on the notation of \Hass\cite{Hass93a,Hass93b}. It was
% developed and refined by Dr.~\Hass{} over many years of teaching engineering,
% and as stated by him\cite{Hass93a}:
%
% \begin{quote}\slshape
%     ``It is designed particulary to distinguish between vectors and tensors
%     and their representation as vectors and matrices in different coordinate
%     systems. The main purpose of this notation is that it can be used in the
%     teaching situation, therefore, it conveys all the information explicitly
%     in the symbols, and it can be used in handwriting.''
% \end{quote}
%
% \noindent \Hass\cite{Hass93a} identifies the following list of requirements
% for a good notation for tensor quantities and operations, to which his
% notation conforms. A notation must:
% \begin{itemize}
%     \item be easily written by hand;
%     \item distinguish between vector and scalar quantities;
%     \item distinguish between (second order) tensors and vectors;
%     \item distinguish between physical vectors and their representation
%         by vector arrays, and between physical (second order) tensors and
%         their representation by matrices;
%     \item distinguish between row and column vectors;
%     \item use the same symbol as name for the same vector or tensor in
%         either its physical sense or its representation by a vector array
%         or matrix in different coordinate axes;
%     \item distinguish between matrix/vector representation of the same
%         vector/tensor in different coordinate axes;
%     \item be equally valid in orthonormal and skew coordinate axes;
%     \item indicate all intended operations uniquely;
%     \item be equally valid in all dimensions;
%     \item be equally valid for algebraic vector/matrix algebra which has
%         no connection to any metric space;
%     \item be applicable to differentials;
%     \item allow for defaults to avoid repetitive elaborate symbols, i.e.,
%         not all the symbols need to be written down explicitly if it is
%         clear from the context.
%     \item It must be well documented (own addition).
% \end{itemize}
%
% \noindent The \MT\ package was developed to typeset the \Hass{} matrix
% tensor symbols in a consistent manner.
%
% An appeal is made to the engineering and scientific community to adopt this
% notation, because of its consistency and ease of use.
%
% \section{Usage of \MT\ package}
%
% The \MT\ package is loaded in the document preamble with:
% \begin{quote}
% \begin{tabbing}
%     \hskip14pc\=\kill
%     \qquad$\vdots$\\
%     \cmd{\usepackage}\oarg{options}|{mattens}| \>|% amsmath loaded internally|\\
%     \qquad$\vdots$\\
%     \cmd{\usepackage}\marg{font packages}      \>|%|\\
%     \cmd{\DeclareSymbolFont}...                \>|% All the font changes|\\
%     \cmd{\SetSymbolFont}...                    \>|%|\\
%     \cmd{\DeclareSymbolFontAlphabet}...        \>|%|\\
%     \qquad$\vdots$\\
%     \cmd{\usepackage}|{bm}       %\boldsymbol redirected to call \bm|\\
%     \qquad$\vdots$
% \end{tabbing}
% \end{quote}
%
% \noindent When \MT\ is loaded, the \pkg{amsmath} package is loaded
% automatically, because it is needed for the redefined \cmd{\overrightarrow}
% and \cmd{\underrightarrow} commands, as well as the \cmd{\boldsymbol}
% command. It must be loaded before any font packages that redefine some of the
% \pkg{amsmath} symbols or commands.
%
% On the other hand, the preferred method for obtaining bold italic math
% symbols is the \cmd{\bm} command of the \pkg{bm} package.\footnote{In the
% \pkg{amsmath} documentation, \AmS{} recommends the \cmd{\bm} command of the
% \pkg{bm} package instead of the \cmd{\boldsymbol} command for bold italic
% math symbols. The \cmd{\boldsymbol} puts its contents in a box,
% \cmd{\mbox\{}\cmd{\boldmath\$}\meta{contents}\texttt{\$\}}, while \cmd{\bm}
% is a font changing command that uses the appropriate bold math font.} The
% \pkg{bm} package must be loaded after all the font packages in order for it
% to recognize the bold math versions. The \pkg{bm} package reroutes the
% \cmd{\boldsymbol} command to point to \cmd{\bm}. If \cmd{\boldsymbol} is
% called after the \pkg{bm} package is loaded, it is equivalent to \cmd{\bm}.
% If the \pkg{bm} package is not loaded, \MT\ defaults to the \cmd{\boldsymbol}
% command.
%
% The \MT\ package by default sets bold italics symbols. This choice stems from
% the ISO standards for typesetting of vectors and tensors. The formatting of
% symbols then indicates the fact that it is a vector/tensor and the lines,
% arrows and sub- and superscripts indicate the specific type and reference
% axes.
%
% The following options are recognized by \MT:
%
% \begin{description}
%     \item[\normalfont\opt{noformat}:]  No symbol formatting is performed,
%         otherwise symbols are set by default in bold italics with the
%         \cmd{\boldsymbol} or \cmd{\bm} command.
%
%         It is important to note that the \Hass{} requirement of easily
%         written by hand is not fulfilled if the symbols are formatted
%         by anything else than normal math fonts.
%
%     \item[\normalfont\opt{mathstrut}:] A mathstrut is inserted with the
%         symbol to force all the lines and arrows to the same height and
%         depth. The default is no mathstrut.
% \end{description}
%
%  \clearpage
%  \section{List of \MT\ commands}
%
% \begin{table}[htbp]
%     \caption{List of Matrix Tensor typing commands} \label{tab:1}
%     \small
%     \renewcommand{\footnoterule}{}
%     \begin{tabular}{@{}ll>{\itshape}r@{}>{\itshape}c@{}>{\itshape}lc@{}}
%         \sphline
%         \bfseries  Type   &
%         \bfseries Command &
%         \multicolumn{3}{c}{\bfseries  Description} &
%         \bfseries  Output
%         \\
%         \sphline
%
%         Physical column vector&
%         \cmd{\aS}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{aS}  &
%         arrow--&Symbol&       &
%         $\aS{x}$
%         \\[1.0ex]
%
%         Physical row vector   &
%         \cmd{\Sa}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{Sa}  &
%         &Symbol&--arrow&
%         $\Sa{x}$
%         \\[1.0ex]
%
%         Column vector         &
%         \cmd{\bS}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{bS}  &
%         bar--&Symbol&       &
%         $\bS{x}$
%         \\[1.0ex]
%
%         Row vector            &
%         \cmd{\Sb}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{Sb}  &
%         &Symbol&--bar  &
%         $\Sb{x}$
%         \\[1.0ex]
%
%         Physical tensor       &
%         \cmd{\aSa}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{aSa}&
%         arrow--&Symbol&--arrow&
%         $\aSa{E}$
%         \\[1.0ex]
%
%         Tensor (mixed base)   &
%         \cmd{\aSb}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{aSb}&
%         arrow--&Symbol&--bar  &
%         $\aSb{E}$
%         \\[1.0ex]
%
%         Tensor (mixed base)   &
%         \cmd{\bSa}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{bSa}&
%         bar--&Symbol&--arrow&
%         $\bSa{E}$
%         \\[1.0ex]
%
%         Tensor                &
%         \cmd{\bSb}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{bSb}&
%         bar--&Symbol&--bar  &
%         $\bSb{E}$
%         \\[1.0ex]
%
%         Cross-product tensor$^\dag$   &
%         \cmd{\aCSa}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{aCSa}&
%         arrow--C&Symbol&--arrow&
%         $\aCSa{w}$
%         \\[1.0ex]
%
%         Cross-product tensor  &
%         \cmd{\bCSb}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{bCSb}&
%         bar--C&Symbol&--bar  &
%         $\bCSb{w}$
%         \\[1.0ex]
%
%         \sphline
%         \multicolumn{5}{@{}l}{\footnotesize$^\dag$~
%             It is defined as the tensor  $\bCSb{a}$ associated with the
%             vector $\bS{a}$, where $\bS{a}\times\bS{c}=\bCSb{a}\cdot\bS{c}$}
%  \end{tabular}
%  \end{table}
%
% \subsection{General syntax}
%
% The general syntax of the \MT\ commands is
% \begin{Decl}
%     |\|\m|S|\m\,| |\oarg{accent}\marg{Symbol} ~~
%     |\|\m|CS|\m\,| |\oarg{accent}\marg{Symbol}\\[1ex]
%     |\|\m|S|\m\,|*|\oarg{accent}\marg{Symbol}~~~
%     |\|\m|CS|\m\,|*|\oarg{accent}\marg{Symbol}
% \end{Decl}
% \noindent with command names $\cmd{\bS}$, $\cmd{\aS}$, $\cmd{\aSa}$,
% $\cmd{\aSb}$, etc. See table\:\ref{tab:1} for a full list of all the
% commands.  The ``starred'' form is used to set the symbol in normal math.
% This can be used for compound tensors or for pre-declared symbols (see
% \pkg{bm} documentation). An example of the usage is
% \begin{sample}
%     \hskip4pc\=\hskip8pc\=\hskip2pc\=\kill^^A
%     \cmd{\aS}|{e}|  \> \cmd{\aS*}|{e}|   \> $\aS{e}$  \> $\aS*{e}$\\[0.75ex]
%     \cmd{\Sb}|{x}|  \> \cmd{\Sb*}|{x}|   \> $\Sb{x}$  \> $\Sb*{x}$\\[0.75ex]
%     \cmd{\aCSa}|{z}|\> \cmd{\aCSa*}|{z}| \> $\aCSa{z}$\> $\aCSa*{z}$
% \end{sample}
% The optional argument \meta{accent} is intended for \LaTeX{} accent commands
% such as $\cmd{\dot}$, $\cmd{\ddot}$, etc., or their $\AmS$ equivalents,
% $\cmd{\Dot}$, $\cmd{\Ddot}$.
% \begin{sample}
%     |\bS[\Ddot]{x}| \> $\bS[\Ddot]{x}$
% \end{sample}
%
% The \MT\ commands look ahead for sub- and superscripts (including primes) in
% order to place them at the correct horizontal and vertical positions.
% \begin{sample}
%     \cmd{\bS}|[|\cmd{\Dot}|]{x}^s_i|  \> $\bS[\Dot]{x}^s_i$  \\[1ex]
%     \cmd{\bS}|[|\cmd{\Ddot}|]{x}_i^s| \> $\bS[\Ddot]{x}_i^s$ \\[1ex]
%     \cmd{\bS}|{x}''^s_i|              \> $\bS{x}''^s_i$      \\[1ex]
%     \cmd{\bSa}|{E}^k|                 \> $\bSa{E}^k$         \\[1ex]
%     \cmd{\aSb}|[|\cmd{\Dot}|]{E}_s|   \> $\aSb[\Dot]{E}_s$
% \end{sample}
%
% The commands are also robust and can be used in moving commands such as
% footnotes\footnote{A vector $\aS{e}_i$ in a footnote}, headers, etc.
% \begin{sample}
%     |\footnote{A vector $\aS{e}_i$ in a footnote}|
% \end{sample}
%
% The symbols scale to the appropriate sizes if used in sub- and superscripts.
% For example, for an integration path parameterized by the vector
% $\bS{r}^s(\xi)$, the equation for a line integral
% \begin{verbatim}
%     \begin{equation*}
%         \oint\limits_{\bS{r}^s(\xi)}  \dotsi
%     \end{equation*}
% \end{verbatim}
% gives
% \begin{equation*}
% \oint\limits_{\bS{r}^s(\xi)} \dotsi
% \end{equation*}
% \bigskip
%
% ^^A\clearpage
% \section{Symbol formatting commands}
% \subsection{Bold italic symbols}
%
% The symbol format can be set with the package options
% \begin{sample}
%     \hskip14pc\=\kill
%     |\usepackage{mattens}|             \>|% Uses \boldsymbol as default|
% \end{sample}
% or
% \begin{sample}
%     \hskip14pc\=\kill
%     |\usepackage[noformat]{mattens}|   \>|% No symbol formatting|
% \end{sample}
% or anywhere in the document with the command
% \begin{Decl}
%    \cmd{\SetSymbFont}\marg{font-command}^^A
%    \SpecialUsageIndex{\SetSymbFont}
% \end{Decl}
% \noindent The \pkg{bm} package reroutes the \cmd{\boldsymbol} command to
% point to \cmd{\bm}. If \cmd{\SetSymbFont}|{\boldsymbol}| is called after the
% \pkg{bm} package is loaded, it is equivalent to \cmd{\SetSymbFont}|{\bm}|.
% Bold formatting of individual tensors can also be switched off with the use
% of the starred forms of the tensor commands.
%
% If the symbols are interpreted as tensors, then according to the ISO, it can
% be typeset in a slanted sans serif font (if you are fond of fonts).  For the
% Computer Modern fonts with an \texttt{OT1} encoding, you can put in the
% preamble
% \begin{quote}
%     |\DeclareMathAlphabet{\mathsfsl}{OT1}{cmss}{m}{sl}|
% \end{quote}
% Examples of formats are
% \begin{sample}
%     |\SetSymbFont{\bm}|       \>\SetSymbFont{\bm}$\aSb{E}_s$\\[1ex]
%     |\SetSymbFont{\relax}|    \>\SetSymbFont{\relax}$\aSb{E}_s$\\[1ex]
%     |\SetSymbFont{\mathsfsl}| \>\SetSymbFont{\mathsfsl}$\aSb{E}_s$
% \end{sample}
% \SetSymbFont{\bm}
%
% Only the first symbol (or group) in multi-symbol constructions is formatted.
% This can be used to obtain
% \begin{sample}
%     |\bS{{}xy}| ~|\bS*{xy}| \> $\bS{{}xy}$ ~ $\bS*{xy}$\\
%     |\bS{xy}|   \> $\bS{xy}$ \\
%     |\bS{{xy}}| \> $\bS{{xy}}$
% \end{sample}
% or
% \begin{sample}
%     |\bCSb*{\bS{x}+\bS{y}}| \> $\bCSb*{\bS{x}+\bS{y}}$\\[1ex]
%     |\bSb{E_{313}}^s_r| \> $\bSb{E_{313}}^s_r$
% \end{sample}
%
% When a font does not have bold italic symbols and is properly configured, the
% |\bm| command constructs the symbols with the ``poor man's bold'' method.
% This results in the loss of the subscript kerning. This is the case for the
% \pkg{mathptm}\ package for Times fonts. If bold italic symbols are needed for
% Times fonts, it is advisable to use the \pkg{txfonts} package or one of the
% commercial fonts.
%
%
% \subsection{Struts}
%
% A strut can be inserted inside the tensor construction to force all the lines
% to the same height. This can be given in the package options
% \begin{sample}
%     \hskip14pc\=\kill
%     |\usepackage{mattens}|             \>|% No strut as default |
% \end{sample}
% or
% \begin{sample}
%     \hskip14pc\=\kill
%     |\usepackage[mathstrut]{mattens}|  \>|% Uses \mathstrut     |
% \end{sample}
% or anywhere in the document with the command
% \begin{Decl}
%     \SpecialUsageIndex{\SetSymbStrut}^^A
%     \cmd{\SetSymbStrut}\marg{strut}
% \end{Decl}
% \noindent For example
% \SetSymbStrut{\relax}
% \begin{sample}
%     |\SetSymbStrut{\relax}| \\
%     |\bSb{E}|, |\bS{f}|, |\Sb{y}| \>$\bSb{E}$, $\bS{x}$, $\Sb{y}$
% \end{sample}
% \SetSymbStrut{\mathstrut}
% \begin{sample}
%     |\SetSymbStrut{\mathstrut}| \\
%     |\bSb{E}|, |\bS{f}|, |\Sb{y}| \>$\bSb{E}$, $\bS{x}$, $\Sb{y}$
% \end{sample}
% \SetSymbStrut{\vphantom{E}}
% \begin{sample}
%     |\SetSymbStrut{\vphantom{E}}| \\
%     |\bSb{E}|, |\bS{f}|, |\Sb{y}| \>$\bSb{E}$, $\bS{x}$, $\Sb{y}$
% \end{sample}
% \SetSymbStrut{\relax}
%
% \subsection{Additional sub- and superscript spaces}
%
% The placing of the sub- and superscripts was fine-tuned for Computer Modern
% fonts. Other fonts may require the sub- and superscript to shift closer or
% further away from the lines and the symbols. Additional spaces can be
% inserted before the sub- and superscripts with the following commands:
% \begin{Decl}
%     \cmd{\SetArrowSkip}\marg{muskip length}\\[.5ex]
%     \cmd{\SetBarSkip}\marg{muskip length}\\[.5ex]
%     \cmd{\SetSymSubSkip}\marg{muskip length}\\[.5ex]
%     \cmd{\SetSymSupSkip}\marg{muskip length}
%         \SpecialUsageIndex{\SetArrowSkip}
%         \SpecialUsageIndex{\SetBarSkip}
%         \SpecialUsageIndex{\SetSymSubSkip}
%         \SpecialUsageIndex{\SetSymSupSkip}
% \end{Decl}
% \noindent The length units must be in math units (\myemph{mu}), where
% $18\,\mathit{mu}=1\,\mathit{em}$ (a little less than the width of the letter
% ``M'').
%
% \section{Other packages and classes}
%
% \begin{description}
%     \item[\normalfont\pkg{bm}:\quad] The \pkg{bm} package is preferred
%         for bold\-/\-heavy symbols in math mode. It can also be used to
%         predeclare bold symbols for use with the starred form of the
%         tensor commands, for example: \SetSymbFont{\bm}
%         \begin{sample}
%             | \bmdefine{\bO}{\mathit{\Omega}}|\\
%             |$\bSb*{\bO_i}$|  \>\qquad\qquad\qquad $\bSb*{\bO_i}$
%         \end{sample}
%
%     \item[\normalfont\pkg{hyperref}:\quad] When tensor symbols are set in
%         chapter and section headers, \pkg{hyperref} crashes if the
%         \cmd{\texorpdfstring} command is not used.
%         \begin{sample}
%             |\section{A header with \texorpdfstring{$\bS{x}^i_j$}{xij} in it}|
%         \end{sample}
%
%     \item[\normalfont\pkg{color}:\quad] To change the colour of a symbol
%         the \cmd{\color} command must be grouped two levels deep to
%         survive all the expansions if the \pkg{bm} package is loaded.
%         \begin{sample}
%             |$\aSb{{{\color{red}E}}}_i$| \> $\aSb{{{\color{red}E}}}_i$
%         \end{sample}
%
%     \item[\normalfont\pkg{slide}, \pkg{foils}:~~] The Euler math fonts
%         are definitely compulsory. The ratio of the sub- and superscript
%         sizes to normal math font sizes is too big inside the \pkg{slide}
%         class. For tensors such as $\bS{x}^j_k$, you may find that the
%         sub- and superscripts overlap. Choose your script characters
%         carefully.
%
%     \item[\normalfont\pkg{eulervm}:\quad] The \Hass{} ideal of symbols
%         that are easily written by hand is satisfied with the beautiful
%         letters of the Euler fonts.  This package is a must for
%         presentation material, but \myemph{please  do not use bold Euler
%         symbols}, they just  do not look right!
%
%     \item[\normalfont\pkg{accents}:\quad] For the creation of alternative
%         accents the \MT\ package is fully compatible with the
%         \pkg{accents}\ package. As an example of its usage, the equation
%         in \Hass\cite{Hass93a}, \S10.1, p.82
%
% \begin{minipage}{\textwidth}
% \begin{verbatim}
%     \SetSymbFont{\relax}
%     \SetSymbStrut{\mathstrut}
%     \newcommand{\dotr}[1]{%
%         \accentset{\phantom{r}{\displaystyle.}r}{#1}}
%     \begin{equation*}
%         \text{apparent velocity}
%                 = \frac{\partial_r}{\mathrm{d}t} \aS{r}
%                 = \aS[\dotr]{r}
%                 = \aSb{E}_s \tdot \bS[\dotr]{r}^s
%            \equiv \aS{v}_{\mathrm{app}}
%                 = \aS{v}_{\mathrm{rel}}
%     \end{equation*}
% \end{verbatim}
% \end{minipage}
% \medskip
%
%         which gives\SetSymbFont{\relax}\SetSymbStrut{\mathstrut}%
%         \begin{equation*}
%             \text{apparent velocity} =
%                 \frac{\partial_r}{\mathrm{d}t} \aS{r} =
%                 \aS[\dotr]{r} =
%                 \aSb{E}_s \tdot \bS[\dotr]{r}^s \equiv
%                 \aS{v}_{\mathrm{app}} =
%                 \aS{v}_{\mathrm{rel}}
%         \end{equation*}
%         \SetSymbStrut{\relax}\SetSymbFont{\bm}
% \end{description}
% ^^A\clearpage
%
% \section{Typesetting the \Hass{} notation in \LaTeX}
% \subsection{Why?}
%
% The \Hass{} notation contains symbols such as, $\aS{e}_i$,
% $\bS[\dot]{x}^{r}_{\alpha}$, $\bSa[\dot]{E}^s$, etc. These symbols
% are quite common and variants thereof are found on many
% blackboards of engineering schools. Based on the reputation of
% \TeX{} it would seem trivial to typeset them, but to the contrary
% ...
% \SetSymbFont{\relax}
% \begin{sample}
%     |\bS[\dot]{f}^a_b|           \> $\bS[\dot]{f}^a_b$ ~~~(correct typesetting)\\[.75ex]
%     |$\dot{\overline{f}}^a_b$|   \> \AccentBox\\[.75ex]
%     |$\dot{\overline{f}}{}^a_b$| \> $\dot{\overline{f}}{}^a_b$\\[.75ex]
%     |$\dot{\overline{f}^a_b}$|   \> $\dot{\overline{f}^a_b}$
% \end{sample}
% \SetSymbFont{\bm}
%
% When a subscript is inserted for slanted characters, e.g.,
% $f^a_b$, the subscript is kerned closer to the symbol.
% This subscript kerning as well as the superscript height is
% retained for math accents, e.g., $\dot{f}^a_b$. When
% the \cmd{\overline} or \cmd{\overrightarrow} commands are used together
% with math accents, the problems begin\footnote{If you are using
% Equation Editor or MathType inside word processors in the Windows environment,
% you end up with the same problems and have to fiddle \myemph{every}
% sub- and superscript individually. A browse through the accompanying
% sample document, \pkg{mtsample.tex}, will show that this can amount to
% hundreds of little equations. I challenge anyone to rewrite that
% document with one of the popular wordprocessors and still be sane
% afterwards :-)}:
%
% \begin{itemize}
%
% \item For an \cmd{\overline}, $\overline{f}^a_b$, the superscript moves up to
%     the height of the overline, which is fine for vector notation, but the
%     subscript kerning is lost, because the symbol is set inside a box with
%     italic correction added (App. G of the \TeX{}book). If the subscript is
%     added inside the \cmd{\overline} construct, $\overline{f_b}^a$, the
%     overline is stretched, which is acceptable only when the subscript is
%     part of the symbol itself. The subscript kerning can be corrected by
%     attaching the subscript to the symbol and the superscript to the overline
%     and then overtyping (\cmd{\rlap} or \cmd{\llap}) them while using a
%     phantom symbol (without subscript) for the overline,
%     \begin{sample}
%         |\leavevmode\rlap{$\overline{\phantom{f}}^a$}%|\\
%         |                {$f^{}_b$}|
%     \end{sample}
%     which gives \leavevmode\rlap{$\overline{\phantom{f}}^a$}{$f^{}_b$}.
%
%     The \cmd{\leavevmode} command is nessesary to prevent the symbol being
%     spread over two lines when it is the first token in a new paragraph
%     (\TeX{} in vertical mode).
%
%     Care must be taken with the sequence in which the two parts overlap when
%     the one is wider than the other,
%     \leavevmode\rlap{$\overline{\phantom{f}}^{abcde}$}{$f^{}_a$},
%     because the superscript will then run into the following text.
%
% \item If a math accent is added to the overline, \AccentBox, the superscript
%     goes to the level of the accent (except if the \pkg{accents}\ package is
%     loaded). This can be remedied by controlling the height of the accented
%     overline construction with a \cmd{\vphantom} commands as a strut,
%     \begin{sample}
%         |\leavevmode\rlap%|\\
%         |   {$\dot{\overline{\phantom{f}}}{\vphantom{\overline{f}}}^a$}%|\\
%         |   {$f^{}_b$}|
%     \end{sample}
%     which gives
%     \rlap{$\dot{\overline{\phantom{f}}}{\vphantom{\overline{f}}}^a$}^^A
%          {$f^{}_b$}.
%
% \item For an |\overrightarrow| in vector notation, ($\overrightarrow{i}_a$,
%     ~$\overrightarrow{iiii}_a\,$), the construction of the stretchable arrow
%     results in an arrow wider than most symbols, with the symbol centred
%     below it. The subscript ended up far removed from the symbol. For
%     multiple symbols, the arrow width is equal to the box containing the
%     letters, resulting in better-looking subscripts (but still without the
%     subscript kerning). The previous procedure can be used to correct the
%     subscript kerning, except that additional white space must be inserted
%     before the symbol to centre it beneath the arrow.
%     \begin{sample}
%         |\newlength{\Wspace}\settowidth{\Wspace}{$\overrightarrow{i}$}|\\
%         |\newlength{\SymWdth}\settowidth{\SymWdth}{$i$}|\\
%         |\addtolength{\Wspace}{-\SymWdth}              |\\
%         |\leavevmode\rlap{$\dot{\overrightarrow{\phantom{i}}}$}%    |\\
%         |                {\hspace*{.5\Wspace}$i^{}_b$}              |
%     \end{sample}
%     \newlength{\Wspace}\settowidth{\Wspace}{$\overrightarrow{i}$}
%     \newlength{\SymWdth}\settowidth{\SymWdth}{$i$}
%     \addtolength{\Wspace}{-\SymWdth}
%     which gives \rlap{$\dot{\overrightarrow{\phantom{i}}}$}{\hspace*{.5\Wspace}$i^{}_b$}.
%
%     The commands can be optimized by using saveboxes, \myemph{but} the
%     symbols will not scale correctly when used as sub- or superscripts or in
%     the \cmd{\tfrac} macro.  A solution is to nest the commands inside a
%     \cmd{\mathpalette} environment, but be warned, this is very expensive!
%     The commands \cmd{\phantom}, \cmd{\smash}, \cmd{\overrightarrow} (in
%     \pkg{amsmath}) are already inside \cmd{\mathpalette} macros, and \TeX{}
%     calls the arguments of a \cmd{\mathpalette} macro four times before
%     deciding on the dimensions.
%
% \item The shape of the arrow tip of the |\overrightarrow| command was
%     probably not designed for this type of application and is much too broad
%     in the final CM font version. This broad arrow shape is incidentally one
%     of last changes by Prof.~Knuth to the CM font symbols. The PostScript
%     version of the CM fonts typesets the arrow much better, but it is highly
%     likely that it is still the old outdated version of the symbol.
%
% \item The subscript heights differ for the cases with and without
%     superscripts, $x_b,\; x_b^a$. This is not very satisfactory for a
%     consistent matrix-tensor notation, but it can be remedied by inserting a
%     dummy superscript, |$x^{}_b$|, which then gives $x^{}_b$, $x_b^a$.
%
% \end{itemize}
% The \MT\ package was developed to overcome (some of) the above-mentioned
% problems and to typeset the \Hass{} matrix tensor symbols in a consistent
% manner.
%
%
% \subsection{To do's}
%
% \begin{itemize}
%     \item The vertical spacing between the symbols and the lines and
%         arrows differs, $\aSb{E}$, $\bSa{E}$. This problem cannot be
%         fixed easily and would need some additional struts or even a
%         rewriting of the arrows and lines commands.
%
%     \item For the purists: The ends of the |\overrightarrow| are rounded
%         (ligature of symbols), while the ends of the |\overline| are
%         squared (\TeX{} line drawing).
% \end{itemize}
% \bigskip
%
% \begin{thebibliography}{7}
%     \bibitem{Hass93a}
%         \Hass, W.~C.,
%         ``Matrix Tensor Notation Part I. Rectilinear Orthogonal Coordinates,''
%         \textsl{Comput. Math. Appl.},
%         \textbf{26}(3), 1993, pp. 55--93.
%
%     \bibitem{Hass93b}
%         \Hass, W.~C.,
%         ``Matrix Tensor Notation Part II. Skew and Curved Coordinates,''
%         \textsl{Comput. Math. Appl.},
%         \textbf{29}(11), 1993, pp. 1--103.
% \end{thebibliography}
%
%  \StopEventually{} ^^A end StopEventually
%
%  \clearpage
%
% \section{The Code: \pkg{mattens.sty}}
%    \setlength{\parskip}{\smallskipamount}
%    \setlength{\parindent}{0pt}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
%
%
%    \subsection{Identification}
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mattens}[2010/03/26
                          v1.3a
                          Matrix/Tensors (DNJ Els)]
%    \end{macrocode}
%
%
%
%    \subsection{Options}
%
%    \begin{macro}{\MT@SymbStrt}
%    \begin{macro}{\SetSymbStrut}
%    Struts to set all the lines and arrows at
%    predetermined heights and depths.
%    \begin{macrocode}
\newcommand*{\MT@SymbStrt}{}
\newcommand*{\SetSymbStrut}[1]{\renewcommand*{\MT@SymbStrt}{#1}}
\SetSymbStrut{\relax}
\DeclareOption{mathstrut}{\SetSymbStrut{\mathstrut}}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%
%    \begin{macro}{\MT@SymbFnt}
%    \begin{macro}{\SetSymbFont}
%    Initialize the symbol font formatting commands.
%    \begin{macrocode}
\newcommand*{\MT@SymbFnt}{}
\newcommand*{\SetSymbFont}[1]{\renewcommand*{\MT@SymbFnt}{#1}}
\SetSymbFont{\boldsymbol}
\DeclareOption{noformat}{\SetSymbFont{\relax}}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%
%    Process the options
%    \changes{1.3a}{2010 Mar 25}{Remove invalid UTF-8 byte sequences}
%    \begin{macrocode}
\DeclareOption*{%
    \PackageWarning{mattens}{Unknown option: \CurrentOption}}
\ProcessOptions\relax
%    \end{macrocode}
%
%
%
%    \subsection{Packages}
%
%    The \pkg{amsmath} package is loaded to provide the scalable
%    \cmd{\overrightarrow} and \cmd{\underrightarrow} commands, as
%    well as the \cmd{\boldsymbol} command for setting bold math
%    symbols.
%
%    \begin{macrocode}
\RequirePackage{amsmath}
%    \end{macrocode}
%
%
%
%    \subsection{Workaround commands}
%
%    \begin{macro}{\MT@Overarrow}
%    \begin{macro}{\MT@Underarrow}
%    We define over- and under-arrows that bypass the
%    \cmd{\mathpalette} part of the \pkg{amsmath} macros
%    \cmd{\overrightarrow} and \cmd{\underrightarrow}. It uses
%    the \pkg{amsmath} internal macros \cmd{\overarrow@},
%    \cmd{\underarrow@} and \cmd{\rightarrowfill@}.
%    The first parameter |#1| consists of math styles \cmd{\displaystyle},
%    \cmd{\textstyle}, etc.  The second parameter |#2| is the symbol
%    or character.
%    \begin{macrocode}
\newcommand{\MT@Overarrow}[2]{\overarrow@{\rightarrowfill@}{#1}{#2}}
\newcommand{\MT@Underarrow}[2]{\underarrow@{\rightarrowfill@}{#1}{#2}}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%
%    \begin{macro}{\MT@Overline}
%    \begin{macro}{\MT@Underline}
%    Make over- and underlines with the same calling syntax as
%    the arrows.
%    \begin{macrocode}
\newcommand{\MT@Overline}[2]{{#1\overline{#2}}}
\newcommand{\MT@Underline}[2]{{#1\underline{#2}}}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%
%    \begin{macro}{\xusebox}
%    \changes{1.1}{2004 Jan 15}{More streamline.}
%    \changes{1.2}{2004 Jan 27}{Test if \pkg{pdftex.def} is loaded.
%        and command is rewritten to use a \cmd{\mathord} to
%        restore script heights}
%    The \cmd{\usebox} command does not function properly when the
%    \pkg{pdftex.def} driver is loaded, because \pkg{pdftex} does
%    not implement a colour stack such as in the \pkg{dvips} driver,
%    but simulate it at \TeX{} macro level.  The \cmd{\xusebox} is
%    a workaround where the \cmd{\usebox} command is grouped.\footnote{
%        Thanks to Heiko Oberdiek for this workaround}
%    A |\mathord| is added around the box to regain its height in the
%    \pkg{pdftex} case.
%    \begin{macrocode}
\AtBeginDocument{%
   \@ifl@aded{def}{pdftex}%
      {\newcommand*{\xusebox}[1]{\mathord{{\usebox{#1}}}}}%
      {\let\xusebox\usebox}%
}
%    \end{macrocode}
%    \end{macro}
%
%
%
%    \subsection{Initialize}
%
%    Define skip lengths for insertion in front of sub- and
%    superscripts.
%    \begin{macrocode}
\newmuskip{\MT@Askip}
\newmuskip{\MT@Bskip}
\newmuskip{\MT@SPskip}
\newmuskip{\MT@SBskip}
%    \end{macrocode}
%
%    \begin{macro}{\SetArrowSkip}
%    \begin{macro}{\SetBarSkip}
%    \begin{macro}{\SetSymSupSkip}
%    \begin{macro}{\SetSymSubSkip}
%    Define commands to set or change the skip lengths and set initial values.
%    \begin{macrocode}
\newcommand*{\SetArrowSkip}[1]{\MT@Askip#1}
\newcommand*{\SetBarSkip}[1]{\MT@Bskip#1}
\newcommand*{\SetSymSupSkip}[1]{\MT@SPskip#1}
\newcommand*{\SetSymSubSkip}[1]{\MT@SBskip#1}
\SetArrowSkip{0mu}
\SetBarSkip{1mu}
\SetSymSubSkip{0mu}
\SetSymSupSkip{0mu}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%
%    \begin{macro}{\MT@SubSkip}
%    \begin{macro}{\MT@SupSkip}
%    Define math skip lengths to insert in front of the sub- and
%    superscripts. The values are set inside the main \MT\ commands
%    according to the type of symbol.
%    \begin{macrocode}
\newmuskip\MT@SubSkip
\newmuskip\MT@SupSkip
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%
%
%
%    \subsection{Main \MT\ commands}
%
%    Setup command templates and lengths to function as global
%    variables and pointers.
%
%    \begin{macro}{\MT@accent}
%    The \cmd{\MT@accent} command points
%    to the math accent that are inserted as the optional argument
%    inside the main \MT\ commands.
%
%    \begin{macrocode}
\newcommand*{\MT@accent}{}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\MT@cmd}
%    \begin{macro}{\MT@@cmd}
%    The commands \cmd{\MT@cmd} and \cmd{\MT@cmd} do the actual
%    typesetting of the symbols.
%    \begin{macrocode}
\newcommand*{\MT@cmd}{}
\newcommand*{\MT@@cmd}{}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%
%
%     They can be seen
%    as function pointer that are set with |\let| commands inside
%    the main \MT\ commands to point to specific commands.
%
% \newcommand{\RA}{\ensuremath{\,\mapsto\,}}
%
%    \begin{tabbing}
%    \hskip2pc\=\hskip3pc\=\hskip12pc\=\kill
%    \>\textsl{Cmd} \> \textsl{Primary command} \> \textsl{Secondary command}\\[.75ex]
%    \>|\aS|:   \>|\MT@cmd| \RA |\MT@OverAandB|,   \>|\MT@@cmd| \RA |\MT@Overarrow|\\
%    \>|\bS|:   \>|\MT@cmd| \RA |\MT@OverAandB|,   \>|\MT@@cmd| \RA |\MT@Overline|\\
%    \>|\Sa|:   \>|\MT@cmd| \RA |\MT@UnderAandB|,  \>|\MT@@cmd| \RA |\MT@Underarrow|\\
%    \>|\Sb|:   \>|\MT@cmd| \RA |\MT@UnderAandB|,  \>|\MT@@cmd| \RA |\MT@Underline|\\
%    \>|\bSb|:  \>|\MT@cmd| \RA |\MT@DoubleAandB|, \>|\MT@@cmd| \RA |\MT@@bSb| \\
%    \>|\aSb|:  \>|\MT@cmd| \RA |\MT@DoubleAandB|, \>|\MT@@cmd| \RA |\MT@@aSb|\\
%    \>|\bSa|:  \>|\MT@cmd| \RA |\MT@DoubleAandB|, \>|\MT@@cmd| \RA |\MT@@bSa| \\
%    \>|\aSa|:  \>|\MT@cmd| \RA |\MT@DoubleAandB|, \>|\MT@@cmd| \RA |\MT@@aSa|\\
%    \>|\bCSb|: \>|\MT@cmd| \RA |\MT@DoubleAandB|, \>|\MT@@cmd| \RA |\MT@@bCSb|\\
%    \>|\aCSa|: \>|\MT@cmd| \RA |\MT@DoubleAandB|, \>|\MT@@cmd| \RA |\MT@@aCSa|\\
%    \end{tabbing}
%
%
%    \begin{macro}{\MT@bold}
%    The \cmd{\MT@bold} command is used internally and set by the
%    ``starred'' command option.
%    \begin{macrocode}
\newcommand*{\MT@bold}{}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\aS}
%    Type the tensor: $\aS{x}$
%    \begin{macrocode}
\DeclareRobustCommand*{\aS}{%
   \let\MT@cmd=\MT@OverAandB%
   \let\MT@@cmd=\MT@Overarrow%
   \MT@SupSkip=\MT@Askip%
   \MT@SubSkip=\MT@SBskip%
   \MT@Tensor}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\bS}
%    Type the tensor: $\bS{x}$
%    \begin{macrocode}
\DeclareRobustCommand*{\bS}{%
   \let\MT@cmd=\MT@OverAandB%
   \let\MT@@cmd=\MT@Overline%
   \MT@SupSkip=\MT@Bskip%
   \MT@SubSkip=\MT@SBskip%
   \MT@Tensor}%
%    \end{macrocode}
%    \end{macro}
%
%
%    \begin{macro}{\Sa}
%    Type the tensor: $\Sa{x}$
%    \begin{macrocode}
\DeclareRobustCommand*{\Sa}{%
   \let\MT@cmd=\MT@UnderAandB%
   \let\MT@@cmd=\MT@Underarrow%
   \MT@SupSkip=\MT@SPskip%
   \MT@SubSkip=\MT@Askip%
   \MT@Tensor}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\Sb}
%    Type the tensor: $\Sb{x}$
%    \begin{macrocode}
\DeclareRobustCommand*{\Sb}{%
   \let\MT@cmd=\MT@UnderAandB%
   \let\MT@@cmd=\MT@Underline%
   \MT@SupSkip=\MT@SPskip%
   \MT@SubSkip=\MT@Bskip%
   \MT@Tensor}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\bSb}
%    Type the tensor: $\bSb{E}$
%    \begin{macrocode}
\DeclareRobustCommand*{\bSb}{%
   \let\MT@cmd=\MT@DoubleAandB%
   \let\MT@@cmd=\MT@@bSb%
   \MT@SupSkip=\MT@Bskip%
   \MT@SubSkip=\MT@Bskip%
   \MT@Tensor}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\aSb}
%    Type the tensor: $\aSb{E}$
%    \begin{macrocode}
\DeclareRobustCommand*{\aSb}{%
   \let\MT@cmd=\MT@DoubleAandB%
   \let\MT@@cmd=\MT@@aSb%
   \MT@SupSkip=\MT@Askip%
   \MT@SubSkip=\MT@Bskip%
   \MT@Tensor}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\bSa}
%    Type the tensor: $\bSa{E}$
%    \begin{macrocode}
\DeclareRobustCommand*{\bSa}{%
   \let\MT@cmd=\MT@DoubleAandB%
   \let\MT@@cmd=\MT@@bSa%
   \MT@SupSkip=\MT@Bskip%
   \MT@SubSkip=\MT@Askip%
   \MT@Tensor}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\aSa}
%    Type the tensor: $\aSa{E}$
%    \begin{macrocode}
\DeclareRobustCommand*{\aSa}{%
   \let\MT@cmd=\MT@DoubleAandB%
   \let\MT@@cmd=\MT@@aSa%
   \MT@SupSkip=\MT@Askip%
   \MT@SubSkip=\MT@Askip%
   \MT@Tensor}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\bCSb}
%    Type the tensor: $\bCSb{\omega}$
%    \begin{macrocode}
\DeclareRobustCommand*{\bCSb}{%
   \let\MT@cmd=\MT@DoubleAandB%
   \let\MT@@cmd=\MT@@bCSb%
   \MT@SupSkip=\MT@Bskip%
   \MT@SubSkip=\MT@Bskip%
   \MT@Tensor}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\aCSa}
%    Type the tensor: $\aCSa{\omega}$
%    \begin{macrocode}
\DeclareRobustCommand*{\aCSa}{%
   \let\MT@cmd=\MT@DoubleAandB%
   \let\MT@@cmd=\MT@@aCSa%
   \MT@SupSkip=\MT@Askip%
   \MT@SubSkip=\MT@Askip%
   \MT@Tensor}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\MT@Tensor}
%    \changes{1.1}{2004 Jan 15}{Added to reduce overall code.}
%    \begin{macro}{\MT@@Tensor}
%    \changes{1.1}{2004 Jan 15}{Added to reduce overall code.}
%    General tensor commands to look for starred form and
%    and initiate script extraction.
%    \begin{macrocode}
\newcommand*{\MT@Tensor}{%
   \@ifstar{\let\MT@bold=\@firstofone\MT@@Tensor}
           {\let\MT@bold=\MT@SymbFnt\MT@@Tensor}}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*{\MT@@Tensor}[2][\@firstofone]{%
   \let\MT@accent=#1\relax%
   \MT@GetScripts{#2}}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%
%
%
%    \subsection{Sub- and superscripts}
%
%
%    \begin{macro}{\MT@GetScripts}
%    This part of the code looks ahead for sub- and superscripts.
%    \changes{1.1}{2004 Jan 15}{Add: Code to check for primes}
%    \begin{macrocode}
\newcommand*\MT@GetScripts[1]{%
   \@ifnextchar'%
      {\MT@GetPrimes{#1}{\prime}}%
      {\MT@UnprimedScripts{#1}}}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\MT@GetPrimes}
%    \changes{1.1}{2004 Jan 15}{Add: Extract primes}
%    \begin{macro}{\MT@GetPrimedSuper}
%    \changes{1.1}{2004 Jan 15}{Add: Extract primes}
%    \begin{macro}{\MT@GetPrimedSub}
%    \changes{1.1}{2004 Jan 15}{Add: Extract primes}
%    Extract primes and look ahead for superscripts |^|. Note that
%    the sequence of operators for a primed symbol is:
%    \meta{symb}|'|$^{..}\!\!$|'^|\meta{sup}|_|\meta{sub}
%    \begin{macrocode}
\newcommand*\MT@GetPrimes[3]{%
   \@ifnextchar'%
      {\MT@GetPrimes{#1}{#2\prime}}%
      {\@ifnextchar^%
          {\MT@GetPrimedSuper{#1}{#2}}%
          {\@ifnextchar_%
              {\MT@GetPrimedSub{#1}{#2}}%
              {\MT@SetScripts{#1}{#2}{\@empty}}%
          }%
      }%
   }
%    \end{macrocode}
%    \begin{macrocode}
\def\MT@GetPrimedSuper#1#2^#3{%
   \@ifnextchar_{\MT@GetPrimedSub{#1}{#2#3}}%
                {\MT@SetScripts{#1}{#2#3}{\@empty}}}
%    \end{macrocode}
%    \begin{macrocode}
\def\MT@GetPrimedSub#1#2_#3{%
   \MT@SetScripts{#1}{#2}{#3}}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%
%    \begin{macro}{\MT@UnprimedScripts}
%    The first extraction command for symbols without primes.
%    It looks ahead for |^| or |_|, if not present, then pass
%    \cmd{\@empty} flags forward, otherwise it passes the tokens
%    on to the next extraction commands.
%
%    \begin{macrocode}
\newcommand*\MT@UnprimedScripts[1]{%
   \@ifnextchar^%
      {\MT@GetSuper{#1}}%
         {\@ifnextchar_%
             {\MT@GetSub{#1}}%
             {\MT@SetScripts{#1}{\@empty}{\@empty}}%
         }%
   }
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\MT@GetSuper}
%    Extract  scripts of the form \meta{Sym}|^|\meta{sup}
%    if there are no further |_| tokens available, otherwise pass the
%    tokens on to the next extraction command.
%
%    \begin{macrocode}
\def\MT@GetSuper#1^#2{%
   \@ifnextchar_{\MT@GetSuperSub{#1}{#2}}%
                {\MT@SetScripts{#1}{#2}{\@empty}}}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\MT@GetSub}
%    Extract scripts of the form \meta{Sym}|_|\meta{sub}
%    if there are no further |^| tokens available, otherwise pass the
%    tokens on to the next extraction command.
%
%    \begin{macrocode}
\def\MT@GetSub#1_#2{%
   \@ifnextchar^{\MT@GetSubSuper{#1}{#2}}%
                {\MT@SetScripts{#1}{\@empty}{#2}}}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\MT@GetSuperSub}
%    Extract scripts of the form
%    \meta{Sym}|^|\meta{sup}|_|\meta{sub}.
%
%    \begin{macrocode}
\def\MT@GetSuperSub#1#2_#3{%
   \MT@SetScripts{#1}{#2}{#3}}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\MT@GetSubSuper}
%    Extract scripts of the form
%    \meta{Sym}|_|\meta{sub}|^|\meta{sup}.
%
%    \begin{macrocode}
\def\MT@GetSubSuper#1#2^#3{%
   \MT@SetScripts{#1}{#3}{#2}}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\MT@SetSup}
%    \begin{macro}{\MT@SetSub}
%    Define global variables commands that contain the extracted
%    sub- and superscripts. These commands are redefined inside the
%    the final \cmd{\MT@SetScripts} command.
%
%    \begin{macrocode}
\newcommand*{\MT@SetSup}{}
\newcommand*{\MT@SetSub}{}
\newcommand*{\MT@SetSubS}{}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%
%    \changes{1.3}{2009 Sep 1}{Remove \cmd{\ensuremath} to force math mode.}
%    \begin{macrocode}
\newcommand*\MT@SetScripts[3]{%
  \let\MT@SetSup\relax%
  \let\MT@SetSub\relax%
  \let\MT@SetSubS\relax%
  \ifx\@empty#2\@empty\else
     \def\MT@SetSup{^{\mskip\MT@SupSkip\relax#2}}%
  \fi
  \ifx\@empty#3\@empty\else
     \def\MT@SetSub{_{\mskip\MT@SubSkip\relax#3}}%
     \def\MT@SetSubS{^{}_{\mskip\MT@SubSkip\relax#3}}%
  \fi
  \MT@cmd{#1}}
%    \end{macrocode}
%
%
%
%    \subsection{Symbol formatting}
%
%    \begin{macro}{\MT@Symb}
%    This command type |{|\meta{strut}\meta{font-cmd}\meta{symb}|}|,
%    the formatted symbol preceded by the selected strut. It is called
%    from within the main typesetting commands.
%
%    \begin{macrocode}
\newcommand*{\MT@Symb}[1]{\MT@SymbStrt\MT@bold#1}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\MT@SymbC}
%    Puts a widetilde over the symbol for the cross product tensors.
%    \begin{macrocode}
\newcommand*{\MT@SymbC}[1]{%
   \MT@SymbStrt\widetilde{%
   \MT@bold#1}}
%    \end{macrocode}
%    \end{macro}
%
%
%    \subsection{Main typesetting commands}
%
%    The commands in this section are the ones pointed to by
%    the \cmd{\MT@cmd} and \cmd{\MT@@cmd} commands to perform
%    the typesetting of the full tensor symbol.
%
%    Declare some save boxes
%    \begin{macrocode}
\newsavebox{\MT@Abox}   % for overline/arrow
\newsavebox{\MT@Sbox}   % for symbol
\newsavebox{\MT@Tbox}   % for tempories
\newsavebox{\MT@APbox}  % for overline/arrow phantom
\newsavebox{\MT@SPbox}  % for symbol phantom
%    \end{macrocode}
%    and some lengths.
%    \begin{macrocode}
\newlength{\MT@SPwdth}  % symbol width
\newlength{\MT@BPwdth}  % Bar width
\newlength{\MT@Wwdth}   % leading whitespace width
%    \end{macrocode}
%
%    \begin{macro}{\MT@OverAandB}
%    This command generates the tensor symbols $\aS{e}$ and $\bS{e}$.
%    It utilizes the \cmd{\mathpalette} macro for the sizing of the
%    final tensor. \LaTeX{} commands \cmd{\smash} and \cmd{\phantom}
%    with embedded \cmd{\mathpalette} calls are avoided to prevent
%    nested \cmd{\mathchoice} calls.
%    \begin{macrocode}
\newcommand*{\MT@OverAandB}{%
   \mathpalette\MT@@OverAandB}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\MT@@OverAandB}
%    \changes{1.2}{2004 Jan 27}{Use \cmd{\xusebox} inside accent
%             to account for \cmd{\dddot}.}
%    For this command the first parameter |#1| is supplied by
%    \cmd{\mathpalette} and consists of math styles \cmd{\displaystyle},
%    \cmd{\textstyle}, etc.  The second parameter |#2| is the original
%    \meta{symbol} from the call \cmd{\MT@cmd}|{|\meta{symbol}|}|.
%
%    \begin{macrocode}
\newcommand*{\MT@@OverAandB}[2]{%
%    \end{macrocode}
%    \begin{Indent}{5em}
%    Set the symbol inside a box for measurement purposes.
%    \end{Indent}
%    \begin{macrocode}
      \sbox{\MT@Tbox}{$\m@th#1\MT@Symb{#2}$}%
%    \end{macrocode}
%    \begin{Indent}{5em}
%    Make phantom symbol box (empty) with size identical to symbol.
%    \end{Indent}
%    \begin{macrocode}
      \setbox\MT@SPbox\null%
      \ht\MT@SPbox\ht\MT@Tbox%
      \dp\MT@SPbox\dp\MT@Tbox%
      \wd\MT@SPbox\wd\MT@Tbox%
%    \end{macrocode}
%    \begin{Indent}{5em}
%    Make overline/overarrow over phantom symbol box for measurement.
%    \end{Indent}
%    \begin{macrocode}
      \sbox{\MT@APbox}{$\m@th\MT@@cmd{#1}{\copy\MT@SPbox}$}%
%    \end{macrocode}
%    \begin{Indent}{5em}
%    Calculate width difference between symbol and arrow/overline.
%    \end{Indent}
%    \begin{macrocode}
      \setlength{\MT@Wwdth}{\the\wd\MT@APbox}%
      \addtolength{\MT@Wwdth}{-\the\wd\MT@SPbox}%
%    \end{macrocode}
%    \begin{Indent}{5em}
%    Make final symbol box with white space in front to center is
%    beneath the arrow/over line and subscript that follows.
%    \end{Indent}
%    \begin{macrocode}
      \sbox{\MT@Sbox}{$\m@th#1\hskip 0.5\MT@Wwdth\relax\MT@Symb{#2}\MT@SetSubS$}%
%    \end{macrocode}
%    \begin{Indent}{5em}
%    Add math accent to overline/overarrow and reset box dimensions to
%    original.
%    \end{Indent}
%    \begin{macrocode}
      \sbox{\MT@Tbox}{$\m@th#1\MT@accent{\xusebox{\MT@APbox}}$}%
      \ht\MT@Tbox\ht\MT@APbox%
      \dp\MT@Tbox\dp\MT@APbox%
%    \end{macrocode}
%    \begin{Indent}{5em}
%    Final overline/overarrow box including accent and superscript at end.
%    \end{Indent}
%    \begin{macrocode}
      \sbox{\MT@Abox}{$\m@th#1\xusebox{\MT@Tbox}\MT@SetSup$}%
%    \end{macrocode}
%    \begin{Indent}{5em}
%    Overtype the symbol and the overline/overarrow boxes. The wider
%    box of the two is typed last to ensure that the spacing after
%    the full tensor symbol is correct.
%    \end{Indent}
%    \begin{macrocode}
      \ifdim\wd\MT@Abox<\wd\MT@Sbox%
          \leavevmode\rlap{\usebox\MT@Abox}{\usebox\MT@Sbox}%
      \else%
          \leavevmode\rlap{\usebox\MT@Sbox}{\usebox\MT@Abox}%
      \fi}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\MT@UnderAandB}
%    \begin{macro}{\MT@@UnderAandB}
%    \changes{1.2}{2004 Jan 27}{Make provisions for wide accents (\cmd{\dddot}).}
%    This command generates the tensor symbols $\Sa{e}$ and $\Sb{e}$.
%    It is identical to the previous command except the sub- and
%    superscripts are swapped and the phantom box is set to the width
%    of the accent.
%    \begin{macrocode}
\newcommand*{\MT@UnderAandB}{%
   \mathpalette\MT@@UnderAandB}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*{\MT@@UnderAandB}[2]{%
      \sbox{\MT@Tbox}{$\m@th#1\MT@accent{\MT@Symb{#2}}$}%
      \setbox\MT@SPbox\null%
      \wd\MT@SPbox\wd\MT@Tbox%
      \sbox{\MT@Tbox}{$\m@th#1\MT@Symb{#2}$}%
      \ht\MT@SPbox\ht\MT@Tbox%
      \dp\MT@SPbox\dp\MT@Tbox%
      \sbox{\MT@APbox}{$\m@th\MT@@cmd{#1}{\copy\MT@SPbox}$}%
      \setlength{\MT@Wwdth}{\the\wd\MT@APbox}%
      \addtolength{\MT@Wwdth}{-\the\wd\MT@SPbox}%
      \sbox{\MT@Sbox}{$\m@th#1%
         \hskip 0.5\MT@Wwdth\relax\MT@accent{\MT@Symb{#2}}\MT@SetSup$}%
      \sbox{\MT@Abox}{$\m@th#1\xusebox{\MT@APbox}\MT@SetSub$}%
      \ifdim\wd\MT@Abox<\wd\MT@Sbox%
         \leavevmode\rlap{\usebox\MT@Abox}{\usebox\MT@Sbox}%
      \else%
         \leavevmode\rlap{\usebox\MT@Sbox}{\usebox\MT@Abox}%
      \fi}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%
%    \begin{macro}{\MT@@bSb}
%    \begin{macro}{\MT@@bSa}
%    \begin{macro}{\MT@@aSb}
%    \begin{macro}{\MT@@aSa}
%    \begin{macro}{\MT@@bCSb}
%    \begin{macro}{\MT@@aCSa}
%    These commands are pointed to by \cmd{\MT@@cmd} and called from
%    within \cmd{\MT@DoubleAandB}. It has the same calling syntax as
%    the \cmd{\MT@Overarrow} and \cmd{\MT@Underarrow} commands.
%    \begin{macrocode}
\newcommand*{\MT@@bSb}[2]{\MT@Overline{#1}{\MT@Underline{#1}{\MT@Symb{#2}}}}
\newcommand*{\MT@@aSb}[2]{\MT@Overarrow{#1}{\MT@Underline{#1}{\MT@Symb{#2}}}}
\newcommand*{\MT@@bSa}[2]{\MT@Overline{#1}{\MT@Underarrow{#1}{\MT@Symb{#2}}}}
\newcommand*{\MT@@aSa}[2]{\MT@Overarrow{#1}{\MT@Underarrow{#1}{\MT@Symb{#2}}}}
\newcommand*{\MT@@bCSb}[2]{\MT@Overline{#1}{\MT@Underline{#1}{\MT@SymbC{#2}}}}
\newcommand*{\MT@@aCSa}[2]{\MT@Overarrow{#1}{\MT@Underarrow{#1}{\MT@SymbC{#2}}}}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%
%    \begin{macro}{\MT@DoubleAandB}
%    \begin{macro}{\MT@@DoubleAandB}
%    \changes{1.2}{2004 Jan 27}{Use \cmd{\xusebox} inside accent
%             to account for \cmd{\dddot}.}
%    This command is used for the remaining tensor symbols and is not
%    so complex compared to the previous commands.
%
%    \begin{macrocode}
\newcommand*{\MT@DoubleAandB}{%
  \mathpalette\MT@@DoubleAandB}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*{\MT@@DoubleAandB}[2]{%
      \sbox{\MT@Abox}{$\m@th#1\MT@@cmd{#1}{#2}$}%
      \sbox{\MT@Tbox}{$\m@th#1\MT@accent{\xusebox{\MT@Abox}}$}%
      \ht\MT@Tbox\ht\MT@Abox%
      \dp\MT@Tbox\dp\MT@Abox%
      \xusebox{\MT@Tbox}\MT@SetSup\MT@SetSub}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%
%
%    \changes{1.1}{2004 Jan 15}{Code: Remove helper commands}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
% \clearpage
% \Finale
% \setcounter{IndexColumns}{2}\PrintIndex
% \PrintChanges
%
\endinput