[Tex/LaTex] What’s the best way make an “augmented” coefficient matrix

math-modematrices

When studying systems of linear equations, it's nice to remind people that the last column of the coefficient matrix holds the constants. This is often done in books by putting a vertical line between the last column and the next to last column. What is a good way to do this in LaTex?

Best Answer

One way to do this is implemented in the (free, in both senses!) online linear algebra textbook Linear Algebra by Jim Hefferon. It's written in LaTeX and is open-source so one can download the book and its attendant style files. One of them, called linalgjh.sty is about typesetting common linear algebra stuff such as augmented matrices and row reductions and the like. The code for the augmented matrices is:

\newenvironment{amatrix}[1]{%
  \left(\begin{array}{@{}*{#1}{c}|c@{}}
}{%
  \end{array}\right)
}

and is used as:

\begin{amatrix}{2}
   1 & 2 & 3 \\  a & b & c
 \end{amatrix}

(note that the argument is one less than the total number of columns). I guess that the @{}s at the start and end are to get the spacing right with the parentheses (mentioned by TH in a comment to fabikw's similar answer).

That style file has several other useful linear algebra macros that may be useful.

Related Question