9

i try to do this:

](http://www7.pic-upload.de/19.12.13/547iej1463a4.jpg)

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.

2
  • 1
    Can you at least provide the code for the matrix without the lines? Commented Dec 19, 2013 at 22:14
  • sure i can, i will edit the code Commented Dec 19, 2013 at 22:14

2 Answers 2

8

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}

enter image description here

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.

1
  • 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. Commented Dec 19, 2013 at 22:55
1

With {bNiceArray} of nicematrix. That environment is similar with the classical {array} (of the package array) but creates PGF/Tikz nodes under the cells, rows and columns. It's possible to use these nodes with Tikz to draw whatever rule you want in the \CodeAfter of the environment.

\documentclass{article}
\usepackage{nicematrix,tikz}

\begin{document}

$\begin{bNiceArray}{ccccccc|c}[margin]
    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)}\\
\CodeAfter
  \tikz \draw (2-|1) -| (3-|2) -| (4-|3) (5-|4) |- (6-|last) ; 
\end{bNiceArray}$

\end{document}

You need several compilations (because of the PGF/Tikz nodes).

Output of the above code

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.