-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinalgjh.sty
396 lines (340 loc) · 14.2 KB
/
linalgjh.sty
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
\ProvidesPackage{linalgjh}[2001/06/08 Mathematics material for _Linear Algebra_ JH]
% linalgjh
%
% Misc math that comes in handy for linear algebra.
%
% HISTORY
% 2001-Jun-08 Jim Hefferon Cleaned up.
% input all the math packages
\RequirePackage{mathrsfs}
% AMS math
% \RequirePackage[reqno]{amsmath}
\RequirePackage[reqno,disallowspaces]{mathtools} % imports amsmath
\RequirePackage{amsfonts} %for Y&Y BSR AMS fonts
\RequirePackage{amssymb}
% \RequirePackage{amsthm}
\RequirePackage{array}
\RequirePackage{amscd}
% \RequirePackage{accents}
%--------linsys
% Use as \begin{linsys}{3}
% x &+ &3y &+ &a &= &7 \\
% x &- &3y &+ &a &= &7
% \end{linsys}
% Remark: TeXbook pp. 167-170 says to put a medmuskip around a +; and that's
% 4/18-ths of an em. Why does 2/18-ths of an em work? I don't know, but
% comparing to a regular displayed equation suggests it is right.
% (darseneau says LaTeX puts in half an \arraycolsep.)
\newenvironment{linsys}[2][m]{%
\setlength{\arraycolsep}{.1111em} % p. 170 TeXbook; a medmuskip
\begin{array}[#1]{@{}*{#2}{rc}r@{}}
}{%
\end{array}}
% Sometimes a system has a column with no + or - in it. LaTeX skips the space
% in that column, and I'd like to put in a box of the right width there.
\newsavebox\boxofmathplus
\sbox{\boxofmathplus}{$+$}
\newcommand{\spaceforemptycolumn}{\makebox[\wd\boxofmathplus]{\ }}
%--------grstep
% For denoting a Gauss' reduction step.
% Use as: \grstep{\rho_1+\rho_3} or \grstep[2\rho_5 \\ 3\rho_6]{\rho_1+\rho_3}
% \newcommand{\grstep}[2][\relax]{%
% \ensuremath{\mathrel{
% \mathop{\longrightarrow}\limits^{#2\mathstrut}_{
% \begin{subarray}{l} #1 \end{subarray}}}}}
% Advantage of length formulation is that between adjacent
% \grstep's you can add \hspace{-\grsteplength} to make it look not too wide
\newlength{\grsteplength}
\setlength{\grsteplength}{1.5ex plus .1ex minus .1ex}
\newcommand{\grstep}[2][\relax]{%
\ensuremath{\mathrel{
\hspace{\grsteplength}\mathop{\longrightarrow}\limits^{#2\mathstrut}_{
\begin{subarray}{l} #1 \end{subarray}}\hspace{\grsteplength}}}}
% If two or more \grsteps are in a row then they need to be tightened
\newcommand{\repeatedgrstep}[2][\relax]{\hspace{-\grsteplength}\grstep[#1]{#2}}
% row swap operation: \rho_1\swap\rho_2
\newcommand{\swap}{\leftrightarrow}
%-------------amatrix
% Augmented matrix. Usage (note the argument does not count the aug col):
% \begin{amatrix}{2}
% 1 2 3 \\ 4 5 6
% \end{amatrix}
\newenvironment{amatrix}[1]{%
\left(\begin{array}{@{}*{#1}{c}|c@{}}
}{%
\end{array}\right)
}
%-------------pmat
% For matrices with arguments.
% Usage: \begin{pmat}{c|c|c} 1 &2 &3 \end{pmat}
\newenvironment{pmat}[1]{
\left(\begin{array}{@{}#1@{}}
}{\end{array}\right)
}
%-------------misc matrices
% \newenvironment{mat}{\left(\begin{array}}{\end{array}\right)}
\newenvironment{detmat}{\left|\begin{array}}{\end{array}\right|}
\newcommand{\deter}[1]{ \mathchoice{\left|#1\right|}{|#1|}{|#1|}{|#1|} }
\newcommand{\generalmatrix}[3]{ %arg1: low-case letter, arg2: rows, arg3: cols
\left(
\begin{array}{cccc}
#1_{1,1} _{1,2} &\ldots _{1,#2} \\
#1_{2,1} _{2,2} &\ldots _{2,#2} \\
&\vdots \\
#1_{#3,1} _{#3,2} &\ldots _{#3,#2}
\end{array}
\right) }
% With mathtools we can have column entries right flushed
% There is an optional argument \begin{mat}[r]{3} .. \end{mat} for
% right-flushed columns. Perhaps the rule is that numbers are better
% right-flushed but if there are any letters it is better centered?
\newenvironment{mat}[1][c]{\begin{pmatrix*} % disable optional arg [#1]
}{\end{pmatrix*}}
% If mat starts with &\vdots get an error; why? No apparent macro fix, according to texexchange
\newenvironment{vmat}[1][c]{\begin{vmatrix*} % disable optional arg [#1]
}{\end{vmatrix*}}
\newenvironment{amat}[2][c]{%
% disable optional arg \left(\begin{array}{@{}*{#2}{#1}|#1@{}}
\left(\begin{array}{@{}*{#2}{c}|#1@{}}
}{%
\end{array}\right)
}
% \newcommand\vdotswithin[1]{% Taken from mathtools.dtx because my TL is not 2011
% {\mathmakebox[\widthof{\ensuremath{{}#1{}}}][c]{{\vdots}}}}
%------------colvec and rowvec
% Column vector and row vector. Usage:
% \colvec{1 \\ 2 \\ 3 \\ 4} and \rowvec{1 &2 &3}
% Colvec takes an optional argument \colvec[r]{x_1 \\ 0}. Perhaps
% digits look better right aligned, but if there are any letters it
% needs to be centered?
\newcommand{\colvec}[2][c]{\begin{mat}[#1] #2 \end{mat}}
% For row vectors, cannot do \newcommand{\rowvec}[1]{\begin{mat} #1 \end{mat}}
% since the delimiters come out too large.
\newcommand{\rowvec}[1]{\setlength{\arraycolsep}{3pt}(\begin{matrix} #1 \end{matrix})}
%-------------making aligned columns
% Usage: \begin{aligncolondecimal}{2} 1.2 \\ .33 \end{aligncolondecimal}
% (negative argument centers decimal pt in column). Also Usage:
% \begin{aligncolondecimal}[0em]{2} 1.2 \\ .33 \end{aligncolondecimal}
% to make the left and right LaTeX-array padding disappear.
\RequirePackage{array}\RequirePackage{dcolumn}
\newenvironment{aligncolondecimal}[2][.1111em]{%
\setlength{\arraycolsep}{#1}
\newcolumntype{.}{D{.}{.}{#2}}\begin{array}{.}}{%
\end{array}}
% Matrix and vector, with numbers centered on decimal point
% Usage: \begin{dmat}{D{.}{.}{1}D{.}{.}{3}} 0 &.123 \\ .2 &.456 \end{dmat}
% (in the D{.}{.}{number} that is the number of decimal places)
\newlength{\dmatcolsep}\setlength{\dmatcolsep}{5pt}
\newenvironment{dmat}[2][\dmatcolsep]{%
\setlength{\arraycolsep}{#1}
\left(\begin{array}{@{}#2@{}}
}{%
\end{array}\right)}
% Usage: \dcolvec[2]{1.23 \\ 4.56} where the optional argument is the number
% of decimal places.
\newcommand{\dcolvec}[2][-1]{\left(\begin{array}{@{}D{.}{.}{#1}@{}} #2 \end{array}\right)}
%=============================================
% misc math definitions
%
\DeclareMathOperator{\trace}{Tr}
\DeclareMathOperator{\rank}{rank}
\DeclareMathOperator{\nullity}{nullity}
\newcommand{\isomorphicto}{\cong}
\newcommand{\rangespace}[1]{ \mathscr{R}(#1) }
\newcommand{\nullspace}[1]{ \mathscr{N}(#1) }
\newcommand{\genrangespace}[1]{ \mathscr{R}_\infty(#1) }
\newcommand{\gennullspace}[1]{ \mathscr{N}_\infty(#1) }
\newcommand{\zero}{ \vec{0} }
\newcommand{\polyspace}{\mathcal{P}}
\newcommand{\matspace}{\mathcal{M}}
\DeclareMathOperator{\size}{size}
\DeclareMathOperator{\adj}{adj}
\DeclareMathOperator{\sgn}{sgn}
% The term being defined.
\newcommand{\definend}[1]{\emph{#1}}
% Blackboard bold letters
\renewcommand{\Re}{\mathbb{R}}
% \newcommand{\C}{\mathbb{C}}
% \newcommand{\N}{\mathbb{N}}
% \newcommand{\Q}{\mathbb{Q}}
% \newcommand{\Z}{\mathbb{Z}}
\ifdefined\Re
\renewcommand{\Re}{\mathbb{R}}
\else
\newcommand{\Re}{\mathbb{R}}
\fi
\newcommand{\R}{\mathbb{R}}
\ifdefined\C
\renewcommand{\C}{\mathbb{C}}
\else
\newcommand{\C}{\mathbb{C}}
\fi
\newcommand{\N}{\mathbb{N}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\Z}{\mathbb{Z}}
% a field
\newcommand{\F}{\mathcal{F}}
% functions
\newcommand{\map}[3]{\mbox{$#1\colon #2\to #3$}}
\newcommand{\mapsunder}[1]{\stackrel{#1}{\longmapsto}}
% \newcommand{\mapsvia}[1]{\stackrel{#1}{\longrightarrow}}
\newcommand{\mapsvia}[1]{\xrightarrow{#1}}
% doesn't seem to be in mathtools: \newcommand{\mapsunder}[1]{\xrightmapsto{#1}}
\newcommand{\xmapsunder}[1]{\mapsunder{#1}}
\newcommand{\composed}[2]{#1\mathbin{\circ} #2}
% \newcommand{\identity}{\mbox{id}}
\DeclareMathOperator{\identity}{id}
\newcommand{\restrictionmap}[2]{{#1}\mathpunct\upharpoonright\hbox{}_{#2}}
% emptyset
\renewcommand{\emptyset}{\varnothing}
% sets
% TODO: use braket.sty?
\newcommand{\setspacing}{0.1em} % space between opening bbrace and set elet, and closing brace and set elet. Note: \,=\thinspace=0.16667em
\newcommand{\set}[1]{\mbox{$\{\hspace{\setspacing}#1\hspace{\setspacing}\}$}}
% \newcommand{\suchthat}{\bigm|}
\newcommand{\suchthat}{\mid}
\newcommand{\union}{\cup}
\newcommand{\intersection}{\cap}
\newcommand{\sequence}[1]{ \langle#1\rangle }
% intervals
\newcommand{\interval}[2]{#1\,\ldots\, #2}
\newcommand{\setinterval}[2]{\mbox{$\{\interval{#1}{#2}\}$}} % or \set{\interval{#1}{#2}}
\newcommand{\openinterval}[2]{(\interval{#1}{#2})}
\newcommand{\closedinterval}[2]{[\interval{#1}{#2}]}
\newcommand{\clopinterval}[2]{[\interval{#1}{#2})}
\newcommand{\opclinterval}[2]{(\interval{#1}{#2}]}
%\newcommand{\implies}{\Longrightarrow}
\newcommand{\isimpliedby}{\Longleftarrow}
\newcommand{\Sage}{\textit{Sage}}
\newcommand{\Maple}{\textit{Maple}}
%\newcommand{\complement}[1]{\overline{#1}}
\newcommand{\cat}[2]{#1\!\mathbin{\raise.6ex\hbox{\( {}^\frown \)}}\!#2}
\newenvironment{strings}{\arraycolsep=.222em \begin{array}[t]}{\end{array}}
% sometimes want to have a bunch of equations
% a = b
% c = d
% \vdots <-- these should be cnetered on the `='
% e = f
\newlength{\equalsignwd} \settowidth{\equalsignwd}{$=$}
\newcommand{\alignedvdots}[1][10pt]{\mskip2.5mu\makebox[.5\equalsignwd][r]{}%
\smash{\vdots}\rule{0pt}{#1}}
% (my version of mathtools doesn't (yet) have \shortvdotswithin)
\newcommand{\stdbasis}{{\cal E}}
\newcommand{\basis}[2]{\sequence{\vec{#1}_1,\ldots,\vec{#1}_{#2}}}
\newcommand{\rowspace}[1]{ \mathop{{\mbox{Rowspace}}}(#1) }
\newcommand{\colspace}[1]{ \mathop{{\mbox{Columnspace}}}(#1) }
\newcommand{\linmaps}[2]{ \mathop{{\cal L}}(#1,#2) }
\newcommand{\lincombo}[2]{
#1_1#2_1+#1_2#2_2+\cdots +#1_n#2_n}
\newcommand{\rep}[2]{ {\rm Rep}_{#2}(#1) }
\newcommand{\wrt}[1]{{\mbox{\scriptsize \textit{wrt}\hspace{.25em}\( #1 \)} }}
% \newcommand{\trans}[1]{ {{#1}^{\rm trans}} }
\newcommand{\trans}[1]{ {{#1}^{\mathsf{T}}} } % \textsf?
\newcommand{\proj}[2]{\mbox{proj}_{#2}({#1}) }
\newcommand{\spanof}[1]{\relax [#1\relax ]} % no optional argument!
\newcommand{\directsum}{\oplus}
% \newcommand{\norm}[1]{\|#1\|}
% \newcommand{\absval}[1]{|#1|}
% From http://tex.stackexchange.com/questions/43008/absolute-value-symbols
\DeclarePairedDelimiter\absval{\lvert}{\rvert}%
\DeclarePairedDelimiter\norm{\lVert}{\rVert}%
\DeclareMathOperator{\dist}{dist}
% dot product
% I like to use a slightly different circle for dot product, for
% a visual distinction.
% The AtBeginDocument makes pdflatex happier
\AtBeginDocument{\newlength{\heightofcdot}
\newlength{\widthofcdot}
\settoheight{\heightofcdot}{$\cdot$}
\settowidth{\widthofcdot}{$\cdot$}
\newsavebox{\dotprodcircle}
% 2012-Jan-06 JH \bullet too big:
\savebox{\dotprodcircle}{\scalebox{0.55}{$\bullet$}}
% 2012-Jan JH mpost won't take the graphic
% \savebox{\dotprodcircle}{\includegraphics{dotprod.1}}
\newcommand{\dotprod}{\mathbin{\raisebox{.25\heightofcdot}{%
\makebox[\widthofcdot]{$\smash{\usebox{\dotprodcircle}}$}}}}}
\newcommand{\nbyn}[1]{#1 \! \times \! #1 } % \! is negative thinspace
\newcommand{\nbym}[2]{#1 \! \times \! #2 } % Use in math mode.
% degrees
\newcommand{\degs}[1]{#1^\circ\relax}
% for the voting material
\newcommand{\votepreflist}[3]{\colvec{#1 \\ #2 \\ #3}}
\newcommand{\voteprefloop}[3]{% #1 at 10 o'clock, #2 at 6, #3 at 2 o'clock
\raisebox{.16in}{\scriptsize #1}%
{\renewcommand{\arraystretch}{1.0}
\begin{tabular}{@{}c@{}}
\makebox[.32in]{\includegraphics{ch2.20}} \\[-.075in]
\makebox[.1in]{{\scriptsize #2}}
\end{tabular}}
\raisebox{.16in}{\scriptsize #3}%
}
\newcommand{\votinggraphic}[1]{\hspace{1.15em}\mathord{\raisebox{-.2in}[.3in][.2in]{\includegraphics{voting.#1}}}\hspace{1.15em}}
% for magic squares
\newcommand{\magicsquares}{\mathscr{M}}
\newcommand{\semimagicsquares}{\mathscr{H}}
% for the networks topic
\newcommand{\circuitfont}{\sffamily}
% for the Nilpotence material
\newcommand{\digitinsq}[1]{\fbox{\( #1 \)} }
\newlength{\widthofdigitinsq}
\settowidth{\widthofdigitinsq}{\digitinsq{1}}
\newcommand{\digitincirc}[1]{%\mbox{\( #1 \)}
\makebox[\widthofdigitinsq]{%
\setlength{\unitlength}{1pt}%
\begin{picture}(0,0)(0,-3)
\thinlines
\put(0,0){\circle{12}}
\put(0,-3){\makebox[0pt]{#1}}
\end{picture}}}
% For recurrence relations
\usepackage{xfrac} % make proper fractions: 1/2
% In tables of matrices, add a bit of extra space above and below each line.
% Note that the included material is set in math mode
\newlength{\extramatrixvspace}
\setlength{\extramatrixvspace}{.75ex}
\newcommand{\matrixvenlarge}[1]{\raisebox{-0.5\height}{\vbox{
\vspace*{\extramatrixvspace}
\hbox{$#1$}
\vspace*{\extramatrixvspace}
}}}
% from ltugboat.cls 2000-Apr-27 for making dashes.
% Really for 10 pt only.
%\def\thinskip{\hskip 0.16667em\relax}
%\def\endash{--}
%\def\emdash{\endash-}
%\def\d@sh#1#2{\unskip#1\thinskip#2\thinskip\ignorespaces}
%\def\dash{\d@sh\nobreak\endash}
%\def\Dash{\d@sh\nobreak\emdash}
%\def\ldash{\d@sh\empty{\hbox{\endash}\nobreak}}
%\def\rdash{\d@sh\nobreak\endash}
%\def\Ldash{\d@sh\empty{\hbox{\emdash}\nobreak}}
%\def\Rdash{\d@sh\nobreak\emdash}
% Vertically center graphics
% ex: \vcenteredhbox{\usegraphics{mygraph.png}}
% From http://tex.stackexchange.com/questions/7219/how-to-vertically-center-two-images
\newcommand*{\vcenteredhbox}[1]{\begingroup
\setbox0=\hbox{#1}\parbox{\wd0}{\box0}\endgroup}
%---------------------hyphenations
\hyphenation{range-space}
\hyphenation{range-spaces}
\hyphenation{null-space}
\hyphenation{null-spaces}
\hyphenation{re-la-tion}
\hyphenation{re-la-tions}
\hyphenation{re-la-tion-ship}
% In mechanics of matrix manipulation;
% show some parts of a formula
\newcommand{\highlightcolorname}{lightgray}
% \newcommand{\highlight}[1]{{\setlength{\fboxsep}{.15em}%
% \colorbox{\highlightcolorname}{#1}}}
\usepackage{calc} % needed for \widthof
\usepackage{transparent}
% \usepackage{tikz} % for transparency
% \newcommand{\highlight}[1]{\makebox[\widthof{#1}]{\makebox[0pt]{\transparent{0.5}\colorbox{\highlightcolorname}{#1}}}}
\newcommand{\highlight}[1]{{%
\setlength{\fboxsep}{1pt}%
\setlength{\fboxrule}{0.2pt}%
\framebox{#1}}}
% \newcommand{\highlight}[1]{\makebox[\widthof{#1}]{\begin{tikzpicture}[unit=1em]#1 \draw[fill=lightgray, ultra thin, lightgray, opacity=0.6] (0,0) rectangle (1,1); \end{tikzpicture}}}
\endinput