L TEX-ing: Linear Algebra
L TEX-ing: Linear Algebra
A
EX-ingLinear Algebra
Jim Hefferon
2016-July-04
This document contains instructions for compiling the source to Jim Hefferon’s undergraduate textbook
Linear Algebra.
1.2 It is Free
These materials are freely available, in both readable and source form.
First, you are free to download the book. If you are an instructor then you are also free to have students
in your class use paper or electronic copies as a course text, either as the main text or as an auxilliary text.
This includes the freedom to print out copies and sell them from your bookstore. But note that hard copies
are for sale from major distributers such as Amazon and the college bookstore distributer; the price is less
than it used to cost to get our print shop to make comb-bound versions.
Besides being free to use the output form of the text, you are also free to use the source. Some examples
of how this can be helpful are: an instructor can add a few favorite exercises here and there, perhaps include
a new Topic, adjust the development in a subsection, or even rewrite a portion entirely. Another example
is: someone who finds an error, say in the answer to an exercise, can send me the correction (email me a
section and subsection number and a description, ideally and also a correction).
I welcome contribution of work back to the project. I of course reserve the ability to not use some things
but all the contributions that I do use are acknowledged in the file Acknowledgements.
1
2.1 Compiling from source
Unzip the contents of linear_algebra.zip. This makes a new directory book.
The book’s source comes in a number of separate files. In addition to separate files for each section, such
as gr1.tex for the first section of the first chapter, here are some other key files.
file name what it is
book.tex Main file
bookjhconcrete.sty Formatting instructions
linalgjh.sty Macros for Linear Algebra
jhanswer.tex Main file for the answers
cover.tex Make the front, back, and spine
After you get the files, you will have in your directory many .tex files, a few .mp files, and a few other
types such as LATEX style files .sty. The .tex files are for LATEX and the .mp files are for MetaPost for the
graphics (a few graphics are in forms such as .jpg). There are also some graphic files for the Asymptote
system, in the subdirectory /asy.
2.1.1 The easy way
If you are on a Unix-y machine, such as Linux, try running ./make_book_for_web.sh from the command
line. That’s how I produce a version of the book.
If you are not on a Unix machine then you have to read make_book_for_web.sh and mimic the steps.
(really, it would be easier to learn Unix.) These steps will give a printable version.
2
One area that can be annoying is that errors in the answer file do not tell you the line number in the
original source file. Instead, they tell you the line number in the source file for the answers (probably
bookans.tex ). That file was written when you LATEX-ed the book. So don’t edit that file since your changes
will disappear the next time you do the book again. Instead, you can look up that line in the answer’s
source, then look for that same line in the original source. Edit that one. Then LATEX the book again.
Thank goodness for fast computers. (Getting the line numbers from the original source into bookans.tex
somehow would be a fine project for someone.)
One trouble that I’ve had comes when switching between a hyperref -ed and non-hyperref -ed versions.
LATEX complains about not liking the cross-reference file (something about “fifthoffive”). My solution is to
delete all the cross-reference files (under Linux, rm -f *.aux *.toc), and then rerun the LATEX command
line twice. Not very elegant, I know, and once I accidentally left out the . between the * and the aux, but I
am over that now.
2.1.3 Slides
I have some slides for a classroom projector. These are keyed to the text in a couple of ways.
First, they reference numbers for theorems, lemmas, etc. These references are generated automatically,
meaning that I did not input them by hand, so in theory they are accurate.
Second, I have changed almost all the examples from the text. This way students see twice as many.
Third, the system is set so that the source of the statements of definitions, theorems, etc., is the text.
Thus there is guaranteed, in theory, to be no discrepency with the text.
You can generate slides by changing into the \slides directory and running ./make_slides.sh. Some
of the graphics take a few minutes to run so you need to be patient.
linsys Make a linear system, in such a way that the columns line up. Here is an example of a three-unknowns
system; you want to do this only as a displayed equation.
\begin{equation*}
\begin{linsys}{3}
x &+ &3y &+ &a &= &7 \\
x &- &3y &+ &a &= &7
\end{linsys}
\end{equation*}
If a row is without some of the variables, be sure to nonetheless add the appropriate &’s.
3
\begin{equation*}
\begin{linsys}{3}
x &+ &3y &+ &a &= &7 \\
& &3y & & &= &7
\end{linsys}
\end{equation*}
In the special case that a row starts with a negative sign, do not use &−. That is, do not start the
second line below with &- &3y.
\begin{equation*}
\begin{linsys}{3}
x &+ &3y &+ &a &= &7 \\
& &-3y&+ &a &= &7
\end{linsys}
\end{equation*}
Remarks.
1. In the exercises I might have three or four linear systems on a horizontal line and to get them to
line up (to be t-aligned) I included an optional argument governing that vertical alignment.
2. LATEX note. The variables are put in the columns right-justified, while the additions or subtrac-
tions are centered. Between the columns is put 4/18-ths of an em (TEXbook, p. 167–170; that’s
a medmuskip).
3. LATEX note. The argument saying how many variables (which in the examples above is the 3) is
there instead of some quite large number because it isn’t as simple as arg + 1 times rc. But I
wasn’t sure, and might be convinced to change this by someone who knows what they are doing
here.
grstep Denote a step of Gauss’s Method.
\begin{equation*}
\begin{linsys}{2}
x &+ &y &= &0 \\
x &- &y &= &1
\end{linsys}
\grstep{-\rho_1+\rho_2}
\begin{linsys}{2}
x &+ &y &= &0 \\
& &-2y&= &1
\end{linsys}
\end{equation*}
Show more than one row operation at a time with \grstep[2\rho_5]{\rho_1+\rho_3} for two
row operations, or \grstep[2\rho_5 \\ 3\rho_6]{\rho_1+\rho_3} for three. Swap two rows with
\rho_1\swap\rho_2.
matrix structures Generic matrices are made with mat.
\begin{equation*}
\begin{mat}
1 &2 &3 \\
4 &5 &6
\end{mat}
\end{equation*}
4
Note that there is no need to specify the number of columns; see the amsmath documentation.
There is an optional argument to make the columns right-aligned.
\begin{equation*}
\begin{mat}[r]
1 &2 &13 \\
4 &5 &6
\end{mat}
\end{equation*}
I restrict its use to those matrices (and column vectors) that contain only numbers, no variables at all.
There are places where I needed something a little different. In particular, I needed augmented matrices:
\begin{equation*}
\begin{amat}{2}
1 &2 &3 \\
4 &5 &6
\end{amat}
\end{equation*}
produces a matrix that is two-by-three, with a vertical bar between the final and next-to-final columns.
The argument 2 means that there are two columns before the vertical bar. (This also has an optional
argument to right-align.) I also sometime need matrices partitioned into columns:
\begin{equation*}
\begin{pmat}{c|c|c}
1 &2 &3 \\
4 &5 &6
\end{pmat}
\end{equation*}
produces a two-by-three matrix that has vertical bars separating the columns.
I make displayed determinant arrays with vmat
\begin{equation*}
\begin{vmat}
a &c \\
b &d
\end{vmat}
=ad-bc
\end{equation*}
and in-line determinants with \deter{A}. (Again, there is an optional argument to right-align.)
vectors Make column vectors with \colvec{1 \\ 2 \\ 3}. (There is an optonal argument to right-align
that I use for number-only vectors \colvec[r]{1 \\ 2 \\ 3}) Make row vectors with \rowvec{1 &2 &3}.
\begin{equation*}
\begin{aligncolondecimal}{3}
15.12 &0.345
\end{aligncolondecimal}
\end{equation*}
5
makes a column vector aligned on the decimal with room for at most three decimal places on the right.
strings A digit 3 in a square is \digitinsq{3}. Not surprisingly, a digit 3 in a circle is \digitincirc{3}.
A sequence of strings is shown this way.
\begin{equation*}
\begin{strings}{ccccc}
\vec{e}_1 &\mapsto &\vec{e}_2 &\mapsto &\zero \\
\vec{e}_3 &\mapsto &\zero
\end{strings}
\end{equation*}
There are five c’s because the longest line is of length five.
names for things Note that there is a page (inside the book’s cover) covering the notation conventions.
I tried to remember to make up macros to name things, rather than retype the thing each time I ran
across it. Here is a list.
1. The reals \Re, the rationals \Q, the complex numbers \C, the integers \Z, and the natural numbers
\N come out in the traditional “blackboard bold”.
2. A vector is \vec{v}_j. The zero vector is \zero. The length of a vector is \norm{\vec{v}},
and the absolute value of a number is \absval{r}. An angle can be expressed in degrees as
$53\degs$. The distance between two vectors is \dist (\vec{v}_1,\vec{v}_2).
3. The dot product of two vectors \vec{v}\dotprod\vec{w}. Please note that (as it is set up coming
from me) this is different than a \cdot.
4. The vector space of degree n polynomials \polyspace_n, and the vector space of n-by-m matrices
\matspace_{\nbym{n}{m}}. The vector space of linear maps from V to W \linmaps{V}{W}.
5. The span of a set S of vectors \spanof{S}.
6. The row space of a matrix is \rowspace{M} and the columnspace is \colspace{M}.
7. A set is \set{\colvec{x \\ y}\suchthat 2x+y=0}. The union and intersection of the sets S
and T is S\union T and S\intersection T. The complement of a set is \complement{S}.
8. The empty set is \emptyset.
9. A sequence, such as a string, is \sequence{s_0,s_1,\dots,s_n}. The concatenation of two
sequences is \cat{B_1}{B_2}.
10. A basis is \basis{\vec{\beta}_1,\dots,\vec{\beta}_n}. The standard basis for real n-space
is \stdbasis_n.
11. Isomorphic spaces is V\isomorphicto W.
12. The matrix representing a linear map h with respect to the bases B and D is \rep{h}{B,D}.
13. The size of a general matrix is \nbym{n}{m} while the special case of a square matrix is \nbyn{n}.
14. A map h’s range space \rangespace{h} and null space \nullspace{h}, and generalized range
space \genrangespace{h} and generalized null space \gennullspace{h}
15. The direct sum of two subspaces V\directsum W.
16. The function, as specified by its domain and codomain, is described by \map{f}{D}{C}. Its action
on a single element x is x\mapsunder{f} f(x). Two maps are composed with \composed{g}{f}.
The identity map is \identity.
17. The projection of a vector into a subspace \proj{\vec{v}}{S}.
18. The restriction of a map to some subdomain is \restrictionmap{f}{S}.
19. The rank of a matrix \rank (A) and the nullity of a matrix \nullity (A). The transpose of a
matrix \trans{A}. The trace of a matrix \trace (A). The adjoint of a matrix is \adj (A).
6
20. The size of a box is \size (B).
21. The signum of a permutation φ is \sgn (\phi).
22. For the Topic on voting, voter preferences are indicated by \votepreflist{7}{1}{5} for the
column vector, and \voteprefloop{1}{2}{3} for the circle (for this one, the first argument
appears at the ten o’clock position, the second argument at six o’clock, and the third argument
at two o’clock).
23. A generic field is \F.
aligned vdots To make \vdots come out inside a bunch of aligned equations, I use \vdotswithin{} from
the mathtools package.
\begin{align*}
a_{1,1}x_1+\cdots+a_{1,n}x_n &= d_1 \\
&\vdotswithin{=} \\
a_{m,1}x_1+\cdots+a_{m,n}x_n &= d_m
\end{align*}
Otherwise the three vertical dots are not centered on the equals sign.
theorem-like structures I have already declared the theorem, lemma, definition, and corollary envi-
ronments. These will come out shaded. To change this, or the color of the shading or its border, see
also bookjh.sty
\begin{definition}
A \definend{big} vector space is one where you can’t see the end when
you are standing at the zero vector, even with your glasses on.
\end{definition}
\begin{proof}
Because I said so; that’s why.
\end{proof}
\begin{center}
\includegraphics{gr2.7}
\end{center}
7
Putting two graphics side-by-side, or putting parallel text, are all a bit messy. I use vcenteredhbox{}.
Just mimic what I did somewhere.
exercises and answers The exercise portions of a subsection looks like you might expect.
\begin{exercises}
\item
First Exercise
\begin{answer}
Answer to the first exercise.
\end{answer}
\item
Second Exercise
\begin{answer}
Answer to the second.
\end{answer}
\recommended \item
Third Exercise, recommended.
\begin{answer}
Answer to the third.
\end{answer}
\end{exercises}
Exercises are, of course, numbered automatically, in the same sequence as the other numbered parts
of the text.
My goal is to have all exercises have answers, even the proof exercises. Of course, the answers are not
written directly to the text; they are written to one or two separate files. Use jhanswer.tex to print
them.
Remarks.
1. Some of the exercises have parts. I use the environment exparts. The items in such an environ-
ment are \partsitem’s.
\recommended\item Do this one right away.
\begin{exparts}
\partsitem Do this first.
\partsitem Do this second.
\end{exparts}
\begin{answer}
\begin{exparts}
\partsitem Answer to the first.
\partsitem Answer to the second.
\end{exparts}
\end{answer}
I sometimes use exparts*, which leaves the items in a horizontal list, but it doesn’t work very well
(it sometimes causes TEX’s Underfull hbox errors; this is not as easy to fix as using a paralist
because I don’t want the beginning of a part on one line and the end on another).
2. Any desired changes to the spacing, etc., of exercises is in exerciselist. See also the style for
the answers in bookans.sty.
3. You can redefine \recommendationmark to change the mark used to denote recommended exer-
cises. You can also mark puzzles with \puzzle\item. This can be combined with \recommended.
4. If you are putting in an exercise without an answer, your best bet is to put an answer environment
that is blank. But really, you shouldn’t do that. I have found that doing the answers to all of
8
the exercises improved both the questions and the presentation greatly, since I often found that
I needed a detail here, or some tweak there. (If what you want is that students can’t read the
answer in their answer list, that is a different matter. See the next two remarks.)
5. These answers are typically quite detailed, giving the work and not just the answer; I approached
the answers expecting that the reader wants to learn and did not take the approach that the
reader is trying to cheat. (Remark. As a practicing teacher, I am very aware that it is not a
simple issue. Nonetheless, in my opinion, a reader is entitled to enough exercise and answer pairs
that, having tried a good selection and not just read the questions and peeked at the answers,
they can move on well-prepared to the next subsection. I figure that a dozen such pairs in each
subsection is about right. Then, to provide a selection and also to allow someone a second crack
at a problem type that gave them trouble the first time, I aimed for two dozen questions in each
subsection. If this question/answer situation bothers you, I would very much welcome additional
submissions of exercise sets for which students do not have access to the answers.)
6. I used to have it set up so that you can have the answers written to either a single file, or separate
files for the answers to recommended exercises and the answers to the others. Although I no
longer do that, I haven’t deleted the code so maybe you could get it to work. (In this Internet
age, trying to control access to such files quickly proved to be folly. For a while I only released
the entire answers to people who emailed me with a claim to being an instructor, but soon the
silliness of that became too much to even hold a pretense. I’ll just say that every twenty year old
on the planet who can come up in minutes with a download address for the answers to exercises
for any popular math text. It is just a fact.)
7. LATEX note. You can use \ref’s inside answers, even though they are written to other files. The
style for the answers reads in the reference files.
8. An answer that is taken from a cited source may not blend stylistically with the others (insofar
as I have a style). I use the disclaimer \answerasgiven.
tfae A small environment for The Following are Equivalent-type lists.
\usepackage{
..,
9
linkcolor=blue,
..}{hyperref}
entry.
\begin{exam}
\item \pts{15}
How much wood could a woodchuck chuck?
\begin{enumerate}
\item If he would chuck wood?
\item If not?
\end{enumerate}
\item \pts{85}
Justify the Axiom of Choice, since we all know it is true anyway.
\end{exam}
5 Bugs
See the TODO.org file in the source.
10