# How to do these lines within a matrix?

i try to do this:

How to do that? Can you help me?

Here is my code for the matrix without the lines:

\left [
\begin{matrix}
r_{11} & r_{12} & \dots & r_{1i} & r_{1,i+1} & \dots & r_{1n} & c_1\\
\lambda_{21} & r_{22} & \dots & r_{2i} & r_{2,i+1} & \dots & r_{2n} & c_2\\
\lambda_{31} & \lambda_{32} & & r_{3i} & r_{3,i+1} & \dots & r_{3n} & c_3\\
\vdots & \vdots & \ddots & \vdots & \vdots & & \vdots & \vdots \\
\lambda_{i1} & \lambda_{i2} & & r_{ii} & r_{i,i+1} & \dots & r_{in} & c_i\\
\lambda_{i+1,1} & \lambda_{1+2,2} & & \lambda_{i+1,i} & a_{i+1,i+1}^{(i)} & \dots & a_{i+1,n}^{(i)} & b_{i+1}^{(i)}\\
\vdots & \vdots & & \vdots & \vdots & & \vdots & \vdots \\
\lambda_{n,1} & \lambda_{n,2} & \dots & \lambda_{n,i} & a_{n,i+1}^{(i)} & \dots & a_{n,n}^{(i)} & b_n^{(i)}\\
\end{matrix}
\right ]


Thank you so much.

• Can you at least provide the code for the matrix without the lines? – egreg Dec 19 '13 at 22:14
• sure i can, i will edit the code – texNewbie Dec 19 '13 at 22:14

With array it is easy:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

$\left [ %\begin{matrix} \begin{array}{*7{c}|c} r_{11} & r_{12} & \dots & r_{1i} & r_{1,i+1} & \dots & r_{1n} & c_1\\ \cline{1-1} \multicolumn{1}{c|}{ \lambda_{21}} & r_{22} & \dots & r_{2i} & r_{2,i+1} & \dots & r_{2n} & c_2\\ \cline{2-2} \lambda_{31} & \multicolumn{1}{c|}{\lambda_{32}} & & r_{3i} & r_{3,i+1} & \dots & r_{3n} & c_3\\ \vdots & \vdots & \ddots & \vdots & \vdots & & \vdots & \vdots \\ \lambda_{i1} & \lambda_{i2} & & \multicolumn{1}{|c}{r_{ii}} & r_{i,i+1} & \dots & r_{in} & c_i\\ \cline{4-8} \lambda_{i+1,1} & \lambda_{1+2,2} & & \lambda_{i+1,i} & a_{i+1,i+1}^{(i)} & \dots & a_{i+1,n}^{(i)} & b_{i+1}^{(i)}\\ \vdots & \vdots & & \vdots & \vdots & & \vdots & \vdots \\ \lambda_{n,1} & \lambda_{n,2} & \dots & \lambda_{n,i} & a_{n,i+1}^{(i)} & \dots & a_{n,n}^{(i)} & b_n^{(i)}\\ %\end{matrix} \end{array} \right ]$

\end{document}


Some additional vertical correction would be useful.

Edit: It is the logic of probable meaning of the step line, but egreg's suggestion of logic of producing columns is a good alternative.

• I'd use \multicolumn{1}{c|}{} in the empty cell, rather than \multicolumn{1}{|c}{r_{ii}}; the rules should always go at the end of a column specifier (except for the first column). Adding \rule{0pt}{3ex} in the cell after \cline{4-8} will make some more room for the high exponents in the row. – egreg Dec 19 '13 at 22:55