Debian Codegraph @

texmf-dist/source/latex/mattens/mattens.dtx

raw
1 % \iffalse meta-comment
2 %
3 % mattens.dtx
4 % Copyright (C) 2001--2022 Danie Els
5 %
6 % -------------------------------------------------------------------
7 % The mattens package
8 % for vector/tensor typesetting
9 % -------------------------------------------------------------------
10 % This work may be distributed and/or modified under the conditions
11 % of the LaTeX Project Public License, either version 1.3c of this
12 % license or (at your option) any later version. The latest version
13 % of this license is in
14 % http://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2005/12/01 or later.
17 %
18 % This work has the LPPL maintenance status 'maintained'.
19 %
20 % This Current Maintainer of this work is Danie Els ([email protected])
21 %
22 % This package consists of the files: mattens.dtx
23 % mattens.ins
24 % and the derived files: mattens.sty
25 % -------------------------------------------------------------------
26 %
27 % \fi
28 %
29 % \iffalse
30 %<*driver>
31 \documentclass[a4paper,notitlepage]{ltxdoc}
32 \makeatletter
33 \newcommand{\DeclareSBox}[2]{%
34 \@ifdefinable{#1}{%
35 \edef\tempa{\expandafter\@gobble\string#1}%
36 \edef\tempa{\csname MTbox@\tempa\endcsname}%
37 \expandafter\newbox\tempa
38 \global\sbox{\tempa}{#2}%
39 \protected@xdef#1{\noexpand\usebox{\tempa}}}}
40 \usepackage{amsmath}
41 \usepackage{amsfonts}
42 \DeclareMathSymbol{\square}{\mathord}{AMSa}{"03}
43 \newcommand*{\m}{\raisebox{.1ex}{$\scriptscriptstyle\square$}}
44 \DeclareMathAlphabet{\mathsfsl}{OT1}{cmss}{m}{sl}
45 \usepackage{color}
46 % Declare the following saved box before
47 % the accents and bm packages are loaded
48 \DeclareSBox{\AccentBox}{$\dot{\overline{f}}^a_b$}
49 \usepackage{array}
50 \usepackage{enumitem}
51 \setlist{itemsep=\smallskipamount, parsep=0pt}
52 \usepackage{accents}
53 \newcommand{\dotr}[1]{\accentset{\phantom{r}{\displaystyle.}r}{#1}}
54 \usepackage{mattens}
55 \usepackage{bm}
56 \bmdefine{\bO}{\mathit{\Omega}}
57
58 \newcommand*{\pkg}[1]{\textsf{#1}}
59 \newcommand*{\opt}[1]{\textsf{#1}}
60 \newcommand*{\MT}{\pkg{mattens}}
61 \newcommand*{\Hass}{Hassenpflug}
62 \newcommand*{\myemph}[1]{\emph{#1}}
63 \newenvironment{Decl}[1][l]%
64 {\par\small\addvspace{2.3ex plus 1ex}%
65 \vskip -\parskip
66 \noindent\hspace{\leftmargini}%
67 \begin{tabular}{|#1|}\hline\ignorespaces}%
68 {\\\hline\end{tabular}\nobreak\par\nobreak
69 \vspace{2.3ex}\vskip -\parskip}
70 \newenvironment{Indent}[1]{%
71 \begin{list}{}{%
72 \setlength{\topsep}{0pt}%
73 \setlength{\leftmargin}{#1}%
74 \setlength{\listparindent}{\parindent}%
75 \setlength{\itemindent}{\parindent}%
76 \setlength{\parsep}{\parskip}}%
77 \item[]
78 }{\end{list}}
79 \newenvironment{sample}{%
80 \begin{quote}\small\begin{tabbing}%
81 \hskip12pc\=\kill}%
82 {\end{tabbing}\end{quote}}
83 \newcommand*{\sphline}{% horizontal table line with spaces
84 \noalign{\vskip3pt}\hline\noalign{\vskip3pt}}
85 \newcommand*{\tdot}{\ensuremath{\cdot}}
86 \newcommand*{\trnsp}{\ensuremath{\mathsf{T}}}
87 \newcommand*{\norm}[1]{\ensuremath{\lVert{#1}\rVert}}
88 \newcommand*{\SB}[1]{\ensuremath{\left[\, #1\right]}}
89
90 \MakeShortVerb{\|}
91 \EnableCrossrefs
92 %\DisableCrossrefs % Say \DisableCrossrefs if index is ready
93 \CodelineIndex
94 \RecordChanges % Gather update information
95 %\OnlyDescription % comment out for implementation details
96 \setlength\hfuzz{15pt} % dont make so many
97 \hbadness=7000 % over and under full box warnings
98 \makeatother
99 \begin{document}
100 \DocInput{mattens.dtx}
101 \end{document}
102 %</driver>
103 %
104 % \fi
105 %
106 % \CheckSum{0}
107 %% \CharacterTable
108 %% {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
109 %% 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
110 %% Digits \0\1\2\3\4\5\6\7\8\9
111 %% Exclamation \! Double quote \" Hash (number) \#
112 %% Dollar \$ Percent \% Ampersand \&
113 %% Acute accent \' Left paren \( Right paren \)
114 %% Asterisk \* Plus \+ Comma \,
115 %% Minus \- Point \. Solidus \/
116 %% Colon \: Semicolon \; Less than \<
117 %% Equals \= Greater than \> Question mark \?
118 %% Commercial at \@ Left bracket \[ Backslash \\
119 %% Right bracket \] Circumflex \^ Underscore \_
120 %% Grave accent \` Left brace \{ Vertical bar \|
121 %% Right brace \} Tilde \~}
122 %%
123 %
124 % \DoNotIndex{\,, \@empty, \@gobble, \@ifnextchar, \@ifstar,
125 % \@ifundefined, \@firstofone}
126 % \DoNotIndex{\addtolength}
127 % \DoNotIndex{\begingroup, \boldsymbol, \box}
128 % \DoNotIndex{\copy, \csname, \CurrentOption}
129 % \DoNotIndex{\DeclareOption, \DeclareRobustCommand, \def, \dp}
130 % \DoNotIndex{\edef, \else, \endcsname, \endgroup, \ensuremath,
131 % \expandafter}
132 % \DoNotIndex{\fi}
133 % \DoNotIndex{\global}
134 % \DoNotIndex{\hskip, \ht}
135 % \DoNotIndex{\ifdim, \ifx}
136 % \DoNotIndex{\leavevmode, \left, \let, \lVert}
137 % \DoNotIndex{\m@th, \mathpalette, \mathsf, \mathstrut, \mskip}
138 % \DoNotIndex{\NeedsTeXFormat, \newbox, \newcommand, \newif, \newlength,
139 % \newmuskip, \newsavebox, \null}
140 % \DoNotIndex{\overline}
141 % \DoNotIndex{\PackageError, \PackageWarning, \ProcessOptions, \protect,
142 % \protected@xdef, \providecommand, \ProvidesPackage}
143 % \DoNotIndex{\relax, \renewcommand, \RequirePackage, \right, \rlap,
144 % \rVert}
145 % \DoNotIndex{\sbox, \setbox, \setlength, \space, \string}
146 % \DoNotIndex{\the}
147 % \DoNotIndex{\underline, \usebox, \wd, \widetilde}
148 % \DoNotIndex{\z@}
149 %
150 % \changes{1.0}{2001 Dec 9}{Initial version}
151 % \changes{1.1}{2004 Jan 15}{Doc: Updated}
152 % \changes{1.3}{2009 Sep 1}{Doc: Updated}
153 % \changes{1.3b}{2022 Mar 1}{Doc: Updated}
154 %
155 %
156 % \GetFileInfo{mattens.sty}
157 %
158 %
159 % \title{The \MT\ package\thanks{This file has version number
160 % \fileversion, last revised
161 % \filedate.}}
162 % \author{Danie Els}
163 % \date{\filedate}
164 % \maketitle
165 %
166 %
167 % \section{Introduction}
168 %
169 % \subsection{Background}
170 %
171 % A browse through journals and handbooks, in particular those concerned with
172 % dynamics, reveals an amazing array of private notations for vectors and
173 % tensors. Every author has his or her own notation, making it very difficult
174 % to comprehend what is going on in complex multi reference axes environments.
175 %
176 % The \MT\ package contains the definitions to typeset vectors and
177 % tensors such as $\aS{e}_i$, $\bS[\dot]{x}^r$, $\bSb{E}^s_r$, etc., for the
178 % representation of common vectors and tensors such as forces, velocities,
179 % moments of inertia, etc. It is based on the well defined notation of
180 % \Hass\cite{Hass93a,Hass93b}. It was developed and over many years of
181 % teaching engineering:
182 % \begin{quote}\slshape
183 % ``It is designed particulary to distinguish between vectors and tensors
184 % and their representation as vectors and matrices in different coordinate
185 % systems. The main purpose of this notation is that it can be used in the
186 % teaching situation, therefore, it conveys all the information explicitly
187 % in the symbols, and it can be used in handwriting.''
188 % \end{quote}
189 %
190 % \noindent \Hass\cite{Hass93a} identifies the following list of requirements
191 % for a good notation for tensor quantities and operations, to which his
192 % notation conforms. A notation must:
193 % \begin{itemize}
194 % \item Be easily written by hand;
195 % \item Distinguish between vector and scalar quantities;
196 % \item Distinguish between (second order) tensors and vectors;
197 % \item Distinguish between physical vectors and their representation
198 % by vector arrays, and between physical (second order) tensors and
199 % their representation by matrices;
200 % \item Distinguish between row and column vectors;
201 % \item Use the same symbol as name for the same vector or tensor in
202 % either its physical sense or its representation by a vector array
203 % or matrix in different coordinate axes;
204 % \item Distinguish between matrix/vector representation of the same
205 % vector/tensor in different coordinate axes;
206 % \item Be equally valid in orthonormal and skew coordinate axes;
207 % \item Indicate all intended operations uniquely;
208 % \item Be equally valid in all dimensions;
209 % \item Be equally valid for algebraic vector/matrix algebra which has
210 % no connection to any metric space;
211 % \item Be applicable to differentials;
212 % \item Allow for defaults to avoid repetitive elaborate symbols, i.e.,
213 % not all the symbols need to be written down explicitly if it is
214 % clear from the context.
215 % \item It must be well documented (own addition).
216 % \end{itemize}
217 %
218 % \noindent The \MT\ package was developed to typeset the \Hass{} matrix
219 % tensor symbols in a consistent manner.
220 %
221 % \subsection{Why the \MT\ package?}
222 %
223 % The \Hass{} notation contains symbols such as, $\aS{e}_i$,
224 % $\bS[\dot]{x}^{r}_{\alpha}$, $\bSa[\dot]{E}^s$, etc. These symbols
225 % are quite common and variants thereof are found on many
226 % blackboards of engineering schools. Based on the reputation of
227 % \TeX{} it would seem trivial to typeset them, but to the contrary
228 % ...
229 % \SetSymbFont{\relax}
230 % \begin{sample}
231 % |$\bS[\dot]{f}^a_b$| \> $\bS[\dot]{f}^a_b$ ~~~(correct typesetting)\\[.75ex]
232 % |$\dot{\overline{f}}^a_b$| \> \AccentBox\\[.75ex]
233 % |$\dot{\overline{f}}{}^a_b$| \> $\dot{\overline{f}}{}^a_b$\\[.75ex]
234 % |$\dot{\overline{f}^a_b}$| \> $\dot{\overline{f}^a_b}$
235 % \end{sample}
236 % \SetSymbFont{\bm}
237 %
238 % \section{Usage of \MT\ package}
239 %
240 % The \MT\ package is loaded in the document preamble with:
241 % \begin{sample}
242 % \cmd{\usepackage}\oarg{options}|{mattens}|
243 % \end{sample}
244 %
245 % \noindent When \MT\ is loaded, the \pkg{amsmath} package is loaded
246 % automatically, because it is needed for the redefined \cmd{\overrightarrow}
247 % and \cmd{\underrightarrow} commands, as well as the \cmd{\boldsymbol}
248 % command. It must be loaded before any font packages that redefine some of the
249 % \pkg{amsmath} symbols or commands.
250
251 % \AmS{} recommends the \pkg{bm} package instead of the \cmd{\boldsymbol}
252 % command for bold italic math symbols\footnote{The \cmd{\boldsymbol} puts
253 % its contents in a box,
254 % \cmd{\mbox\{}\cmd{\boldmath\$}\meta{contents}\texttt{\$\}},
255 % while \cmd{\bm} is a font changing command that uses the appropriate
256 % bold math font.}. The \pkg{bm} package reroutes the
257 % \cmd{\boldsymbol} command to point to \cmd{\bm}. If \cmd{\boldsymbol} is
258 % called after the \pkg{bm} package is loaded, it is equivalent to \cmd{\bm}.
259 % If the \pkg{bm} package is not loaded, \MT\ defaults to the \cmd{\boldsymbol}
260 % command.
261 %
262 % The \MT\ package by default sets bold italics symbols. This choice stems from
263 % the ISO standards for typesetting of vectors and tensors. The formatting of
264 % symbols then indicates the fact that it is a vector/tensor and the lines,
265 % arrows and sub- and superscripts indicate the specific type and reference
266 % axes.
267 % \pagebreak[2]
268 %
269 % \noindent The following options are recognized by \MT:
270 %
271 % \begin{description}
272 % \item[\normalfont\opt{noformat}:] No symbol formatting is performed,
273 % otherwise symbols are set by default in bold italics with the
274 % \cmd{\boldsymbol} command.
275 %
276 % It is important to note that the \Hass{} requirement of easily
277 % written by hand is not fulfilled if the symbols are formatted
278 % by anything else than normal math fonts.
279 %
280 % \item[\normalfont\opt{mathstrut}:] A mathstrut is inserted with the
281 % symbol to force all the lines and arrows to the same height and
282 % depth. The default is no mathstrut.
283 % \end{description}
284 %
285 % \section{List of \MT\ commands}
286 %
287 % \begin{table}[htbp]
288 % \caption{List of Matrix Tensor typing commands} \label{tab:1}
289 % \small
290 % \renewcommand{\footnoterule}{}
291 % \begin{tabular}{@{}ll>{\itshape}r@{}>{\itshape}c@{}>{\itshape}lc@{}}
292 % \sphline
293 % \bfseries Type &
294 % \bfseries Command &
295 % \multicolumn{3}{c}{\bfseries Description} &
296 % \bfseries Output
297 % \\
298 % \sphline
299 %
300 % Physical column vector&
301 % \cmd{\aS}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{aS} &
302 % arrow--&Symbol& &
303 % $\aS{x}$
304 % \\[1.0ex]
305 %
306 % Physical row vector &
307 % \cmd{\Sa}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{Sa} &
308 % &Symbol&--arrow&
309 % $\Sa{x}$
310 % \\[1.0ex]
311 %
312 % Column vector &
313 % \cmd{\bS}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{bS} &
314 % bar--&Symbol& &
315 % $\bS{x}$
316 % \\[1.0ex]
317 %
318 % Row vector &
319 % \cmd{\Sb}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{Sb} &
320 % &Symbol&--bar &
321 % $\Sb{x}$
322 % \\[1.0ex]
323 %
324 % Physical tensor &
325 % \cmd{\aSa}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{aSa}&
326 % arrow--&Symbol&--arrow&
327 % $\aSa{E}$
328 % \\[1.0ex]
329 %
330 % Tensor (mixed base) &
331 % \cmd{\aSb}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{aSb}&
332 % arrow--&Symbol&--bar &
333 % $\aSb{E}$
334 % \\[1.0ex]
335 %
336 % Tensor (mixed base) &
337 % \cmd{\bSa}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{bSa}&
338 % bar--&Symbol&--arrow&
339 % $\bSa{E}$
340 % \\[1.0ex]
341 %
342 % Tensor &
343 % \cmd{\bSb}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{bSb}&
344 % bar--&Symbol&--bar &
345 % $\bSb{E}$
346 % \\[1.0ex]
347 %
348 % Cross-product tensor$^\dag$ &
349 % \cmd{\aCSa}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{aCSa}&
350 % arrow--C&Symbol&--arrow&
351 % $\aCSa{w}$
352 % \\[1.0ex]
353 %
354 % Cross-product tensor &
355 % \cmd{\bCSb}\oarg{accent}\marg{Symbol}\SpecialUsageIndex{bCSb}&
356 % bar--C&Symbol&--bar &
357 % $\bCSb{w}$
358 % \\[1.0ex]
359 %
360 % \sphline
361 % \multicolumn{5}{@{}l}{\footnotesize$^\dag$~
362 % It is defined as the tensor $\bCSb{a}$ associated with the
363 % vector $\bS{a}$, where $\bS{a}\times\bS{c}=\bCSb{a}\cdot\bS{c}$}
364 % \end{tabular}
365 % \end{table}
366 %
367 % \subsection{General syntax}
368 %
369 % The general syntax of the \MT\ commands is
370 % \begin{Decl}[ll]
371 % |\|\m|S|\,\oarg{accent}\marg{Symbol} &
372 % |\|\m|S|\,|*|\oarg{accent}\marg{Symbol} \\
373 % |\S|\m\,\oarg{accent}\marg{Symbol} &
374 % |\S|\m\,|*|\oarg{accent}\marg{Symbol} \\[1ex]
375 %
376 % |\|\m|S|\m\,\oarg{accent}\marg{Symbol} &
377 % |\|\m|S|\m\,|*|\oarg{accent}\marg{Symbol}\\[1ex]
378 %
379 % |\|\m|CS|\m\,\oarg{accent}\marg{Symbol} &
380 % |\|\m|CS|\m\,|*|\oarg{accent}\marg{Symbol}
381 % \end{Decl}
382 % The ``starred'' form is used to set the symbol in normal math.
383 % This can be used for compound tensors or for pre-declared symbols (see
384 % \pkg{bm} documentation). An example of the usage is
385 % \begin{sample}
386 % \hskip4pc\=\hskip8pc\=\hskip2pc\=\kill^^A
387 % \cmd{\aS}|{e}| \> \cmd{\aS*}|{e}| \> $\aS{e}$ \> $\aS*{e}$\\[0.75ex]
388 % \cmd{\Sb}|{x}| \> \cmd{\Sb*}|{x}| \> $\Sb{x}$ \> $\Sb*{x}$\\[0.75ex]
389 % \cmd{\aCSa}|{z}|\> \cmd{\aCSa*}|{z}| \> $\aCSa{z}$\> $\aCSa*{z}$
390 % \end{sample}
391 %
392 % The optional argument \meta{accent} is intended for \LaTeX{}
393 % accent commands % such as $\cmd{\dot}$, $\cmd{\ddot}$, etc., or
394 % their $\AmS$ equivalents, $\cmd{\Dot}$, $\cmd{\Ddot}$.
395 % \begin{sample}
396 % |\bS[\Ddot]{x}| \> $\bS[\Ddot]{x}$
397 % \end{sample}
398 %
399 % The \MT\ commands look ahead for sub- and superscripts (including primes) in
400 % order to place them at the correct horizontal and vertical positions.
401 % \begin{sample}
402 % \cmd{\bS}|[|\cmd{\Dot}|]{x}^s_i| \> $\bS[\Dot]{x}^s_i$ \\[1ex]
403 % \cmd{\bS}|[|\cmd{\Ddot}|]{x}_i^s| \> $\bS[\Ddot]{x}_i^s$ \\[1ex]
404 % \cmd{\bS}|{x}''^s_i| \> $\bS{x}''^s_i$ \\[1ex]
405 % \cmd{\bSa}|{E}^k| \> $\bSa{E}^k$ \\[1ex]
406 % \cmd{\aSb}|[|\cmd{\Dot}|]{E}_s| \> $\aSb[\Dot]{E}_s$
407 % \end{sample}
408 %
409 % The commands are also robust and can be used in moving commands such as
410 % footnotes\footnote{A vector $\aS{e}_i$ in a footnote}, headers, etc.
411 % \begin{sample}
412 % |\footnote{A vector $\aS{e}_i$ in a footnote}|
413 % \end{sample}
414 %
415 % The symbols scale to the appropriate sizes if used in sub- and superscripts.
416 % For example, for an integration path parameterized by the vector
417 % $\bS{r}^s(\xi)$, the equation for a line integral
418 % \begin{verbatim}
419 % \begin{equation*}
420 % \oint\limits_{\bS{r}^s(\xi)} \dotsi
421 % \end{equation*}
422 % \end{verbatim}
423 % gives
424 % \begin{equation*}
425 % \oint\limits_{\bS{r}^s(\xi)} \dotsi
426 % \end{equation*}
427 % \bigskip
428 %
429 % ^^A\clearpage
430 % \section{Symbol formatting commands}
431 % \subsection{Bold italic symbols}
432 %
433 % The symbol format can be set with the package options
434 % \begin{sample}
435 % \hskip14pc\=\kill
436 % |\usepackage{mattens}| \>|% Uses \boldsymbol as default|
437 % \end{sample}
438 % or
439 % \begin{sample}
440 % \hskip14pc\=\kill
441 % |\usepackage[noformat]{mattens}| \>|% No symbol formatting|
442 % \end{sample}
443 % or anywhere in the document with the command
444 % \begin{Decl}
445 % \cmd{\SetSymbFont}\marg{font-command}^^A
446 % \SpecialUsageIndex{\SetSymbFont}
447 % \end{Decl}
448 %
449 % \pagebreak[2]
450 % \noindent In general a typical setup to include unicode math
451 % \begin{sample}
452 % |\usepackage{ifxetex} |\\
453 % |\ifxetex |\\
454 % | ... Unicode-math and font selection ...|\\
455 % | \SetSymbFont{\symbfit} |\\
456 % |\else |\\
457 % | ... Font selection ... |\\
458 % | \usepackage{bm} |\\
459 % | \SetSymbFont{\bm} |\\
460 % |\fi |
461 % \end{sample}
462 %
463 %
464 % \noindent If the symbols are interpreted as tensors, then according to the ISO, it can
465 % be typeset in a slanted sans serif font (if you are fond of fonts). For the
466 % Computer Modern fonts with an \texttt{OT1} encoding, you can put in the
467 % preamble
468 % \begin{quote}
469 % |\DeclareMathAlphabet{\mathsfsl}{OT1}{cmss}{m}{sl}|
470 % \end{quote}
471 % Examples of formats are
472 % \begin{sample}
473 % |\SetSymbFont{\bm}| \>\SetSymbFont{\bm}$\aSb{E}_s$\\[1ex]
474 % |\SetSymbFont{\relax}| \>\SetSymbFont{\relax}$\aSb{E}_s$\\[1ex]
475 % |\SetSymbFont{\mathsfsl}| \>\SetSymbFont{\mathsfsl}$\aSb{E}_s$
476 % \end{sample}
477 % \SetSymbFont{\bm}
478 %
479 % Only the first symbol (or group) in multi-symbol constructions is formatted.
480 % This can be used to obtain
481 % \begin{sample}
482 % |\bS{{}xy}| ~|\bS*{xy}| \> $\bS{{}xy}$ ~ $\bS*{xy}$\\
483 % |\bS{xy}| \> $\bS{xy}$ \\
484 % |\bS{{xy}}| \> $\bS{{xy}}$
485 % \end{sample}
486 % or
487 % \begin{sample}
488 % |\bCSb*{\bS{x}+\bS{y}}| \> $\bCSb*{\bS{x}+\bS{y}}$\\[1ex]
489 % |\bSb{E_{313}}^s_r| \> $\bSb{E_{313}}^s_r$
490 % \end{sample}
491 %
492 % When a font does not have bold italic symbols and is properly configured, the
493 % |\bm| command constructs the symbols with the ``poor man's bold'' method.
494 % This results in the loss of the subscript kerning. This is the case for the
495 % \pkg{mathptm}\ package for Times fonts. If bold italic symbols are needed for
496 % Times fonts, it is advisable to use the \pkg{txfonts} package or one of the
497 % commercial fonts.
498 %
499 %
500 % \subsection{Struts}
501 %
502 % A strut can be inserted inside the tensor construction to force all the lines
503 % to the same height. This can be given in the package options
504 % \begin{sample}
505 % \hskip14pc\=\kill
506 % |\usepackage{mattens}| \>|% No strut as default |
507 % \end{sample}
508 % or
509 % \begin{sample}
510 % \hskip14pc\=\kill
511 % |\usepackage[mathstrut]{mattens}| \>|% Uses \mathstrut |
512 % \end{sample}
513 % or anywhere in the document with the command
514 % \begin{Decl}
515 % \SpecialUsageIndex{\SetSymbStrut}^^A
516 % \cmd{\SetSymbStrut}\marg{strut}
517 % \end{Decl}
518 %
519 % \pagebreak[2]
520 % \noindent For example
521 % \SetSymbStrut{\relax}
522 % \begin{sample}
523 % |\SetSymbStrut{\relax}| \\
524 % |\bSb{E}|, |\bS{x}|, |\Sb{y}| \>$\bSb{E}$, $\bS{x}$, $\Sb{y}$
525 % \end{sample}
526 % \SetSymbStrut{\mathstrut}
527 % \begin{sample}
528 % |\SetSymbStrut{\mathstrut}| \\
529 % |\bSb{E}|, |\bS{x}|, |\Sb{y}| \>$\bSb{E}$, $\bS{x}$, $\Sb{y}$
530 % \end{sample}
531 % \SetSymbStrut{\vphantom{E}}
532 % \begin{sample}
533 % |\SetSymbStrut{\vphantom{E}}| \\
534 % |\bSb{E}|, |\bS{x}|, |\Sb{y}| \>$\bSb{E}$, $\bS{x}$, $\Sb{y}$
535 % \end{sample}
536 % \SetSymbStrut{\relax}
537 %
538 % \subsection{Additional sub- and superscript spaces}
539 %
540 % The placing of the sub- and superscripts was fine-tuned for Computer Modern
541 % fonts. Other fonts may require the sub- and superscript to shift closer or
542 % further away from the lines and the symbols. Additional spaces can be
543 % inserted before the sub- and superscripts with the following commands:
544 % \begin{Decl}
545 % \cmd{\SetArrowSkip}\marg{muskip length}\\[.5ex]
546 % \cmd{\SetBarSkip}\marg{muskip length}\\[.5ex]
547 % \cmd{\SetSymSubSkip}\marg{muskip length}\\[.5ex]
548 % \cmd{\SetSymSupSkip}\marg{muskip length}
549 % \SpecialUsageIndex{\SetArrowSkip}
550 % \SpecialUsageIndex{\SetBarSkip}
551 % \SpecialUsageIndex{\SetSymSubSkip}
552 % \SpecialUsageIndex{\SetSymSupSkip}
553 % \end{Decl}
554 % \noindent The length units must be in math units (\myemph{mu}), where
555 % $18\,\mathit{mu}=1\,\mathit{em}$ (a little less than the width of the letter
556 % ``M'').
557 %
558 % \section{Other packages and classes}
559 %
560 % \begin{description}
561 % \item[\normalfont\pkg{bm}:\quad] The \pkg{bm} package is preferred
562 % for bold\-/\-heavy symbols in math mode. It can also be used to
563 % predeclare bold symbols for use with the starred form of the
564 % tensor commands, for example: \SetSymbFont{\bm}
565 % \begin{sample}
566 % | \bmdefine{\bO}{\mathit{\Omega}}|\\
567 % |$\bSb*{\bO_i}$| \>\qquad\qquad\qquad $\bSb*{\bO_i}$
568 % \end{sample}
569 %
570 % \item[\normalfont\pkg{hyperref}:\quad] When tensor symbols are set in
571 % chapter and section headers, \pkg{hyperref} crashes if the
572 % \cmd{\texorpdfstring} command is not used.
573 % \begin{sample}
574 % |\section{A header with \texorpdfstring{$\bS{x}^i_j$}{xij} in it}|
575 % \end{sample}
576 %
577 % \item[\normalfont\pkg{color}:\quad] To change the colour of a symbol
578 % the \cmd{\color} command must be grouped two levels deep to
579 % survive all the expansions if the \pkg{bm} package is loaded.
580 % \begin{sample}
581 % |$\aSb{{{\color{red}E}}}_i$| \> $\aSb{{{\color{red}E}}}_i$
582 % \end{sample}
583 %
584 % \item[\normalfont\pkg{accents}:\quad] For the creation of alternative
585 % accents the \MT\ package is fully compatible with the
586 % \pkg{accents}\ package. As an example of its usage, the equation
587 % in \Hass\cite{Hass93a}, \S10.1, p.82
588 %
589 % \begin{minipage}{\textwidth}
590 % \begin{verbatim}
591 % \SetSymbFont{\relax}
592 % \SetSymbStrut{\mathstrut}
593 % \newcommand{\dotr}[1]{%
594 % \accentset{\phantom{r}{\displaystyle.}r}{#1}}
595 % \begin{equation*}
596 % \text{apparent velocity}
597 % = \frac{\partial_r}{\mathrm{d}t} \aS{r}
598 % = \aS[\dotr]{r}
599 % = \aSb{E}_s \tdot \bS[\dotr]{r}^s
600 % \equiv \aS{v}_{\mathrm{app}}
601 % = \aS{v}_{\mathrm{rel}}
602 % \end{equation*}
603 % \end{verbatim}
604 % \end{minipage}
605 % \medskip
606 %
607 % which gives\SetSymbFont{\relax}\SetSymbStrut{\mathstrut}%
608 % \begin{equation*}
609 % \text{apparent velocity} =
610 % \frac{\partial_r}{\mathrm{d}t} \aS{r} =
611 % \aS[\dotr]{r} =
612 % \aSb{E}_s \tdot \bS[\dotr]{r}^s \equiv
613 % \aS{v}_{\mathrm{app}} =
614 % \aS{v}_{\mathrm{rel}}
615 % \end{equation*}
616 % \SetSymbStrut{\relax}\SetSymbFont{\bm}
617 % \end{description}
618 % ^^A\clearpage
619 %
620 % \section{To do's}
621 %
622 % \begin{itemize}
623 % \item The vertical spacing between the symbols and the lines and
624 % arrows differs, $\aSb{E}$, $\bSa{E}$. This problem cannot be
625 % fixed easily and would need some additional struts or even a
626 % rewriting of the arrows and lines commands.
627 %
628 % \item For the purists: The ends of the |\overrightarrow| are rounded
629 % (ligature of symbols), while the ends of the |\overline| are
630 % squared (\TeX{} line drawing).
631 % \item The shape of the arrow tip of the |\overrightarrow| command was
632 % probably not designed for this type of application and is much too broad
633 % in the final CM font version. This broad arrow shape is incidentally one
634 % of last changes by Prof.~Knuth to the CM font symbols. The PostScript
635 % version of the CM fonts typesets the arrow much better, but it is highly
636 % likely that it is still the old outdated version of the symbol.
637 % The \pkg{esvect} provides alternative vector symbols that can
638 % be used in \cmd{\overrightarrow}.
639 % \end{itemize}
640 % \bigskip
641 %
642 % \begin{thebibliography}{7}
643 % \bibitem{Hass93a}
644 % \Hass, W.~C.,
645 % ``Matrix Tensor Notation Part I. Rectilinear Orthogonal Coordinates,''
646 % \textsl{Comput. Math. Appl.},
647 % \textbf{26}(3), 1993, pp. 55--93.
648 %
649 % \bibitem{Hass93b}
650 % \Hass, W.~C.,
651 % ``Matrix Tensor Notation Part II. Skew and Curved Coordinates,''
652 % \textsl{Comput. Math. Appl.},
653 % \textbf{29}(11), 1993, pp. 1--103.
654 % \end{thebibliography}
655 %
656 % \StopEventually{} ^^A end StopEventually
657 %
658 % \clearpage
659 %
660 % \section{The Code: \pkg{mattens.sty}}
661 % \setlength{\parskip}{\smallskipamount}
662 % \setlength{\parindent}{0pt}
663 %
664 % \begin{macrocode}
665 %<*package>
666 % \end{macrocode}
667 %
668 %
669 %
670 % \subsection{Identification}
671 %
672 % \begin{macrocode}
673 \NeedsTeXFormat{LaTeX2e}
674 \ProvidesPackage{mattens}[2022/03/01
675 v1.3b
676 Matrix/Tensors (DNJ Els)]
677 % \end{macrocode}
678 %
679 %
680 %
681 % \subsection{Options}
682 %
683 % \begin{macro}{\MT@SymbStrt}
684 % \begin{macro}{\SetSymbStrut}
685 % Struts to set all the lines and arrows at
686 % predetermined heights and depths.
687 % \begin{macrocode}
688 \newcommand*{\MT@SymbStrt}{}
689 \newcommand*{\SetSymbStrut}[1]{\renewcommand*{\MT@SymbStrt}{#1}}
690 \SetSymbStrut{\relax}
691 \DeclareOption{mathstrut}{\SetSymbStrut{\mathstrut}}
692 % \end{macrocode}
693 % \end{macro}
694 % \end{macro}
695 %
696 % \begin{macro}{\MT@SymbFnt}
697 % \begin{macro}{\SetSymbFont}
698 % Initialize the symbol font formatting commands.
699 % \begin{macrocode}
700 \newcommand*{\MT@SymbFnt}{}
701 \newcommand*{\SetSymbFont}[1]{\renewcommand*{\MT@SymbFnt}{#1}}
702 \SetSymbFont{\boldsymbol}
703 \DeclareOption{noformat}{\SetSymbFont{\relax}}
704 % \end{macrocode}
705 % \end{macro}
706 % \end{macro}
707 %
708 % Process the options
709 % \changes{1.3a}{2010 Mar 25}{Remove invalid UTF-8 byte sequences}
710 % \begin{macrocode}
711 \DeclareOption*{%
712 \PackageWarning{mattens}{Unknown option: \CurrentOption}}
713 \ProcessOptions\relax
714 % \end{macrocode}
715 %
716 %
717 %
718 % \subsection{Packages}
719 %
720 % The \pkg{amsmath} package is loaded to provide the scalable
721 % \cmd{\overrightarrow} and \cmd{\underrightarrow} commands, as
722 % well as the \cmd{\boldsymbol} command for setting bold math
723 % symbols.
724 %
725 % \begin{macrocode}
726 \RequirePackage{amsmath}
727 % \end{macrocode}
728 %
729 %
730 %
731 % \subsection{Workaround commands}
732 %
733 % \begin{macro}{\MT@Overarrow}
734 % \begin{macro}{\MT@Underarrow}
735 % We define over- and under-arrows that bypass the
736 % \cmd{\mathpalette} part of the \pkg{amsmath} macros
737 % \cmd{\overrightarrow} and \cmd{\underrightarrow}. It uses
738 % the \pkg{amsmath} internal macros \cmd{\overarrow@},
739 % \cmd{\underarrow@} and \cmd{\rightarrowfill@}.
740 % The first parameter |#1| consists of math styles \cmd{\displaystyle},
741 % \cmd{\textstyle}, etc. The second parameter |#2| is the symbol
742 % or character.
743 % \begin{macrocode}
744 \newcommand{\MT@Overarrow}[2]{\overarrow@{\rightarrowfill@}{#1}{#2}}
745 \newcommand{\MT@Underarrow}[2]{\underarrow@{\rightarrowfill@}{#1}{#2}}
746 % \end{macrocode}
747 % \end{macro}
748 % \end{macro}
749 %
750 % \begin{macro}{\MT@Overline}
751 % \begin{macro}{\MT@Underline}
752 % Make over- and underlines with the same calling syntax as
753 % the arrows.
754 % \begin{macrocode}
755 \newcommand{\MT@Overline}[2]{{#1\overline{#2}}}
756 \newcommand{\MT@Underline}[2]{{#1\underline{#2}}}
757 % \end{macrocode}
758 % \end{macro}
759 % \end{macro}
760 %
761 % \begin{macro}{\xusebox}
762 % \changes{1.1}{2004 Jan 15}{More streamline.}
763 % \changes{1.2}{2004 Jan 27}{Test if \pkg{pdftex.def} is loaded.
764 % and command is rewritten to use a \cmd{\mathord} to
765 % restore script heights}
766 % The \cmd{\usebox} command does not function properly when the
767 % \pkg{pdftex.def} driver is loaded, because \pkg{pdftex} does
768 % not implement a colour stack such as in the \pkg{dvips} driver,
769 % but simulate it at \TeX{} macro level. The \cmd{\xusebox} is
770 % a workaround where the \cmd{\usebox} command is grouped.\footnote{
771 % Thanks to Heiko Oberdiek for this workaround}
772 % A |\mathord| is added around the box to regain its height in the
773 % \pkg{pdftex} case.
774 % \begin{macrocode}
775 \AtBeginDocument{%
776 \@ifl@aded{def}{pdftex}%
777 {\newcommand*{\xusebox}[1]{\mathord{{\usebox{#1}}}}}%
778 {\let\xusebox\usebox}%
779 }
780 % \end{macrocode}
781 % \end{macro}
782 %
783 %
784 %
785 % \subsection{Initialize}
786 %
787 % Define skip lengths for insertion in front of sub- and
788 % superscripts.
789 % \begin{macrocode}
790 \newmuskip{\MT@Askip}
791 \newmuskip{\MT@Bskip}
792 \newmuskip{\MT@SPskip}
793 \newmuskip{\MT@SBskip}
794 % \end{macrocode}
795 %
796 % \begin{macro}{\SetArrowSkip}
797 % \begin{macro}{\SetBarSkip}
798 % \begin{macro}{\SetSymSupSkip}
799 % \begin{macro}{\SetSymSubSkip}
800 % Define commands to set or change the skip lengths and set initial values.
801 % \begin{macrocode}
802 \newcommand*{\SetArrowSkip}[1]{\MT@Askip#1}
803 \newcommand*{\SetBarSkip}[1]{\MT@Bskip#1}
804 \newcommand*{\SetSymSupSkip}[1]{\MT@SPskip#1}
805 \newcommand*{\SetSymSubSkip}[1]{\MT@SBskip#1}
806 \SetArrowSkip{0mu}
807 \SetBarSkip{1mu}
808 \SetSymSubSkip{0mu}
809 \SetSymSupSkip{0mu}
810 % \end{macrocode}
811 % \end{macro}
812 % \end{macro}
813 % \end{macro}
814 % \end{macro}
815 %
816 % \begin{macro}{\MT@SubSkip}
817 % \begin{macro}{\MT@SupSkip}
818 % Define math skip lengths to insert in front of the sub- and
819 % superscripts. The values are set inside the main \MT\ commands
820 % according to the type of symbol.
821 % \begin{macrocode}
822 \newmuskip\MT@SubSkip
823 \newmuskip\MT@SupSkip
824 % \end{macrocode}
825 % \end{macro}
826 % \end{macro}
827 %
828 %
829 %
830 % \subsection{Main \MT\ commands}
831 %
832 % Setup command templates and lengths to function as global
833 % variables and pointers.
834 %
835 % \begin{macro}{\MT@accent}
836 % The \cmd{\MT@accent} command points
837 % to the math accent that are inserted as the optional argument
838 % inside the main \MT\ commands.
839 %
840 % \begin{macrocode}
841 \newcommand*{\MT@accent}{}
842 % \end{macrocode}
843 % \end{macro}
844 %
845 % \begin{macro}{\MT@cmd}
846 % \begin{macro}{\MT@@cmd}
847 % The commands \cmd{\MT@cmd} and \cmd{\MT@cmd} do the actual
848 % typesetting of the symbols.
849 % \begin{macrocode}
850 \newcommand*{\MT@cmd}{}
851 \newcommand*{\MT@@cmd}{}
852 % \end{macrocode}
853 % \end{macro}
854 % \end{macro}
855 %
856 %
857 % They can be seen
858 % as function pointer that are set with |\let| commands inside
859 % the main \MT\ commands to point to specific commands.
860 %
861 % \newcommand{\RA}{\ensuremath{\,\mapsto\,}}
862 %
863 % \begin{tabbing}
864 % \hskip2pc\=\hskip3pc\=\hskip12pc\=\kill
865 % \>\textsl{Cmd} \> \textsl{Primary command} \> \textsl{Secondary command}\\[.75ex]
866 % \>|\aS|: \>|\MT@cmd| \RA |\MT@OverAandB|, \>|\MT@@cmd| \RA |\MT@Overarrow|\\
867 % \>|\bS|: \>|\MT@cmd| \RA |\MT@OverAandB|, \>|\MT@@cmd| \RA |\MT@Overline|\\
868 % \>|\Sa|: \>|\MT@cmd| \RA |\MT@UnderAandB|, \>|\MT@@cmd| \RA |\MT@Underarrow|\\
869 % \>|\Sb|: \>|\MT@cmd| \RA |\MT@UnderAandB|, \>|\MT@@cmd| \RA |\MT@Underline|\\
870 % \>|\bSb|: \>|\MT@cmd| \RA |\MT@DoubleAandB|, \>|\MT@@cmd| \RA |\MT@@bSb| \\
871 % \>|\aSb|: \>|\MT@cmd| \RA |\MT@DoubleAandB|, \>|\MT@@cmd| \RA |\MT@@aSb|\\
872 % \>|\bSa|: \>|\MT@cmd| \RA |\MT@DoubleAandB|, \>|\MT@@cmd| \RA |\MT@@bSa| \\
873 % \>|\aSa|: \>|\MT@cmd| \RA |\MT@DoubleAandB|, \>|\MT@@cmd| \RA |\MT@@aSa|\\
874 % \>|\bCSb|: \>|\MT@cmd| \RA |\MT@DoubleAandB|, \>|\MT@@cmd| \RA |\MT@@bCSb|\\
875 % \>|\aCSa|: \>|\MT@cmd| \RA |\MT@DoubleAandB|, \>|\MT@@cmd| \RA |\MT@@aCSa|\\
876 % \end{tabbing}
877 %
878 %
879 % \begin{macro}{\MT@bold}
880 % The \cmd{\MT@bold} command is used internally and set by the
881 % ``starred'' command option.
882 % \begin{macrocode}
883 \newcommand*{\MT@bold}{}
884 % \end{macrocode}
885 % \end{macro}
886 %
887 % \begin{macro}{\aS}
888 % Type the tensor: $\aS{x}$
889 % \begin{macrocode}
890 \DeclareRobustCommand*{\aS}{%
891 \let\MT@cmd=\MT@OverAandB%
892 \let\MT@@cmd=\MT@Overarrow%
893 \MT@SupSkip=\MT@Askip%
894 \MT@SubSkip=\MT@SBskip%
895 \MT@Tensor}
896 % \end{macrocode}
897 % \end{macro}
898 %
899 % \begin{macro}{\bS}
900 % Type the tensor: $\bS{x}$
901 % \begin{macrocode}
902 \DeclareRobustCommand*{\bS}{%
903 \let\MT@cmd=\MT@OverAandB%
904 \let\MT@@cmd=\MT@Overline%
905 \MT@SupSkip=\MT@Bskip%
906 \MT@SubSkip=\MT@SBskip%
907 \MT@Tensor}%
908 % \end{macrocode}
909 % \end{macro}
910 %
911 %
912 % \begin{macro}{\Sa}
913 % Type the tensor: $\Sa{x}$
914 % \begin{macrocode}
915 \DeclareRobustCommand*{\Sa}{%
916 \let\MT@cmd=\MT@UnderAandB%
917 \let\MT@@cmd=\MT@Underarrow%
918 \MT@SupSkip=\MT@SPskip%
919 \MT@SubSkip=\MT@Askip%
920 \MT@Tensor}
921 % \end{macrocode}
922 % \end{macro}
923 %
924 % \begin{macro}{\Sb}
925 % Type the tensor: $\Sb{x}$
926 % \begin{macrocode}
927 \DeclareRobustCommand*{\Sb}{%
928 \let\MT@cmd=\MT@UnderAandB%
929 \let\MT@@cmd=\MT@Underline%
930 \MT@SupSkip=\MT@SPskip%
931 \MT@SubSkip=\MT@Bskip%
932 \MT@Tensor}
933 % \end{macrocode}
934 % \end{macro}
935 %
936 % \begin{macro}{\bSb}
937 % Type the tensor: $\bSb{E}$
938 % \begin{macrocode}
939 \DeclareRobustCommand*{\bSb}{%
940 \let\MT@cmd=\MT@DoubleAandB%
941 \let\MT@@cmd=\MT@@bSb%
942 \MT@SupSkip=\MT@Bskip%
943 \MT@SubSkip=\MT@Bskip%
944 \MT@Tensor}
945 % \end{macrocode}
946 % \end{macro}
947 %
948 % \begin{macro}{\aSb}
949 % Type the tensor: $\aSb{E}$
950 % \begin{macrocode}
951 \DeclareRobustCommand*{\aSb}{%
952 \let\MT@cmd=\MT@DoubleAandB%
953 \let\MT@@cmd=\MT@@aSb%
954 \MT@SupSkip=\MT@Askip%
955 \MT@SubSkip=\MT@Bskip%
956 \MT@Tensor}
957 % \end{macrocode}
958 % \end{macro}
959 %
960 % \begin{macro}{\bSa}
961 % Type the tensor: $\bSa{E}$
962 % \begin{macrocode}
963 \DeclareRobustCommand*{\bSa}{%
964 \let\MT@cmd=\MT@DoubleAandB%
965 \let\MT@@cmd=\MT@@bSa%
966 \MT@SupSkip=\MT@Bskip%
967 \MT@SubSkip=\MT@Askip%
968 \MT@Tensor}
969 % \end{macrocode}
970 % \end{macro}
971 %
972 % \begin{macro}{\aSa}
973 % Type the tensor: $\aSa{E}$
974 % \begin{macrocode}
975 \DeclareRobustCommand*{\aSa}{%
976 \let\MT@cmd=\MT@DoubleAandB%
977 \let\MT@@cmd=\MT@@aSa%
978 \MT@SupSkip=\MT@Askip%
979 \MT@SubSkip=\MT@Askip%
980 \MT@Tensor}
981 % \end{macrocode}
982 % \end{macro}
983 %
984 % \begin{macro}{\bCSb}
985 % Type the tensor: $\bCSb{\omega}$
986 % \begin{macrocode}
987 \DeclareRobustCommand*{\bCSb}{%
988 \let\MT@cmd=\MT@DoubleAandB%
989 \let\MT@@cmd=\MT@@bCSb%
990 \MT@SupSkip=\MT@Bskip%
991 \MT@SubSkip=\MT@Bskip%
992 \MT@Tensor}
993 % \end{macrocode}
994 % \end{macro}
995 %
996 % \begin{macro}{\aCSa}
997 % Type the tensor: $\aCSa{\omega}$
998 % \begin{macrocode}
999 \DeclareRobustCommand*{\aCSa}{%
1000 \let\MT@cmd=\MT@DoubleAandB%
1001 \let\MT@@cmd=\MT@@aCSa%
1002 \MT@SupSkip=\MT@Askip%
1003 \MT@SubSkip=\MT@Askip%
1004 \MT@Tensor}
1005 % \end{macrocode}
1006 % \end{macro}
1007 %
1008 % \begin{macro}{\MT@Tensor}
1009 % \changes{1.1}{2004 Jan 15}{Added to reduce overall code.}
1010 % \begin{macro}{\MT@@Tensor}
1011 % \changes{1.1}{2004 Jan 15}{Added to reduce overall code.}
1012 % General tensor commands to look for starred form and
1013 % and initiate script extraction.
1014 % \begin{macrocode}
1015 \newcommand*{\MT@Tensor}{%
1016 \@ifstar{\let\MT@bold=\@firstofone\MT@@Tensor}
1017 {\let\MT@bold=\MT@SymbFnt\MT@@Tensor}}
1018 % \end{macrocode}
1019 % \begin{macrocode}
1020 \newcommand*{\MT@@Tensor}[2][\@firstofone]{%
1021 \let\MT@accent=#1\relax%
1022 \MT@GetScripts{#2}}
1023 % \end{macrocode}
1024 % \end{macro}
1025 % \end{macro}
1026 %
1027 %
1028 %
1029 % \subsection{Sub- and superscripts}
1030 %
1031 %
1032 % \begin{macro}{\MT@GetScripts}
1033 % This part of the code looks ahead for sub- and superscripts.
1034 % \changes{1.1}{2004 Jan 15}{Add: Code to check for primes}
1035 % \begin{macrocode}
1036 \newcommand*\MT@GetScripts[1]{%
1037 \@ifnextchar'%
1038 {\MT@GetPrimes{#1}{\prime}}%
1039 {\MT@UnprimedScripts{#1}}}
1040 % \end{macrocode}
1041 % \end{macro}
1042 %
1043 % \begin{macro}{\MT@GetPrimes}
1044 % \changes{1.1}{2004 Jan 15}{Add: Extract primes}
1045 % \begin{macro}{\MT@GetPrimedSuper}
1046 % \changes{1.1}{2004 Jan 15}{Add: Extract primes}
1047 % \begin{macro}{\MT@GetPrimedSub}
1048 % \changes{1.1}{2004 Jan 15}{Add: Extract primes}
1049 % Extract primes and look ahead for superscripts |^|. Note that
1050 % the sequence of operators for a primed symbol is:
1051 % \meta{symb}|'|$^{..}\!\!$|'^|\meta{sup}|_|\meta{sub}
1052 % \begin{macrocode}
1053 \newcommand*\MT@GetPrimes[3]{%
1054 \@ifnextchar'%
1055 {\MT@GetPrimes{#1}{#2\prime}}%
1056 {\@ifnextchar^%
1057 {\MT@GetPrimedSuper{#1}{#2}}%
1058 {\@ifnextchar_%
1059 {\MT@GetPrimedSub{#1}{#2}}%
1060 {\MT@SetScripts{#1}{#2}{\@empty}}%
1061 }%
1062 }%
1063 }
1064 % \end{macrocode}
1065 % \begin{macrocode}
1066 \def\MT@GetPrimedSuper#1#2^#3{%
1067 \@ifnextchar_{\MT@GetPrimedSub{#1}{#2#3}}%
1068 {\MT@SetScripts{#1}{#2#3}{\@empty}}}
1069 % \end{macrocode}
1070 % \begin{macrocode}
1071 \def\MT@GetPrimedSub#1#2_#3{%
1072 \MT@SetScripts{#1}{#2}{#3}}
1073 % \end{macrocode}
1074 % \end{macro}
1075 % \end{macro}
1076 % \end{macro}
1077 %
1078 % \begin{macro}{\MT@UnprimedScripts}
1079 % The first extraction command for symbols without primes.
1080 % It looks ahead for |^| or |_|, if not present, then pass
1081 % \cmd{\@empty} flags forward, otherwise it passes the tokens
1082 % on to the next extraction commands.
1083 %
1084 % \begin{macrocode}
1085 \newcommand*\MT@UnprimedScripts[1]{%
1086 \@ifnextchar^%
1087 {\MT@GetSuper{#1}}%
1088 {\@ifnextchar_%
1089 {\MT@GetSub{#1}}%
1090 {\MT@SetScripts{#1}{\@empty}{\@empty}}%
1091 }%
1092 }
1093 % \end{macrocode}
1094 % \end{macro}
1095 %
1096 % \begin{macro}{\MT@GetSuper}
1097 % Extract scripts of the form \meta{Sym}|^|\meta{sup}
1098 % if there are no further |_| tokens available, otherwise pass the
1099 % tokens on to the next extraction command.
1100 %
1101 % \begin{macrocode}
1102 \def\MT@GetSuper#1^#2{%
1103 \@ifnextchar_{\MT@GetSuperSub{#1}{#2}}%
1104 {\MT@SetScripts{#1}{#2}{\@empty}}}
1105 % \end{macrocode}
1106 % \end{macro}
1107 %
1108 % \begin{macro}{\MT@GetSub}
1109 % Extract scripts of the form \meta{Sym}|_|\meta{sub}
1110 % if there are no further |^| tokens available, otherwise pass the
1111 % tokens on to the next extraction command.
1112 %
1113 % \begin{macrocode}
1114 \def\MT@GetSub#1_#2{%
1115 \@ifnextchar^{\MT@GetSubSuper{#1}{#2}}%
1116 {\MT@SetScripts{#1}{\@empty}{#2}}}
1117 % \end{macrocode}
1118 % \end{macro}
1119 %
1120 % \begin{macro}{\MT@GetSuperSub}
1121 % Extract scripts of the form
1122 % \meta{Sym}|^|\meta{sup}|_|\meta{sub}.
1123 %
1124 % \begin{macrocode}
1125 \def\MT@GetSuperSub#1#2_#3{%
1126 \MT@SetScripts{#1}{#2}{#3}}
1127 % \end{macrocode}
1128 % \end{macro}
1129 %
1130 % \begin{macro}{\MT@GetSubSuper}
1131 % Extract scripts of the form
1132 % \meta{Sym}|_|\meta{sub}|^|\meta{sup}.
1133 %
1134 % \begin{macrocode}
1135 \def\MT@GetSubSuper#1#2^#3{%
1136 \MT@SetScripts{#1}{#3}{#2}}
1137 % \end{macrocode}
1138 % \end{macro}
1139 %
1140 % \begin{macro}{\MT@SetSup}
1141 % \begin{macro}{\MT@SetSub}
1142 % Define global variables commands that contain the extracted
1143 % sub- and superscripts. These commands are redefined inside the
1144 % the final \cmd{\MT@SetScripts} command.
1145 %
1146 % \begin{macrocode}
1147 \newcommand*{\MT@SetSup}{}
1148 \newcommand*{\MT@SetSub}{}
1149 \newcommand*{\MT@SetSubS}{}
1150 % \end{macrocode}
1151 % \end{macro}
1152 % \end{macro}
1153 %
1154 % \changes{1.3}{2009 Sep 1}{Remove \cmd{\ensuremath} to force math mode.}
1155 % \begin{macrocode}
1156 \newcommand*\MT@SetScripts[3]{%
1157 \let\MT@SetSup\relax%
1158 \let\MT@SetSub\relax%
1159 \let\MT@SetSubS\relax%
1160 \ifx\@empty#2\@empty\else
1161 \def\MT@SetSup{^{\mskip\MT@SupSkip\relax#2}}%
1162 \fi
1163 \ifx\@empty#3\@empty\else
1164 \def\MT@SetSub{_{\mskip\MT@SubSkip\relax#3}}%
1165 \def\MT@SetSubS{^{}_{\mskip\MT@SubSkip\relax#3}}%
1166 \fi
1167 \MT@cmd{#1}}
1168 % \end{macrocode}
1169 %
1170 %
1171 %
1172 % \subsection{Symbol formatting}
1173 %
1174 % \begin{macro}{\MT@Symb}
1175 % This command type |{|\meta{strut}\meta{font-cmd}\meta{symb}|}|,
1176 % the formatted symbol preceded by the selected strut. It is called
1177 % from within the main typesetting commands.
1178 %
1179 % \begin{macrocode}
1180 \newcommand*{\MT@Symb}[1]{\MT@SymbStrt\MT@bold#1}
1181 % \end{macrocode}
1182 % \end{macro}
1183 %
1184 % \begin{macro}{\MT@SymbC}
1185 % Puts a widetilde over the symbol for the cross product tensors.
1186 % \begin{macrocode}
1187 \newcommand*{\MT@SymbC}[1]{%
1188 \MT@SymbStrt\widetilde{%
1189 \MT@bold#1}}
1190 % \end{macrocode}
1191 % \end{macro}
1192 %
1193 %
1194 % \subsection{Main typesetting commands}
1195 %
1196 % The commands in this section are the ones pointed to by
1197 % the \cmd{\MT@cmd} and \cmd{\MT@@cmd} commands to perform
1198 % the typesetting of the full tensor symbol.
1199 %
1200 % Declare some save boxes
1201 % \begin{macrocode}
1202 \newsavebox{\MT@Abox} % for overline/arrow
1203 \newsavebox{\MT@Sbox} % for symbol
1204 \newsavebox{\MT@Tbox} % for tempories
1205 \newsavebox{\MT@APbox} % for overline/arrow phantom
1206 \newsavebox{\MT@SPbox} % for symbol phantom
1207 % \end{macrocode}
1208 % and some lengths.
1209 % \begin{macrocode}
1210 \newlength{\MT@SPwdth} % symbol width
1211 \newlength{\MT@BPwdth} % Bar width
1212 \newlength{\MT@Wwdth} % leading whitespace width
1213 % \end{macrocode}
1214 %
1215 % \begin{macro}{\MT@OverAandB}
1216 % This command generates the tensor symbols $\aS{e}$ and $\bS{e}$.
1217 % It utilizes the \cmd{\mathpalette} macro for the sizing of the
1218 % final tensor. \LaTeX{} commands \cmd{\smash} and \cmd{\phantom}
1219 % with embedded \cmd{\mathpalette} calls are avoided to prevent
1220 % nested \cmd{\mathchoice} calls.
1221 % \begin{macrocode}
1222 \newcommand*{\MT@OverAandB}{%
1223 \mathpalette\MT@@OverAandB}
1224 % \end{macrocode}
1225 % \end{macro}
1226 %
1227 % \begin{macro}{\MT@@OverAandB}
1228 % \changes{1.2}{2004 Jan 27}{Use \cmd{\xusebox} inside accent
1229 % to account for \cmd{\dddot}.}
1230 % For this command the first parameter |#1| is supplied by
1231 % \cmd{\mathpalette} and consists of math styles \cmd{\displaystyle},
1232 % \cmd{\textstyle}, etc. The second parameter |#2| is the original
1233 % \meta{symbol} from the call \cmd{\MT@cmd}|{|\meta{symbol}|}|.
1234 %
1235 % \begin{macrocode}
1236 \newcommand*{\MT@@OverAandB}[2]{%
1237 % \end{macrocode}
1238 % \begin{Indent}{5em}
1239 % Set the symbol inside a box for measurement purposes.
1240 % \end{Indent}
1241 % \begin{macrocode}
1242 \sbox{\MT@Tbox}{$\m@th#1\MT@Symb{#2}$}%
1243 % \end{macrocode}
1244 % \begin{Indent}{5em}
1245 % Make phantom symbol box (empty) with size identical to symbol.
1246 % \end{Indent}
1247 % \begin{macrocode}
1248 \setbox\MT@SPbox\null%
1249 \ht\MT@SPbox\ht\MT@Tbox%
1250 \dp\MT@SPbox\dp\MT@Tbox%
1251 \wd\MT@SPbox\wd\MT@Tbox%
1252 % \end{macrocode}
1253 % \begin{Indent}{5em}
1254 % Make overline/overarrow over phantom symbol box for measurement.
1255 % \end{Indent}
1256 % \begin{macrocode}
1257 \sbox{\MT@APbox}{$\m@th\MT@@cmd{#1}{\copy\MT@SPbox}$}%
1258 % \end{macrocode}
1259 % \begin{Indent}{5em}
1260 % Calculate width difference between symbol and arrow/overline.
1261 % \end{Indent}
1262 % \begin{macrocode}
1263 \setlength{\MT@Wwdth}{\the\wd\MT@APbox}%
1264 \addtolength{\MT@Wwdth}{-\the\wd\MT@SPbox}%
1265 % \end{macrocode}
1266 % \begin{Indent}{5em}
1267 % Make final symbol box with white space in front to center is
1268 % beneath the arrow/over line and subscript that follows.
1269 % \end{Indent}
1270 % \begin{macrocode}
1271 \sbox{\MT@Sbox}{$\m@th#1\hskip 0.5\MT@Wwdth\relax\MT@Symb{#2}\MT@SetSubS$}%
1272 % \end{macrocode}
1273 % \begin{Indent}{5em}
1274 % Add math accent to overline/overarrow and reset box dimensions to
1275 % original.
1276 % \end{Indent}
1277 % \begin{macrocode}
1278 \sbox{\MT@Tbox}{$\m@th#1\MT@accent{\xusebox{\MT@APbox}}$}%
1279 \ht\MT@Tbox\ht\MT@APbox%
1280 \dp\MT@Tbox\dp\MT@APbox%
1281 % \end{macrocode}
1282 % \begin{Indent}{5em}
1283 % Final overline/overarrow box including accent and superscript at end.
1284 % \end{Indent}
1285 % \begin{macrocode}
1286 \sbox{\MT@Abox}{$\m@th#1\xusebox{\MT@Tbox}\MT@SetSup$}%
1287 % \end{macrocode}
1288 % \begin{Indent}{5em}
1289 % Overtype the symbol and the overline/overarrow boxes. The wider
1290 % box of the two is typed last to ensure that the spacing after
1291 % the full tensor symbol is correct.
1292 % \end{Indent}
1293 % \begin{macrocode}
1294 \ifdim\wd\MT@Abox<\wd\MT@Sbox%
1295 \leavevmode\rlap{\usebox\MT@Abox}{\usebox\MT@Sbox}%
1296 \else%
1297 \leavevmode\rlap{\usebox\MT@Sbox}{\usebox\MT@Abox}%
1298 \fi}
1299 % \end{macrocode}
1300 % \end{macro}
1301 %
1302 % \begin{macro}{\MT@UnderAandB}
1303 % \begin{macro}{\MT@@UnderAandB}
1304 % \changes{1.2}{2004 Jan 27}{Make provisions for wide accents (\cmd{\dddot}).}
1305 % This command generates the tensor symbols $\Sa{e}$ and $\Sb{e}$.
1306 % It is identical to the previous command except the sub- and
1307 % superscripts are swapped and the phantom box is set to the width
1308 % of the accent.
1309 % \begin{macrocode}
1310 \newcommand*{\MT@UnderAandB}{%
1311 \mathpalette\MT@@UnderAandB}
1312 % \end{macrocode}
1313 % \begin{macrocode}
1314 \newcommand*{\MT@@UnderAandB}[2]{%
1315 \sbox{\MT@Tbox}{$\m@th#1\MT@accent{\MT@Symb{#2}}$}%
1316 \setbox\MT@SPbox\null%
1317 \wd\MT@SPbox\wd\MT@Tbox%
1318 \sbox{\MT@Tbox}{$\m@th#1\MT@Symb{#2}$}%
1319 \ht\MT@SPbox\ht\MT@Tbox%
1320 \dp\MT@SPbox\dp\MT@Tbox%
1321 \sbox{\MT@APbox}{$\m@th\MT@@cmd{#1}{\copy\MT@SPbox}$}%
1322 \setlength{\MT@Wwdth}{\the\wd\MT@APbox}%
1323 \addtolength{\MT@Wwdth}{-\the\wd\MT@SPbox}%
1324 \sbox{\MT@Sbox}{$\m@th#1%
1325 \hskip 0.5\MT@Wwdth\relax\MT@accent{\MT@Symb{#2}}\MT@SetSup$}%
1326 \sbox{\MT@Abox}{$\m@th#1\xusebox{\MT@APbox}\MT@SetSub$}%
1327 \ifdim\wd\MT@Abox<\wd\MT@Sbox%
1328 \leavevmode\rlap{\usebox\MT@Abox}{\usebox\MT@Sbox}%
1329 \else%
1330 \leavevmode\rlap{\usebox\MT@Sbox}{\usebox\MT@Abox}%
1331 \fi}
1332 % \end{macrocode}
1333 % \end{macro}
1334 % \end{macro}
1335 %
1336 % \begin{macro}{\MT@@bSb}
1337 % \begin{macro}{\MT@@bSa}
1338 % \begin{macro}{\MT@@aSb}
1339 % \begin{macro}{\MT@@aSa}
1340 % \begin{macro}{\MT@@bCSb}
1341 % \begin{macro}{\MT@@aCSa}
1342 % These commands are pointed to by \cmd{\MT@@cmd} and called from
1343 % within \cmd{\MT@DoubleAandB}. It has the same calling syntax as
1344 % the \cmd{\MT@Overarrow} and \cmd{\MT@Underarrow} commands.
1345 % \begin{macrocode}
1346 \newcommand*{\MT@@bSb}[2]{\MT@Overline{#1}{\MT@Underline{#1}{\MT@Symb{#2}}}}
1347 \newcommand*{\MT@@aSb}[2]{\MT@Overarrow{#1}{\MT@Underline{#1}{\MT@Symb{#2}}}}
1348 \newcommand*{\MT@@bSa}[2]{\MT@Overline{#1}{\MT@Underarrow{#1}{\MT@Symb{#2}}}}
1349 \newcommand*{\MT@@aSa}[2]{\MT@Overarrow{#1}{\MT@Underarrow{#1}{\MT@Symb{#2}}}}
1350 \newcommand*{\MT@@bCSb}[2]{\MT@Overline{#1}{\MT@Underline{#1}{\MT@SymbC{#2}}}}
1351 \newcommand*{\MT@@aCSa}[2]{\MT@Overarrow{#1}{\MT@Underarrow{#1}{\MT@SymbC{#2}}}}
1352 % \end{macrocode}
1353 % \end{macro}
1354 % \end{macro}
1355 % \end{macro}
1356 % \end{macro}
1357 % \end{macro}
1358 % \end{macro}
1359 %
1360 % \begin{macro}{\MT@DoubleAandB}
1361 % \begin{macro}{\MT@@DoubleAandB}
1362 % \changes{1.2}{2004 Jan 27}{Use \cmd{\xusebox} inside accent
1363 % to account for \cmd{\dddot}.}
1364 % This command is used for the remaining tensor symbols and is not
1365 % so complex compared to the previous commands.
1366 %
1367 % \begin{macrocode}
1368 \newcommand*{\MT@DoubleAandB}{%
1369 \mathpalette\MT@@DoubleAandB}
1370 % \end{macrocode}
1371 % \begin{macrocode}
1372 \newcommand*{\MT@@DoubleAandB}[2]{%
1373 \sbox{\MT@Abox}{$\m@th#1\MT@@cmd{#1}{#2}$}%
1374 \sbox{\MT@Tbox}{$\m@th#1\MT@accent{\xusebox{\MT@Abox}}$}%
1375 \ht\MT@Tbox\ht\MT@Abox%
1376 \dp\MT@Tbox\dp\MT@Abox%
1377 \xusebox{\MT@Tbox}\MT@SetSup\MT@SetSub}
1378 % \end{macrocode}
1379 % \end{macro}
1380 % \end{macro}
1381 %
1382 %
1383 % \changes{1.1}{2004 Jan 15}{Code: Remove helper commands}
1384 % \begin{macrocode}
1385 %</package>
1386 % \end{macrocode}
1387 % \clearpage
1388 % \Finale
1389 % \setcounter{IndexColumns}{2}\PrintIndex
1390 % \PrintChanges
1391 %
1392 \endinput