3

I'm using overleaf and I am trying to shade entries in a matrix like the picture below :

enter image description here

and this is my work without that shading.

enter image description here

Can anyone help?

This is my code :

\documentclass{article}

\usepackage[english]{babel} \usepackage[a4paper,top=2cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}

\usepackage{amsmath} \usepackage{amssymb} \usepackage{amsthm} \usepackage{enumerate} \usepackage{enumitem} \usepackage{graphicx} \usepackage{xcolor} \usepackage{indentfirst} \usepackage{tabularx} \usepackage{bm} \usepackage[colorlinks=true, allcolors=teal]{hyperref} \usepackage[T1]{fontenc}

\begin{document}

\makeatother \begin{tabularx}{0.9\linewidth}{l@{}c@{}X} \textbf{2.3.6} & $\quad$ & \textbf{Inverse of a Matrix Using Its Adjoint} \ & & If $A$ is an invertible matrix, then \begin{equation} A^{-1} = \frac{1}{\det(A)} \operatorname{adj}(A) \end{equation} \end{tabularx}

\begin{tabularx}{0.9\linewidth}{l@{}c@{}X} \textbf{Proof} & $\quad$ & We show first that $$A \operatorname{adj}(A) = \det(A) I$$ Consider the product $$A \operatorname{adj}(A) = \begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1n} \ a_{21} & a_{22} & \cdots & a_{2n} \ \vdots & \vdots & & \vdots \ a_{i1} & a_{i2} & \cdots & a_{in} \ \vdots & \vdots & & \vdots \ a_{n1} & a_{n2} & \cdots & a_{nn} \end{bmatrix} \begin{bmatrix} C_{11} & C_{21} & \cdots & C_{j1} & \cdots & C_{n1} \ C_{12} & C_{22} & \cdots & C_{j2} & \cdots & C_{n2} \ \vdots & \vdots & & \vdots & & \vdots \ C_{1n} & C_{2n} & \cdots & C_{jn} & \cdots & C_{nn} \end{bmatrix}$$ The entry in the $i$th row and $j$th column of the product $A \operatorname{adj}(A)$ is \begin{equation} a_{i1} C_{j1} + a_{i2} + C_{j2} + \cdots + a_{in} C_{jn} \end{equation} (see the shaded lines above.) If $i = j$, then (12) is the cofactor expansion of $\det(A)$ along the $i$th row of $A$ (\textbf{Theorem 2.1.1}), and if $i \ne j$, then the $a$'s and the cofactors come from different rows of $A$, so the value of (12) is zero. Therefore, \begin{equation} A \operatorname{adj}(A) = \begin{bmatrix} \det(A) & 0 & \cdots & 0 \ 0 & \det(A) & \cdots & 0 \ \vdots & \vdots & & \vdots \ 0 & 0 & \cdots & \det(A) \end{bmatrix} = \det(A) I \end{equation} Since $A$ is invertible and $\det(A) \ne 0$. Therefore, Equation (13) can be rewritten as $$\frac{1}{\det(A)} [A \operatorname{A}] = I \quad \text{or} \quad A \left[ \frac{1} {\det(A)} \operatorname{adj}(A) \right] = I$$ Multiplying both sides on the left by $A^{-1}$ yields $$A^{-1} = \frac{1}{\det(A)} \operatorname{adj}(A)$$ $\blacksquare$ \ \end{tabularx}

\end{document}

This is my first question here.

Vue
  • 155

1 Answers1

6

With nicematrix you can use \CodeBefore to shade any rectangular area by specifying the upper left and lower right cells:

enter image description here

To color full rows or columns, you can alternatively use \rowcolor{blue!15}{4} and \columncolor{blue!15}{4}. You can use this to shade multiple rows/columns, e.g., \rowcolor{blue!15}{1,3-5}

\documentclass{article}

\usepackage{nicematrix}

\begin{document}

Consider the product [ A \operatorname{adj}(A) = \begin{bNiceMatrix} \CodeBefore \rectanglecolor{blue!15}{4-1}{4-4} \Body
a_{11} & a_{12} & \cdots & a_{1n} \ a_{21} & a_{22} & \cdots & a_{2n} \ \vdots & \vdots & & \vdots \ a_{i1} & a_{i2} & \cdots & a_{in} \ \vdots & \vdots & & \vdots \ a_{n1} & a_{n2} & \cdots & a_{nn} \end{bNiceMatrix} \begin{bNiceMatrix} \CodeBefore \rectanglecolor{blue!15}{1-4}{4-4} \Body C_{11} & C_{21} & \cdots & C_{j1} & \cdots & C_{n1} \ C_{12} & C_{22} & \cdots & C_{j2} & \cdots & C_{n2} \ \vdots & \vdots & & \vdots & & \vdots \ C_{1n} & C_{2n} & \cdots & C_{jn} & \cdots & C_{nn} \end{bNiceMatrix} ]

\end{document}

Sandy G
  • 42,558